aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2019-03-19 11:49:11 +0100
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-04-16 01:46:31 +0000
commitb9774b44851780fc401a78e0e3da7ad8e76b7b54 (patch)
tree55a981a56b875f13988c69c18806810af128cf99
parentad0ba6a911b9fcdca24379bb4f14b4b5a312a3d5 (diff)
downloadmeson-b9774b44851780fc401a78e0e3da7ad8e76b7b54.zip
meson-b9774b44851780fc401a78e0e3da7ad8e76b7b54.tar.gz
meson-b9774b44851780fc401a78e0e3da7ad8e76b7b54.tar.bz2
generator: add dependency on generator in source tree
If find_program() returns a file from the source directory, anything that uses it should add the file to the dependencies, so that they are rebuilt whenever the script changes. Generator is not doing that. While at it, I am doing two related fixes: - Generator is not checking whther the generator actually was found, resulting in a Python error involving NoneType if it isn't. To minimize backwards compatibility issues, I am only raising the error when g.process() is acutally called. - the error message for custom_target with a nonexisting program erroneously mention a not-found external program "nonexistingprogram". The new error is similar to the one I am adding for generators.
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--mesonbuild/build.py12
2 files changed, 11 insertions, 3 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index a3b9ce8..405bd26 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1757,7 +1757,7 @@ rule FORTRAN_DEP_HACK%s
exe_arr = self.exe_object_to_cmd_array(exe)
infilelist = genlist.get_inputs()
outfilelist = genlist.get_outputs()
- extra_dependencies = [os.path.join(self.build_to_src, i) for i in genlist.extra_depends]
+ extra_dependencies = self.get_custom_target_depend_files(genlist)
for i in range(len(infilelist)):
curfile = infilelist[i]
if len(generator.outputs) == 1:
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index dae94b6..66f08d8 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1365,8 +1365,17 @@ class GeneratedList:
self.outfilelist = []
self.outmap = {}
self.extra_depends = []
+ self.depend_files = []
self.preserve_path_from = preserve_path_from
self.extra_args = extra_args
+ if isinstance(generator.exe, dependencies.ExternalProgram):
+ if not generator.exe.found():
+ raise InvalidArguments('Tried to use not-found external program as generator')
+ path = generator.exe.get_path()
+ if os.path.isabs(path):
+ # Can only add a dependency on an external program which we
+ # know the absolute path of
+ self.depend_files.append(File.from_absolute_file(path))
def add_preserved_path_segment(self, infile, outfiles, state):
result = []
@@ -1962,8 +1971,7 @@ class CustomTarget(Target):
final_cmd.append(c)
elif isinstance(c, dependencies.ExternalProgram):
if not c.found():
- m = 'Tried to use not-found external program {!r} in "command"'
- raise InvalidArguments(m.format(c.name))
+ raise InvalidArguments('Tried to use not-found external program in "command"')
path = c.get_path()
if os.path.isabs(path):
# Can only add a dependency on an external program which we