Skip to content

Commit

Permalink
ninjabackend: ensure structured_sources are populated before running …
Browse files Browse the repository at this point in the history
…clippy

Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Jan 10, 2025
1 parent da83889 commit a0ba17c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ def __init__(self, build: T.Optional[build.Build], interpreter: T.Optional[Inter
self.ninja_filename = 'build.ninja'
self.fortran_deps: T.Dict[str, T.Dict[str, File]] = {}
self.all_outputs: T.Set[str] = set()
self.all_structured_sources: T.Set[str] = set()
self.introspection_data = {}
self.created_llvm_ir_rule = PerMachine(False, False)
self.rust_crates: T.Dict[str, RustCrate] = {}
Expand Down Expand Up @@ -1940,7 +1941,6 @@ def generate_rust_target(self, target: build.BuildTarget) -> None:
if target.structured_sources.needs_copy():
_ods, main_rust_file = self.__generate_sources_structure(Path(
self.get_target_private_dir(target)) / 'structured', target.structured_sources)
orderdeps.extend(_ods)
else:
# The only way to get here is to have only files in the "root"
# positional argument, which are all generated into the same
Expand All @@ -1954,12 +1954,15 @@ def generate_rust_target(self, target: build.BuildTarget) -> None:
else:
main_rust_file = os.path.join(g.get_subdir(), g.get_outputs()[0])

_ods = []
for f in target.structured_sources.as_list():
if isinstance(f, File):
orderdeps.append(f.rel_to_builddir(self.build_to_src))
_ods.append(f.rel_to_builddir(self.build_to_src))
else:
orderdeps.extend([os.path.join(self.build_to_src, f.subdir, s)
for s in f.get_outputs()])
_ods.extend([os.path.join(self.build_to_src, f.subdir, s)
for s in f.get_outputs()])
self.all_structured_sources.update(_ods)
orderdeps.extend(_ods)

for i in target.get_sources():
if not rustc.can_compile(i):
Expand Down Expand Up @@ -3657,6 +3660,7 @@ def generate_clippy(self) -> None:
for crate in self.rust_crates.values():
if crate.crate_type in {'rlib', 'dylib', 'proc-macro'}:
elem.add_dep(crate.target_name)
elem.add_dep(list(self.all_structured_sources))
self.add_build(elem)

def generate_scanbuild(self) -> None:
Expand Down

0 comments on commit a0ba17c

Please sign in to comment.