Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for "ninja clippy" #14111

Merged
merged 2 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,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 @@ -1951,7 +1952,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 @@ -1965,12 +1965,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 @@ -3715,6 +3718,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
2 changes: 1 addition & 1 deletion mesonbuild/scripts/clippy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def warn_missing_clippy(self, machine: str) -> None:

def __call__(self, target: T.Dict[str, T.Any]) -> T.Iterable[T.Coroutine[None, None, int]]:
for src_block in target['target_sources']:
if src_block['language'] == 'rust':
if 'compiler' in src_block and src_block['language'] == 'rust':
clippy = getattr(self.tools, src_block['machine'])
if not clippy:
self.warn_missing_clippy(src_block['machine'])
Expand Down
Loading