Skip to content

Commit

Permalink
Merge pull request #198 from polac24/bartosz/20230413-override-exclus…
Browse files Browse the repository at this point in the history
…ions

Set libtool Build Setting for excluded sdks
  • Loading branch information
polac24 authored Apr 15, 2023
2 parents f432917 + b28613a commit dfb4039
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ class XcodeProjBuildSettingsIntegrateAppender: BuildSettingsIntegrateAppender {
if case .consumer = mode {
setBuildSetting(buildSettings: &result, key: "CC", value: wrappers.cc.path )
setBuildSetting(buildSettings: &result, key: "LD", value: wrappers.ld.path )
setBuildSetting(buildSettings: &result, key: "LIBTOOL", value: wrappers.libtool.path )
// Setting LIBTOOL to '' breaks SwiftDriver intengration so resetting it to the original value
// 'libtool' for all excluded configurations
setBuildSetting(
buildSettings: &result,
key: "LIBTOOL",
value: wrappers.libtool.path,
excludedValue: "libtool"
)
setBuildSetting(buildSettings: &result, key: "LIPO", value: wrappers.lipo.path )
setBuildSetting(buildSettings: &result, key: "LDPLUSPLUS", value: wrappers.ldplusplus.path )
}
Expand Down Expand Up @@ -79,15 +86,15 @@ class XcodeProjBuildSettingsIntegrateAppender: BuildSettingsIntegrateAppender {
return result
}

private func setBuildSetting(buildSettings: inout BuildSettings, key: String, value: String?) {
private func setBuildSetting(buildSettings: inout BuildSettings, key: String, value: String?, excludedValue: String = "") {
buildSettings[key] = value
guard value != nil else {
// no need to exclude as the value will
return
}
// Erase all overrides for a given sdk so a default toolchain is used
for skippedSDK in sdksExclude {
buildSettings["\(key)[sdk=\(skippedSDK)]"] = ""
buildSettings["\(key)[sdk=\(skippedSDK)]"] = excludedValue
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ class XcodeProjBuildSettingsIntegrateAppenderTests: XCTestCase {
XCTAssertEqual(ldPlusPlusWatchOS, "")
}

func testLibtoolIsSetForExcludedSdks() throws {
let mode: Mode = .consumer
let appender = XcodeProjBuildSettingsIntegrateAppender(
mode: mode,
repoRoot: rootURL,
fakeSrcRoot: "/",
sdksExclude: ["watchOS*"]
)
let result = appender.appendToBuildSettings(buildSettings: buildSettings, wrappers: binaries)
let libtoolWatchOS: String = try XCTUnwrap(result["LIBTOOL[sdk=watchOS*]"] as? String)

XCTAssertEqual(libtoolWatchOS, "libtool")
}

func testMultiplesdksExcludeAreAppended() throws {
let mode: Mode = .consumer
let appender = XcodeProjBuildSettingsIntegrateAppender(
Expand Down
2 changes: 2 additions & 0 deletions cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def self.enable_xcremotecache(
end
reset_build_setting(config.build_settings, 'SWIFT_EXEC', "$SRCROOT/#{srcroot_relative_xc_location}/xcswiftc", exclude_sdks_configurations)
reset_build_setting(config.build_settings, 'LIBTOOL', "$SRCROOT/#{srcroot_relative_xc_location}/xclibtool", exclude_sdks_configurations)
# Setting LIBTOOL to '' breaks SwiftDriver intengration so resetting it to the original value 'libtool' for all excluded configurations
add_build_setting_for_sdks(config.build_settings, 'LIBTOOL', 'libtool', exclude_sdks_configurations)
reset_build_setting(config.build_settings, 'LD', "$SRCROOT/#{srcroot_relative_xc_location}/xcld", exclude_sdks_configurations)
reset_build_setting(config.build_settings, 'LDPLUSPLUS', "$SRCROOT/#{srcroot_relative_xc_location}/xcldplusplus", exclude_sdks_configurations)
reset_build_setting(config.build_settings, 'LIPO', "$SRCROOT/#{srcroot_relative_xc_location}/xclipo", exclude_sdks_configurations)
Expand Down

0 comments on commit dfb4039

Please sign in to comment.