backend/ninja: add generated sources to depscan order deps
Since we changed to using a json file to avoid over long command lines we created a situation where the generated files may not be ready when the depscan happens. To avoid that, we need to add all of the generated sources as order deps. Fixes: #9258
This commit is contained in:
parent
276ff0cc89
commit
40ff02268c
|
@ -887,7 +887,7 @@ class NinjaBackend(backends.Backend):
|
||||||
else:
|
else:
|
||||||
final_obj_list = obj_list
|
final_obj_list = obj_list
|
||||||
elem = self.generate_link(target, outname, final_obj_list, linker, pch_objects, stdlib_args=stdlib_args)
|
elem = self.generate_link(target, outname, final_obj_list, linker, pch_objects, stdlib_args=stdlib_args)
|
||||||
self.generate_dependency_scan_target(target, compiled_sources, source2object)
|
self.generate_dependency_scan_target(target, compiled_sources, source2object, generated_source_files)
|
||||||
self.generate_shlib_aliases(target, self.get_target_dir(target))
|
self.generate_shlib_aliases(target, self.get_target_dir(target))
|
||||||
self.add_build(elem)
|
self.add_build(elem)
|
||||||
|
|
||||||
|
@ -911,7 +911,7 @@ class NinjaBackend(backends.Backend):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def generate_dependency_scan_target(self, target, compiled_sources, source2object):
|
def generate_dependency_scan_target(self, target, compiled_sources, source2object, generated_source_files: T.List[mesonlib.File]):
|
||||||
if not self.should_use_dyndeps_for_target(target):
|
if not self.should_use_dyndeps_for_target(target):
|
||||||
return
|
return
|
||||||
depscan_file = self.get_dep_scan_file_for(target)
|
depscan_file = self.get_dep_scan_file_for(target)
|
||||||
|
@ -929,6 +929,10 @@ class NinjaBackend(backends.Backend):
|
||||||
json.dump(scan_sources, f)
|
json.dump(scan_sources, f)
|
||||||
elem = NinjaBuildElement(self.all_outputs, depscan_file, rule_name, json_abs)
|
elem = NinjaBuildElement(self.all_outputs, depscan_file, rule_name, json_abs)
|
||||||
elem.add_item('picklefile', pickle_file)
|
elem.add_item('picklefile', pickle_file)
|
||||||
|
# Add any generated outputs to the order deps of the scan target, so
|
||||||
|
# that those sources are present
|
||||||
|
for g in generated_source_files:
|
||||||
|
elem.orderdeps.add(g.relative_name())
|
||||||
scaninfo = TargetDependencyScannerInfo(self.get_target_private_dir(target), source2object)
|
scaninfo = TargetDependencyScannerInfo(self.get_target_private_dir(target), source2object)
|
||||||
with open(pickle_abs, 'wb') as p:
|
with open(pickle_abs, 'wb') as p:
|
||||||
pickle.dump(scaninfo, p)
|
pickle.dump(scaninfo, p)
|
||||||
|
|
|
@ -7,9 +7,21 @@ project('generated', 'fortran',
|
||||||
conf_data = configuration_data()
|
conf_data = configuration_data()
|
||||||
conf_data.set('ONE', 1)
|
conf_data.set('ONE', 1)
|
||||||
conf_data.set('TWO', 2)
|
conf_data.set('TWO', 2)
|
||||||
conf_data.set('THREE', 3)
|
|
||||||
|
|
||||||
mod3_f = configure_file(input : 'mod3.fpp', output : 'mod3.f90', configuration : conf_data)
|
mod3_f = custom_target(
|
||||||
|
'mod3.f',
|
||||||
|
input : 'mod3.f90',
|
||||||
|
output : 'mod3.f90',
|
||||||
|
# We need a platform agnostic way to do a copy a file, using a custom_target
|
||||||
|
# and we need to use the @OUTDIR@, not @OUTPUT@ in order to exercise
|
||||||
|
# https://github.com/mesonbuild/meson/issues/9258
|
||||||
|
command : [
|
||||||
|
find_program('python', 'python3'), '-c',
|
||||||
|
'import sys, shutil; shutil.copy(sys.argv[1], sys.argv[2])',
|
||||||
|
'@INPUT@', '@OUTDIR@',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
three = library('mod3', mod3_f)
|
three = library('mod3', mod3_f)
|
||||||
|
|
||||||
templates_basenames = ['mod2', 'mod1']
|
templates_basenames = ['mod2', 'mod1']
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module mod3
|
module mod3
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer, parameter :: modval3 = @THREE@
|
integer, parameter :: modval3 = 3
|
||||||
|
|
||||||
end module mod3
|
end module mod3
|
Loading…
Reference in New Issue