aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2022-05-23 14:09:43 +0200
committerDylan Baker <dylan@pnwbakers.com>2022-06-14 10:11:22 -0700
commite4a8f4dbd64dce546b9a7651774b572f52b8f20f (patch)
treec226dac9ab8ea29be339a20b367ee74aed902132
parentdae986073d5ab3a6241cecaf3362065256400772 (diff)
downloadmeson-e4a8f4dbd64dce546b9a7651774b572f52b8f20f.zip
meson-e4a8f4dbd64dce546b9a7651774b572f52b8f20f.tar.gz
meson-e4a8f4dbd64dce546b9a7651774b572f52b8f20f.tar.bz2
backend: always use the same code to compute the files in ExtractedObjects
Instead of asking the ExtractedObjects, but with a hook back into the backend, use the existing function in the backend itself. This fixes using the extract_objects(...) of a generated source file in a custom_target. It should also fix recursive extract_all_objects with the Xcode backend. Fixes: #10394
-rw-r--r--mesonbuild/backend/backends.py14
-rw-r--r--mesonbuild/backend/xcodebackend.py5
-rw-r--r--mesonbuild/build.py8
3 files changed, 9 insertions, 18 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index fb4163f..c3c44e6 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -456,6 +456,10 @@ class Backend:
obj_list = self._flatten_object_list(target, target.get_objects(), proj_dir_to_build_root)
return list(dict.fromkeys(obj_list))
+ def determine_ext_objs(self, objects: build.ExtractedObjects, proj_dir_to_build_root: str = '') -> T.List[str]:
+ obj_list = self._flatten_object_list(objects.target, [objects], proj_dir_to_build_root)
+ return list(dict.fromkeys(obj_list))
+
def _flatten_object_list(self, target: build.BuildTarget,
objects: T.Sequence[T.Union[str, 'File', build.ExtractedObjects]],
proj_dir_to_build_root: str) -> T.List[str]:
@@ -477,7 +481,7 @@ class Backend:
elif isinstance(obj, build.ExtractedObjects):
if obj.recursive:
obj_list += self._flatten_object_list(obj.target, obj.objlist, proj_dir_to_build_root)
- obj_list += self.determine_ext_objs(obj, proj_dir_to_build_root)
+ obj_list += self._determine_ext_objs(obj, proj_dir_to_build_root)
else:
raise MesonException('Unknown data type in object list.')
return obj_list
@@ -808,7 +812,7 @@ class Backend:
machine = self.environment.machines[target.for_machine]
return self.canonicalize_filename(gen_source) + '.' + machine.get_object_suffix()
- def determine_ext_objs(self, extobj: 'build.ExtractedObjects', proj_dir_to_build_root: str) -> T.List[str]:
+ def _determine_ext_objs(self, extobj: 'build.ExtractedObjects', proj_dir_to_build_root: str) -> T.List[str]:
result: T.List[str] = []
# Merge sources and generated sources
@@ -1297,8 +1301,7 @@ class Backend:
elif isinstance(i, build.GeneratedList):
fname = [os.path.join(self.get_target_private_dir(target), p) for p in i.get_outputs()]
elif isinstance(i, build.ExtractedObjects):
- outputs = i.get_outputs(self)
- fname = self.get_extracted_obj_paths(i.target, outputs)
+ fname = self.determine_ext_objs(i)
elif isinstance(i, programs.ExternalProgram):
assert i.found(), "This shouldn't be possible"
assert i.path is not None, 'for mypy'
@@ -1310,9 +1313,6 @@ class Backend:
srcs += fname
return srcs
- def get_extracted_obj_paths(self, target: build.BuildTarget, outputs: T.List[str]) -> T.List[str]:
- return [os.path.join(self.get_target_private_dir(target), p) for p in outputs]
-
def get_custom_target_depend_files(self, target: build.CustomTarget, absolute_paths: bool = False) -> T.List[str]:
deps: T.List[str] = []
for i in target.depend_files:
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index 326c4b6..0d8bafb 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -259,9 +259,6 @@ class XCodeBackend(backends.Backend):
obj_path = f'{project}.build/{buildtype}/{tname}.build/Objects-normal/{arch}/{stem}.o'
return obj_path
- def get_extracted_obj_paths(self, target: build.BuildTarget, outputs: T.List[str]) -> T.List[str]:
- return outputs
-
def generate(self):
self.serialize_tests()
# Cache the result as the method rebuilds the array every time it is called.
@@ -1469,7 +1466,7 @@ class XCodeBackend(backends.Backend):
# Add extracted objects to the link line by hand.
if isinstance(o, build.ExtractedObjects):
added_objs = set()
- for objname_rel in o.get_outputs(self):
+ for objname_rel in self.determine_ext_objs(o):
objname_abs = os.path.join(self.environment.get_build_dir(), o.target.subdir, objname_rel)
if objname_abs not in added_objs:
added_objs.add(objname_abs)
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index d312abd..233d953 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -447,12 +447,6 @@ class ExtractedObjects(HoldableObject):
'in Unity builds. You can only extract all '
'the object files for each compiler at once.')
- def get_outputs(self, backend: 'Backend') -> T.List[str]:
- return [
- backend.object_filename_from_source(self.target, source)
- for source in self.get_sources(self.srclist, self.genlist)
- ]
-
@dataclass(eq=False, order=False)
class StructuredSources(HoldableObject):
@@ -2878,7 +2872,7 @@ def get_sources_string_names(sources, backend):
elif isinstance(s, (BuildTarget, CustomTarget, CustomTargetIndex, GeneratedList)):
names += s.get_outputs()
elif isinstance(s, ExtractedObjects):
- names += s.get_outputs(backend)
+ names += backend.determine_ext_objs(s)
elif isinstance(s, File):
names.append(s.fname)
else: