aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-05-04 11:31:19 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2021-05-19 23:28:17 +0300
commit0fd907a8cc729d75dfb85820dc8b84c41a5bb8be (patch)
tree57579be620dc07e86b06ba373061638505943b9b
parent7bd7d1cd732c33c3cb301ba62bf46f00ac8d8a1b (diff)
downloadmeson-0fd907a8cc729d75dfb85820dc8b84c41a5bb8be.zip
meson-0fd907a8cc729d75dfb85820dc8b84c41a5bb8be.tar.gz
meson-0fd907a8cc729d75dfb85820dc8b84c41a5bb8be.tar.bz2
build: Simplify BuildTarget.process_sourcelist
-rw-r--r--mesonbuild/build.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index a4a4f19..82f3a13 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -613,16 +613,12 @@ class BuildTarget(Target):
self.pch = {}
self.extra_args: T.Dict[str, T.List['FileOrString']] = {}
self.sources: T.List[File] = []
- self.generated: T.Sequence[T.Union[GeneratedList, CustomTarget, CustomTargetIndex]] = []
+ self.generated: T.List[T.Union[GeneratedList, CustomTarget, CustomTargetIndex]] = []
self.d_features = {}
self.pic = False
self.pie = False
# Track build_rpath entries so we can remove them at install time
self.rpath_dirs_to_remove: T.Set[bytes] = set()
- # Sources can be:
- # 1. Pre-existing source files in the source tree
- # 2. Pre-existing sources generated by configure_file in the build tree
- # 3. Sources files generated by another target or a Generator
self.process_sourcelist(sources)
# Objects can be:
# 1. Pre-existing objects provided by the user with the `objects:` kwarg
@@ -680,19 +676,23 @@ class BuildTarget(Target):
msg = 'Bad object of type {!r} in target {!r}.'.format(type(s).__name__, self.name)
raise InvalidArguments(msg)
- def process_sourcelist(self, sources):
- sources = listify(sources)
- added_sources = {} # If the same source is defined multiple times, use it only once.
- for s in unholder(sources):
+ def process_sourcelist(self, sources: T.List['SourceOutputs']) -> None:
+ """Split sources into generated and static sources.
+
+ Sources can be:
+ 1. Pre-existing source files in the source tree (static)
+ 2. Pre-existing sources generated by configure_file in the build tree.
+ (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:
self.sources.append(s)
- added_sources[s] = True
- elif isinstance(s, (GeneratedList, CustomTarget, CustomTargetIndex)):
+ added_sources.add(s)
+ elif isinstance(s, (CustomTarget, CustomTargetIndex, GeneratedList)):
self.generated.append(s)
- else:
- msg = 'Bad source of type {!r} in target {!r}.'.format(type(s).__name__, self.name)
- raise InvalidArguments(msg)
@staticmethod
def can_compile_remove_sources(compiler, sources):