backend/ninja: Add order dependencies for generated sources in rust

pull/8158/head
Dylan Baker 4 years ago
parent bff0b41525
commit caa6d5e16b
  1. 7
      mesonbuild/backend/ninjabackend.py

@ -1582,6 +1582,9 @@ int dummy;
# Compiler args for compiling this target # Compiler args for compiling this target
args += compilers.get_base_compile_args(base_proxy, rustc) args += compilers.get_base_compile_args(base_proxy, rustc)
self.generate_generator_list_rules(target) self.generate_generator_list_rules(target)
orderdeps = [os.path.join(t.subdir, t.get_filename()) for t in target.link_targets]
main_rust_file = None main_rust_file = None
for i in target.get_sources(): for i in target.get_sources():
if not rustc.can_compile(i): if not rustc.can_compile(i):
@ -1598,6 +1601,7 @@ int dummy;
fname = i fname = i
if main_rust_file is None: if main_rust_file is None:
main_rust_file = fname main_rust_file = fname
orderdeps.append(fname)
if main_rust_file is None: if main_rust_file is None:
raise RuntimeError('A Rust target has no Rust sources. This is weird. Also a bug. Please report') raise RuntimeError('A Rust target has no Rust sources. This is weird. Also a bug. Please report')
target_name = os.path.join(target.subdir, target.get_filename()) target_name = os.path.join(target.subdir, target.get_filename())
@ -1635,7 +1639,6 @@ int dummy;
args += target.get_extra_args('rust') args += target.get_extra_args('rust')
args += rustc.get_output_args(os.path.join(target.subdir, target.get_filename())) args += rustc.get_output_args(os.path.join(target.subdir, target.get_filename()))
args += self.environment.coredata.get_external_args(target.for_machine, rustc.language) args += self.environment.coredata.get_external_args(target.for_machine, rustc.language)
orderdeps = [os.path.join(t.subdir, t.get_filename()) for t in target.link_targets]
linkdirs = OrderedDict() linkdirs = OrderedDict()
for d in target.link_targets: for d in target.link_targets:
linkdirs[d.subdir] = True linkdirs[d.subdir] = True
@ -1682,7 +1685,7 @@ int dummy;
args += ['-C', 'link-arg=' + rpath_arg + ':' + os.path.join(rustc.get_sysroot(), 'lib')] args += ['-C', 'link-arg=' + rpath_arg + ':' + os.path.join(rustc.get_sysroot(), 'lib')]
compiler_name = self.get_compiler_rule_name('rust', target.for_machine) compiler_name = self.get_compiler_rule_name('rust', target.for_machine)
element = NinjaBuildElement(self.all_outputs, target_name, compiler_name, main_rust_file) element = NinjaBuildElement(self.all_outputs, target_name, compiler_name, main_rust_file)
if len(orderdeps) > 0: if orderdeps:
element.add_orderdep(orderdeps) element.add_orderdep(orderdeps)
element.add_item('ARGS', args) element.add_item('ARGS', args)
element.add_item('targetdep', depfile) element.add_item('targetdep', depfile)

Loading…
Cancel
Save