diff options
author | Albert Tang <tangalbert919@yahoo.com> | 2023-08-19 10:55:14 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-01-26 00:42:24 -0500 |
commit | 6e381714c7cb15877e2bcaa304b93c212252ada3 (patch) | |
tree | 97daeeb67d94ac563b209c301378210f00c9610d | |
parent | 02ee16729614ba2aae5f5d921c2ebbc1f5d19b46 (diff) | |
download | meson-6e381714c7cb15877e2bcaa304b93c212252ada3.zip meson-6e381714c7cb15877e2bcaa304b93c212252ada3.tar.gz meson-6e381714c7cb15877e2bcaa304b93c212252ada3.tar.bz2 |
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
-rw-r--r-- | mesonbuild/backend/xcodebackend.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 3a70d25..abdac0c 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/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 |