xcode: Autodetect host machine's CPU architecture
Currently, the backend has "x86_64" hardcoded as the architecture, which breaks cross compiling and compiling normally on arm64. Fix this by setting it to the host machine's CPU architecture instead.
This commit is contained in:
parent
d7bf365acd
commit
d2740cf0d1
|
@ -195,6 +195,9 @@ class XCodeBackend(backends.Backend):
|
|||
self.regen_dependency_id = self.gen_id()
|
||||
self.top_level_dict = PbxDict()
|
||||
self.generator_outputs = {}
|
||||
self.arch = self.build.environment.machines.host.cpu
|
||||
if self.arch == 'aarch64':
|
||||
self.arch = 'arm64'
|
||||
# In Xcode files are not accessed via their file names, but rather every one of them
|
||||
# gets an unique id. More precisely they get one unique id per target they are used
|
||||
# in. If you generate only one id per file and use them, compilation will work but the
|
||||
|
@ -233,11 +236,10 @@ class XCodeBackend(backends.Backend):
|
|||
project = self.build.project_name
|
||||
buildtype = self.buildtype
|
||||
tname = target.get_id()
|
||||
arch = 'x86_64'
|
||||
if isinstance(source, mesonlib.File):
|
||||
source = source.fname
|
||||
stem = os.path.splitext(os.path.basename(source))[0]
|
||||
obj_path = f'{project}.build/{buildtype}/{tname}.build/Objects-normal/{arch}/{stem}.o'
|
||||
obj_path = f'{project}.build/{buildtype}/{tname}.build/Objects-normal/{self.arch}/{stem}.o'
|
||||
return obj_path
|
||||
|
||||
def determine_swift_dep_dirs(self, target: build.BuildTarget) -> T.List[str]:
|
||||
|
@ -1391,7 +1393,7 @@ class XCodeBackend(backends.Backend):
|
|||
bt_dict.add_item('isa', 'XCBuildConfiguration')
|
||||
settings_dict = PbxDict()
|
||||
bt_dict.add_item('buildSettings', settings_dict)
|
||||
settings_dict.add_item('ARCHS', '"$(NATIVE_ARCH_ACTUAL)"')
|
||||
settings_dict.add_item('ARCHS', f'"{self.arch}"')
|
||||
settings_dict.add_item('ONLY_ACTIVE_ARCH', 'YES')
|
||||
settings_dict.add_item('SWIFT_VERSION', '5.0')
|
||||
settings_dict.add_item('SDKROOT', '"macosx"')
|
||||
|
@ -1435,7 +1437,7 @@ class XCodeBackend(backends.Backend):
|
|||
bt_dict.add_item('isa', 'XCBuildConfiguration')
|
||||
settings_dict = PbxDict()
|
||||
bt_dict.add_item('buildSettings', settings_dict)
|
||||
settings_dict.add_item('ARCHS', '"$(NATIVE_ARCH_ACTUAL)"')
|
||||
settings_dict.add_item('ARCHS', f'"{self.arch}"')
|
||||
settings_dict.add_item('ONLY_ACTIVE_ARCH', 'YES')
|
||||
settings_dict.add_item('SDKROOT', '"macosx"')
|
||||
settings_dict.add_item('SYMROOT', '"%s/build"' % self.environment.get_build_dir())
|
||||
|
|
Loading…
Reference in New Issue