Skip to content

Commit 561a11f

Browse files
vriesdavidmalcolm
authored andcommitted
generate-casts-c.py, xml-to-h.py: Don't search for xml files in pwd
Some python scripts attempt to read xml files (located in the sources) assuming they are present in the current directory. This works when building in the source dir, but breaks building in a separate build dir. Fix this by adding an xmldir argument to these scripts.
1 parent ec0224f commit 561a11f

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
ifneq ($(srcdir),)
1919
VPATH = $(srcdir)
2020
endif
21+
xmldir = $(srcdir)./gcc-c-api/
2122

2223
.PHONY: all clean debug dump_gimple plugin show-ssa tarball \
2324
test-suite testcpychecker testcpybuilder testdejagnu \
@@ -194,7 +195,7 @@ $(PLUGIN_GENERATED_SOURCE_FILES): autogenerated-%.c: generate-%-c.py $(GENERATOR
194195
$(PYTHON) $< > $@
195196

196197
autogenerated-casts.c: autogenerated-gimple-types.txt autogenerated-tree-types.txt autogenerated-rtl-types.txt generate-casts-c.py
197-
$(PYTHON) $(srcdir)generate-casts-c.py autogenerated-casts.c autogenerated-casts.h
198+
$(PYTHON) $(srcdir)generate-casts-c.py autogenerated-casts.c autogenerated-casts.h $(xmldir)
198199

199200
autogenerated-gimple.c: autogenerated-gimple-types.txt autogenerated-tree-types.txt autogenerated-rtl-types.txt maketreetypes.py
200201
autogenerated-tree.c: autogenerated-tree-types.txt maketreetypes.py

gcc-c-api/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
ifneq ($(srcdir),)
1919
VPATH = $(srcdir)
2020
endif
21+
xmldir = $(srcdir)./
2122

2223
.PHONY: all clean check-api
2324

@@ -97,7 +98,7 @@ $(OBJECT_FILES): %.o: %.c $(GENERATED_HEADERS) ../autogenerated-EXTRA_CFLAGS.txt
9798
$(COMPILE.c) $(shell cat ../autogenerated-EXTRA_CFLAGS.txt) $(OUTPUT_OPTION) $<
9899

99100
autogenerated-casts.c: $(SOURCE_XML) xmltypes.py generate-casts-c.py
100-
$(PYTHON) generate-casts-c.py $@
101+
$(PYTHON) $(srcdir)./generate-casts-c.py $@ $(xmldir)
101102

102103
clean:
103104
$(RM) *.so *.o $(GENERATED_HEADERS)
@@ -110,7 +111,7 @@ install: $(LIBGCC_C_API_SO)
110111
PYTHON=python
111112

112113
$(GENERATED_HEADERS): $(SOURCE_XML) xml-to-h.py xmltypes.py
113-
$(PYTHON) xml-to-h.py
114+
$(PYTHON) $(srcdir)./xml-to-h.py $(xmldir)
114115

115116
check-api:
116117
xmllint --noout --relaxng api.rng *.xml

gcc-c-api/generate-casts-c.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def write_footer(out):
5555
*/
5656
''')
5757

58-
def main(c_filename):
58+
def main(c_filename, xmldir):
5959
registry = ApiRegistry()
60-
for xmlfile in sorted(glob.glob('*.xml')):
60+
for xmlfile in sorted(glob.glob(xmldir + '*.xml')):
6161
api = Api(registry, xmlfile)
6262

6363
with open(c_filename, 'w') as c_out:
@@ -86,4 +86,5 @@ def main(c_filename):
8686

8787
write_footer(c_out)
8888

89-
main(c_filename=sys.argv[1])
89+
main(c_filename=sys.argv[1],
90+
xmldir=sys.argv[2])

gcc-c-api/xml-to-h.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ def write_semiprivate_types(registry, out):
293293
write_footer(out)
294294

295295
registry = ApiRegistry()
296-
for xmlfile in sorted(glob.glob('*.xml')):
296+
xmldir=sys.argv[1]
297+
for xmlfile in sorted(glob.glob(xmldir + '*.xml')):
297298
api = Api(registry, xmlfile)
298299
for api in registry.apis:
299300
with open(api.get_header_filename(), 'w') as f:

generate-casts-c.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def write_h(registry, h_out):
103103
% (subclass.get_c_name(), subclass.get_c_name()))
104104
write_footer(h_out)
105105

106-
def main(c_filename, h_filename):
106+
def main(c_filename, h_filename, xmldir):
107107
registry = ApiRegistry()
108-
for xmlfile in sorted(glob.glob('gcc-c-api/*.xml')):
108+
for xmlfile in sorted(glob.glob(xmldir + '*.xml')):
109109
api = Api(registry, xmlfile)
110110

111111
with open(c_filename, 'w') as c_out:
@@ -116,4 +116,5 @@ def main(c_filename, h_filename):
116116

117117

118118
main(c_filename=sys.argv[1],
119-
h_filename=sys.argv[2])
119+
h_filename=sys.argv[2],
120+
xmldir=sys.argv[3])

0 commit comments

Comments
 (0)