xcode: Fix "clean" operation under new build system

Xcode 14 has dropped the legacy build system, forcing us to use the
new one introduced in Xcode 9. The new system requires that we conform
to its "clean build folder" behavior, or clean operations fail.

CMake achieves this by setting other variables instead of SYMROOT, so
we follow that approach while retaining our current behavior as much
as possible.

Ref: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7730
pull/12784/head
Albert Tang 1 year ago committed by Eli Schwartz
parent 02ee167296
commit 6e381714c7
  1. 13
      mesonbuild/backend/xcodebackend.py

@ -239,7 +239,8 @@ class XCodeBackend(backends.Backend):
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/{self.arch}/{stem}.o'
# Append "build" before the actual object path to match OBJROOT
obj_path = f'build/{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]:
@ -1397,10 +1398,12 @@ class XCodeBackend(backends.Backend):
settings_dict = PbxDict()
bt_dict.add_item('buildSettings', settings_dict)
settings_dict.add_item('ARCHS', f'"{self.arch}"')
settings_dict.add_item('BUILD_DIR', f'"{self.environment.get_build_dir()}"')
settings_dict.add_item('BUILD_ROOT', '"$(BUILD_DIR)"')
settings_dict.add_item('ONLY_ACTIVE_ARCH', 'YES')
settings_dict.add_item('SWIFT_VERSION', '5.0')
settings_dict.add_item('SDKROOT', '"macosx"')
settings_dict.add_item('SYMROOT', '"%s/build"' % self.environment.get_build_dir())
settings_dict.add_item('OBJROOT', '"$(BUILD_DIR)/build"')
bt_dict.add_item('name', f'"{buildtype}"')
# Then the all target.
@ -1410,7 +1413,6 @@ class XCodeBackend(backends.Backend):
bt_dict.add_item('isa', 'XCBuildConfiguration')
settings_dict = PbxDict()
bt_dict.add_item('buildSettings', settings_dict)
settings_dict.add_item('SYMROOT', '"%s"' % self.environment.get_build_dir())
warn_array = PbxArray()
warn_array.add_item('"$(inherited)"')
settings_dict.add_item('WARNING_CFLAGS', warn_array)
@ -1424,7 +1426,6 @@ class XCodeBackend(backends.Backend):
bt_dict.add_item('isa', 'XCBuildConfiguration')
settings_dict = PbxDict()
bt_dict.add_item('buildSettings', settings_dict)
settings_dict.add_item('SYMROOT', '"%s"' % self.environment.get_build_dir())
warn_array = PbxArray()
settings_dict.add_item('WARNING_CFLAGS', warn_array)
warn_array.add_item('"$(inherited)"')
@ -1443,7 +1444,6 @@ class XCodeBackend(backends.Backend):
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())
bt_dict.add_item('name', f'"{buildtype}"')
def determine_internal_dep_link_args(self, target, buildtype):
@ -1671,7 +1671,8 @@ class XCodeBackend(backends.Backend):
settings_dict.add_item('SECTORDER_FLAGS', '""')
if is_swift and bridging_header:
settings_dict.add_item('SWIFT_OBJC_BRIDGING_HEADER', f'"{bridging_header}"')
settings_dict.add_item('SYMROOT', f'"{symroot}"')
settings_dict.add_item('BUILD_DIR', f'"{symroot}"')
settings_dict.add_item('OBJROOT', f'"{symroot}/build"')
sysheader_arr = PbxArray()
# XCode will change every -I flag that points inside these directories
# to an -isystem. Thus set nothing in it since we control our own

Loading…
Cancel
Save