diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 9f2e649ec..c1c4c9393 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1582,6 +1582,9 @@ int dummy; # Compiler args for compiling this target args += compilers.get_base_compile_args(base_proxy, rustc) 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 for i in target.get_sources(): if not rustc.can_compile(i): @@ -1598,6 +1601,7 @@ int dummy; fname = i if main_rust_file is None: main_rust_file = fname + orderdeps.append(fname) if main_rust_file is None: 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()) @@ -1635,7 +1639,6 @@ int dummy; args += target.get_extra_args('rust') 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) - orderdeps = [os.path.join(t.subdir, t.get_filename()) for t in target.link_targets] linkdirs = OrderedDict() for d in target.link_targets: linkdirs[d.subdir] = True @@ -1682,7 +1685,7 @@ int dummy; args += ['-C', 'link-arg=' + rpath_arg + ':' + os.path.join(rustc.get_sysroot(), 'lib')] compiler_name = self.get_compiler_rule_name('rust', target.for_machine) element = NinjaBuildElement(self.all_outputs, target_name, compiler_name, main_rust_file) - if len(orderdeps) > 0: + if orderdeps: element.add_orderdep(orderdeps) element.add_item('ARGS', args) element.add_item('targetdep', depfile)