Skip to content

Commit dfb4039

Browse files
authored
Merge pull request #198 from polac24/bartosz/20230413-override-exclusions
Set libtool Build Setting for excluded sdks
2 parents f432917 + b28613a commit dfb4039

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

Sources/XCRemoteCache/Commands/Prepare/Integrate/BuildSettingsIntegrateAppender.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ class XcodeProjBuildSettingsIntegrateAppender: BuildSettingsIntegrateAppender {
5151
if case .consumer = mode {
5252
setBuildSetting(buildSettings: &result, key: "CC", value: wrappers.cc.path )
5353
setBuildSetting(buildSettings: &result, key: "LD", value: wrappers.ld.path )
54-
setBuildSetting(buildSettings: &result, key: "LIBTOOL", value: wrappers.libtool.path )
54+
// Setting LIBTOOL to '' breaks SwiftDriver intengration so resetting it to the original value
55+
// 'libtool' for all excluded configurations
56+
setBuildSetting(
57+
buildSettings: &result,
58+
key: "LIBTOOL",
59+
value: wrappers.libtool.path,
60+
excludedValue: "libtool"
61+
)
5562
setBuildSetting(buildSettings: &result, key: "LIPO", value: wrappers.lipo.path )
5663
setBuildSetting(buildSettings: &result, key: "LDPLUSPLUS", value: wrappers.ldplusplus.path )
5764
}
@@ -79,15 +86,15 @@ class XcodeProjBuildSettingsIntegrateAppender: BuildSettingsIntegrateAppender {
7986
return result
8087
}
8188

82-
private func setBuildSetting(buildSettings: inout BuildSettings, key: String, value: String?) {
89+
private func setBuildSetting(buildSettings: inout BuildSettings, key: String, value: String?, excludedValue: String = "") {
8390
buildSettings[key] = value
8491
guard value != nil else {
8592
// no need to exclude as the value will
8693
return
8794
}
8895
// Erase all overrides for a given sdk so a default toolchain is used
8996
for skippedSDK in sdksExclude {
90-
buildSettings["\(key)[sdk=\(skippedSDK)]"] = ""
97+
buildSettings["\(key)[sdk=\(skippedSDK)]"] = excludedValue
9198
}
9299
}
93100

Tests/XCRemoteCacheTests/Commands/Prepare/Integrate/XcodeProjBuildSettingsIntegrateAppenderTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ class XcodeProjBuildSettingsIntegrateAppenderTests: XCTestCase {
101101
XCTAssertEqual(ldPlusPlusWatchOS, "")
102102
}
103103

104+
func testLibtoolIsSetForExcludedSdks() throws {
105+
let mode: Mode = .consumer
106+
let appender = XcodeProjBuildSettingsIntegrateAppender(
107+
mode: mode,
108+
repoRoot: rootURL,
109+
fakeSrcRoot: "/",
110+
sdksExclude: ["watchOS*"]
111+
)
112+
let result = appender.appendToBuildSettings(buildSettings: buildSettings, wrappers: binaries)
113+
let libtoolWatchOS: String = try XCTUnwrap(result["LIBTOOL[sdk=watchOS*]"] as? String)
114+
115+
XCTAssertEqual(libtoolWatchOS, "libtool")
116+
}
117+
104118
func testMultiplesdksExcludeAreAppended() throws {
105119
let mode: Mode = .consumer
106120
let appender = XcodeProjBuildSettingsIntegrateAppender(

cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def self.enable_xcremotecache(
139139
end
140140
reset_build_setting(config.build_settings, 'SWIFT_EXEC', "$SRCROOT/#{srcroot_relative_xc_location}/xcswiftc", exclude_sdks_configurations)
141141
reset_build_setting(config.build_settings, 'LIBTOOL', "$SRCROOT/#{srcroot_relative_xc_location}/xclibtool", exclude_sdks_configurations)
142+
# Setting LIBTOOL to '' breaks SwiftDriver intengration so resetting it to the original value 'libtool' for all excluded configurations
143+
add_build_setting_for_sdks(config.build_settings, 'LIBTOOL', 'libtool', exclude_sdks_configurations)
142144
reset_build_setting(config.build_settings, 'LD', "$SRCROOT/#{srcroot_relative_xc_location}/xcld", exclude_sdks_configurations)
143145
reset_build_setting(config.build_settings, 'LDPLUSPLUS', "$SRCROOT/#{srcroot_relative_xc_location}/xcldplusplus", exclude_sdks_configurations)
144146
reset_build_setting(config.build_settings, 'LIPO', "$SRCROOT/#{srcroot_relative_xc_location}/xclipo", exclude_sdks_configurations)

0 commit comments

Comments
 (0)