Skip to content

Commit

Permalink
backends/ninja: fix dependencies added as full but should be order-only
Browse files Browse the repository at this point in the history
Due to the confusing naming of the parameters, a number of arguments
were incorrectly added as full dependencies when they should be order
only.
  • Loading branch information
dcbaker committed Oct 1, 2024
1 parent 5eb3cb7 commit 3e24341
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ def generate_target(self, target) -> None:
if self.environment.is_llvm_ir(src):
o, s = self.generate_llvm_ir_compile(target, src)
else:
o, s = self.generate_single_compile(target, src, True, order_deps=header_deps)
o, s = self.generate_single_compile(target, src, True, full_deps=header_deps)
compiled_sources.append(s)
source2object[s] = o
obj_list.append(o)
Expand Down Expand Up @@ -1040,7 +1040,7 @@ def generate_target(self, target) -> None:
else:
transpiled_source_files.append(raw_src)
for src in transpiled_source_files:
o, s = self.generate_single_compile(target, src, True, [], header_deps)
o, s = self.generate_single_compile(target, src, True, full_deps=header_deps)
obj_list.append(o)

# Generate compile targets for all the preexisting sources for this target
Expand All @@ -1054,17 +1054,21 @@ def generate_target(self, target) -> None:
src.rel_to_builddir(self.build_to_src))
unity_src.append(abs_src)
else:
o, s = self.generate_single_compile(target, src, False, [],
header_deps + d_generated_deps + fortran_order_deps,
fortran_inc_args)
o, s = self.generate_single_compile(
target, src, False,
full_deps=header_deps + d_generated_deps + fortran_order_deps,
extra_args=fortran_inc_args)
obj_list.append(o)
compiled_sources.append(s)
source2object[s] = o

if is_unity:
for src in self.generate_unity_files(target, unity_src):
o, s = self.generate_single_compile(target, src, True, unity_deps + header_deps + d_generated_deps,
fortran_order_deps, fortran_inc_args, unity_src)
o, s = self.generate_single_compile(
target, src, True,
full_deps=unity_deps + header_deps + d_generated_deps + fortran_order_deps,
extra_args=fortran_inc_args,
unity_sources=unity_src)
obj_list.append(o)
compiled_sources.append(s)
source2object[s] = o
Expand Down Expand Up @@ -2960,8 +2964,8 @@ def generate_common_compile_args_per_src_type(self, target: build.BuildTarget) -
def generate_single_compile(self, target: build.BuildTarget,
src: FileOrString,
is_generated: bool = False,
header_deps: T.Optional[T.Sequence[FileOrString]] = None,
order_deps: T.Optional[T.List[FileOrString]] = None,
order_deps: T.Optional[T.Sequence[FileOrString]] = None,
full_deps: T.Optional[T.List[FileOrString]] = None,
extra_args: T.Optional[T.List[str]] = None,
unity_sources: T.Optional[T.List[FileOrString]] = None,
) -> T.Tuple[str, str]:
Expand All @@ -2970,14 +2974,14 @@ def generate_single_compile(self, target: build.BuildTarget,
:param target: The target which the source belongs to
:param src: The source to be compiled
:param is_generated: Whether this source is generated or static, defaults to False
:param header_deps: Order only dependencies, defaults to None
:param order_deps: Dependencies which cause a full rebuild, defaults to None
:param order_deps: Order only dependencies, defaults to None
:param full_deps: Dependencies which cause a full rebuild, defaults to None
:param extra_args: Extra arguments just for this compilation unit, defaults to None
:param unity_sources: The sources that were combined into this unity, defaults to None
:return: A tuple with the object file that will be created and the source that was compiled
"""
header_deps = header_deps if header_deps is not None else []
order_deps = order_deps if order_deps is not None else []
full_deps = full_deps if full_deps is not None else []

if isinstance(src, str) and src.endswith('.h'):
raise AssertionError(f'BUG: sources should not contain headers {src!r}')
Expand Down Expand Up @@ -3069,7 +3073,7 @@ def generate_single_compile(self, target: build.BuildTarget,
commands.extend(extra_args)

element = NinjaBuildElement(self.all_outputs, rel_obj, compiler_name, rel_src)
self.add_full_deps(target, element, header_deps)
self.add_full_deps(target, element, full_deps)
for d in extra_deps:
element.add_dep(d)
self.add_order_deps(target, element, order_deps)
Expand Down

0 comments on commit 3e24341

Please sign in to comment.