diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-03-09 18:02:47 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-03-09 22:04:38 -0500 |
commit | d897c300f1a76e068f40f9d98182a80de9d2411b (patch) | |
tree | a0bdfe9a8be0380d6f61413ed0efb2e28ea9147b | |
parent | c91a6ad0130e64fabf30b6bae58ae266453ab86a (diff) | |
download | meson-d897c300f1a76e068f40f9d98182a80de9d2411b.zip meson-d897c300f1a76e068f40f9d98182a80de9d2411b.tar.gz meson-d897c300f1a76e068f40f9d98182a80de9d2411b.tar.bz2 |
compiler.preprocess should only update the private name per directory
We add a unique ID to each rule we create, to work around the use of
an entire build target with private directory named "preprocess" per use
of the preprocess() method.
But this ID doesn't need to increment every time it is used anywhere --
only when it is used in the same subdir as a previous time. That is the
only case where it could conflict.
By making the increment counter per-subdir, we can avoid potential
frivolous rebuilds when a new preprocess() is added in a different
directory, the build is reconfigured, and all uses in the entire project
tree suddenly get new output paths even if they haven't changed.
-rw-r--r-- | mesonbuild/interpreter/compiler.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py index da50d7b..4e88145 100644 --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -3,6 +3,7 @@ # Copyright © 2021 Intel Corporation from __future__ import annotations +import collections import enum import functools import os @@ -166,7 +167,7 @@ _COMPILES_KWS: T.List[KwargInfo] = [_NAME_KW, _ARGS_KW, _DEPENDENCIES_KW, _INCLU _HEADER_KWS: T.List[KwargInfo] = [REQUIRED_KW.evolve(since='0.50.0', default=False), *_COMMON_KWS] class CompilerHolder(ObjectHolder['Compiler']): - preprocess_uid = itertools.count() + preprocess_uid: T.Dict[str, itertools.count] = collections.defaultdict(itertools.count) def __init__(self, compiler: 'Compiler', interpreter: 'Interpreter'): super().__init__(compiler, interpreter) @@ -773,7 +774,9 @@ class CompilerHolder(ObjectHolder['Compiler']): if any(isinstance(s, (build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)) for s in sources): FeatureNew.single_use('compiler.preprocess with generated sources', '1.1.0', self.subproject, location=self.current_node) - tg_name = f'preprocessor_{next(self.preprocess_uid)}' + + tg_counter = next(self.preprocess_uid[self.interpreter.subdir]) + tg_name = f'preprocessor_{tg_counter}' tg = build.CompileTarget( tg_name, self.interpreter.subdir, |