summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick <0xb000@gmail.com>2024-11-04 20:43:33 +0200
committerEli Schwartz <eschwartz93@gmail.com>2024-11-20 01:53:20 -0500
commit7b10f48d1cfbdf4c5d0f061d9da32e057ffdc460 (patch)
treed7792bffa191819c6283dbc4200e33de5086b996
parent3ba0976394553e9ef9039bb1fd74aa2fe212facf (diff)
downloadmeson-7b10f48d1cfbdf4c5d0f061d9da32e057ffdc460.tar.gz
De-duplicate BuildTarget.sources
If the same source is provided by multiple dependencies it was added multiple times, as `added_sources` was only guarding against duplicates within the same source list. This was not a problem with ninja, but it triggers multiple sanity checks within xcode backend while attempting to create multiple ids for the same file. Rename `added_sources` to `seen_sources` as per reviewers request
-rw-r--r--mesonbuild/build.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 0d9374d40..a00209ad4 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -762,6 +762,8 @@ class BuildTarget(Target):
self.pch: T.Dict[str, T.List[str]] = {}
self.extra_args: T.DefaultDict[str, T.List[str]] = kwargs.get('language_args', defaultdict(list))
self.sources: T.List[File] = []
+ # If the same source is defined multiple times, use it only once.
+ self.seen_sources: T.Set[File] = set()
self.generated: T.List['GeneratedTypes'] = []
self.extra_files: T.List[File] = []
self.d_features: DFeatures = {
@@ -884,12 +886,11 @@ class BuildTarget(Target):
(static as they are only regenerated if meson itself is regenerated)
3. Sources files generated by another target or a Generator (generated)
"""
- added_sources: T.Set[File] = set() # If the same source is defined multiple times, use it only once.
for s in sources:
if isinstance(s, File):
- if s not in added_sources:
+ if s not in self.seen_sources:
self.sources.append(s)
- added_sources.add(s)
+ self.seen_sources.add(s)
elif isinstance(s, (CustomTarget, CustomTargetIndex, GeneratedList)):
self.generated.append(s)