summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-04-19 20:04:00 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2021-04-20 17:23:50 +0300
commitd116d94f92d68583e139c18a53d18ccbb397bfae (patch)
tree403b4f5950111628403c6cacb4bf257a742441b4
parent07117c422597e8414c1b653a3cace4e6839d8693 (diff)
downloadmeson-d116d94f92d68583e139c18a53d18ccbb397bfae.tar.gz
Xcode: fix file objects in various places.
-rw-r--r--mesonbuild/backend/xcodebackend.py44
-rw-r--r--test cases/common/122 object only target/meson.build4
2 files changed, 35 insertions, 13 deletions
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index 1dd1f21a1..2a72b1993 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -487,13 +487,17 @@ class XCodeBackend(backends.Backend):
if isinstance(o, build.ExtractedObjects):
# Extracted objects do not live in "the Xcode world".
continue
- else:
+ if isinstance(o, mesonlib.File):
+ o = os.path.join(o.subdir, o.fname)
+ if isinstance(o, str):
o = os.path.join(t.subdir, o)
k = (tname, o)
- assert(k not in sel.buildfile_ids)
+ assert(k not in self.buildfile_ids)
self.buildfile_ids[k] = self.gen_id()
assert(k not in self.fileref_ids)
self.fileref_ids[k] = self.gen_id()
+ else:
+ raise RuntimeError('Unknown input type ' + str(o))
def generate_source_phase_map(self):
self.source_phase = {}
@@ -597,12 +601,15 @@ class XCodeBackend(backends.Backend):
# by hand in linker flags. It is also not particularly
# clear how to define build files in Xcode's file format.
continue
- o = os.path.join(t.subdir, o)
+ if isinstance(o, mesonlib.File):
+ o = os.path.join(o.subdir, o.fname)
+ elif isinstance(o, str):
+ o = os.path.join(t.subdir, o)
idval = self.buildfile_ids[(tname, o)]
- k = (tname, s)
+ k = (tname, o)
fileref = self.fileref_ids[k]
- assert(k not in self.targetfile_ids)
- self.targetfile_ids[k] = idval
+ assert(o not in self.filemap)
+ self.filemap[o] = idval
fullpath = os.path.join(self.environment.get_source_dir(), o)
fullpath2 = fullpath
o_dict = PbxDict()
@@ -736,15 +743,23 @@ class XCodeBackend(backends.Backend):
if isinstance(o, build.ExtractedObjects):
# Same as with pbxbuildfile.
continue
- o = os.path.join(t.subdir, o)
+ if isinstance(o, mesonlib.File):
+ fullpath = o.absolute_path(self.environment.get_source_dir(), self.environment.get_build_dir())
+ o = os.path.join(o.subdir, o.fname)
+ else:
+ o = os.path.join(t.subdir, o)
+ fullpath = os.path.join(self.environment.get_source_dir(), o)
idval = self.fileref_ids[(tname, o)]
- fileref = self.filemap[o]
- fullpath = os.path.join(self.environment.get_source_dir(), o)
- fullpath2 = fullpath
+ rel_name = mesonlib.relpath(fullpath, self.environment.get_source_dir())
o_dict = PbxDict()
+ name = os.path.basename(o)
objects_dict.add_item(idval, o_dict, fullpath)
- o_dict.add_item('isa', 'PBXBuildFile')
- o_dict.add_item('fileRef', fileref, fullpath2)
+ o_dict.add_item('isa', 'PBXFileReference')
+ o_dict.add_item('explicitFileType', '"' + self.get_xcodetype(o) + '"')
+ o_dict.add_item('fileEncoding', '4')
+ o_dict.add_item('name', f'"{name}"')
+ o_dict.add_item('path', f'"{rel_name}"')
+ o_dict.add_item('sourceTree', 'SOURCE_ROOT')
for tname, idval in self.target_filemap.items():
target_dict = PbxDict()
objects_dict.add_item(idval, target_dict, tname)
@@ -902,7 +917,10 @@ class XCodeBackend(backends.Backend):
if isinstance(o, build.ExtractedObjects):
# Do not show built object files in the project tree.
continue
- o = os.path.join(t.subdir, o)
+ if isinstance(o, mesonlib.File):
+ o = os.path.join(o.subdir, o.fname)
+ else:
+ o = os.path.join(t.subdir, o)
source_file_children.add_item(self.fileref_ids[(tname, o)], o)
source_files_dict.add_item('name', '"Source files"')
source_files_dict.add_item('sourceTree', '"<group>"')
diff --git a/test cases/common/122 object only target/meson.build b/test cases/common/122 object only target/meson.build
index d83a65825..e2ce43e6c 100644
--- a/test cases/common/122 object only target/meson.build
+++ b/test cases/common/122 object only target/meson.build
@@ -1,5 +1,9 @@
project('object generator', 'c')
+if meson.backend() == 'xcode'
+ error('MESON_SKIP_TEST object-only libraries not supported in Xcode. Patches welcome.')
+endif
+
# FIXME: Note that this will not add a dependency to the compiler executable.
# Code will not be rebuilt if it changes.
comp = find_program('obj_generator.py')