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 Jul 1, 2024
1 parent 0549e02 commit 3897d7d
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 @@ -987,7 +987,7 @@ def generate_target(self, target):
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 @@ -1031,7 +1031,7 @@ def generate_target(self, target):
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 @@ -1045,17 +1045,21 @@ def generate_target(self, target):
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 @@ -2950,8 +2954,8 @@ def generate_common_compile_args_per_src_type(self, target: build.BuildTarget) -
def generate_single_compile(self, target: build.BuildTarget,
src: mesonlib.FileOrString,
is_generated: bool = False,
header_deps: T.Optional[T.Sequence[mesonlib.FileOrString]] = None,
order_deps: T.Optional[T.List['mesonlib.FileOrString']] = None,
order_deps: T.Optional[T.Sequence[mesonlib.FileOrString]] = None,
full_deps: T.Optional[T.List['mesonlib.FileOrString']] = None,
extra_args: T.Optional[T.List[str]] = None,
unity_sources: T.Optional[T.List[mesonlib.FileOrString]] = None,
) -> T.Tuple[str, str]:
Expand All @@ -2960,14 +2964,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 @@ -3059,7 +3063,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 3897d7d

Please sign in to comment.