Feature: Add four new SettingsTransformers (#4427)
This commit is contained in:
parent
8e2536a2af
commit
1c5b2773a3
|
@ -97,18 +97,27 @@ extension SettingsDictionary {
|
|||
return merging(versionSettings)
|
||||
}
|
||||
|
||||
// MARK: - Swift Settings
|
||||
// MARK: - Swift Compiler - Language
|
||||
|
||||
/// Sets `"SWIFT_VERSION"` to `version`
|
||||
public func swiftVersion(_ version: String) -> SettingsDictionary {
|
||||
merging(["SWIFT_VERSION": SettingValue(version)])
|
||||
}
|
||||
|
||||
// MARK: - Swift Compiler - Custom Flags
|
||||
|
||||
/// Sets `"OTHER_SWIFT_FLAGS"` to `flags`
|
||||
public func otherSwiftFlags(_ flags: String...) -> SettingsDictionary {
|
||||
merging(["OTHER_SWIFT_FLAGS": SettingValue(flags.joined(separator: " "))])
|
||||
}
|
||||
|
||||
/// Sets `"SWIFT_ACTIVE_COMPILATION_CONDITIONS"` to `conditions`
|
||||
public func swiftActiveCompilationConditions(_ conditions: String...) -> SettingsDictionary {
|
||||
merging(["SWIFT_ACTIVE_COMPILATION_CONDITIONS": SettingValue(conditions.joined(separator: " "))])
|
||||
}
|
||||
|
||||
// MARK: - Swift Compiler - Code Generation
|
||||
|
||||
/// Sets `"SWIFT_COMPILATION_MODE"` to the available `SwiftCompilationMode` (`"singlefile"` or `"wholemodule"`)
|
||||
public func swiftCompilationMode(_ mode: SwiftCompilationMode) -> SettingsDictionary {
|
||||
merging(["SWIFT_COMPILATION_MODE": SettingValue(mode)])
|
||||
|
@ -124,6 +133,29 @@ extension SettingsDictionary {
|
|||
merging(["SWIFT_OPTIMIZE_OBJECT_LIFETIME": SettingValue(enabled)])
|
||||
}
|
||||
|
||||
// MARK: - Swift Compiler - General
|
||||
|
||||
/// Sets `"SWIFT_OBJC_BRIDGING_HEADER"` to `path`
|
||||
public func swiftObjcBridingHeaderPath(_ path: String) -> SettingsDictionary {
|
||||
var settings = self
|
||||
settings["SWIFT_OBJC_BRIDGING_HEADER"] = SettingValue(path)
|
||||
return settings
|
||||
}
|
||||
|
||||
// MARK: - Apple Clang - Custom Compiler Flags
|
||||
|
||||
/// Sets `"OTHER_CFLAGS"` to `flags`
|
||||
public func otherCFlags(_ flags: [String]) -> SettingsDictionary {
|
||||
merging(["OTHER_CFLAGS": .array(flags)])
|
||||
}
|
||||
|
||||
// MARK: - Linking
|
||||
|
||||
/// Sets `"OTHER_LDFLAGS"` to `flags`
|
||||
public func otherLinkerFlags(_ flags: [String]) -> SettingsDictionary {
|
||||
merging(["OTHER_LDFLAGS": .array(flags)])
|
||||
}
|
||||
|
||||
// MARK: - Bitcode
|
||||
|
||||
/// Sets `"ENABLE_BITCODE"` to `"YES"` or `"NO"`
|
||||
|
|
|
@ -98,6 +98,10 @@ final class SettingsTests: XCTestCase {
|
|||
.otherSwiftFlags("first", "second", "third")
|
||||
.bitcodeEnabled(true)
|
||||
.debugInformationFormat(.dwarf)
|
||||
.swiftActiveCompilationConditions("FIRST", "SECOND", "THIRD")
|
||||
.swiftObjcBridingHeaderPath("/my/briding/header/path.h")
|
||||
.otherCFlags(["$(inherited)", "-my-c-flag"])
|
||||
.otherLinkerFlags(["$(inherited)", "-my-linker-flag"])
|
||||
|
||||
/// Then
|
||||
XCTAssertEqual(settings, [
|
||||
|
@ -114,6 +118,10 @@ final class SettingsTests: XCTestCase {
|
|||
"OTHER_SWIFT_FLAGS": "first second third",
|
||||
"ENABLE_BITCODE": "YES",
|
||||
"DEBUG_INFORMATION_FORMAT": "dwarf",
|
||||
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "FIRST SECOND THIRD",
|
||||
"SWIFT_OBJC_BRIDGING_HEADER": "/my/briding/header/path.h",
|
||||
"OTHER_CFLAGS": ["$(inherited)", "-my-c-flag"],
|
||||
"OTHER_LDFLAGS": ["$(inherited)", "-my-linker-flag"],
|
||||
])
|
||||
}
|
||||
|
||||
|
@ -130,6 +138,17 @@ final class SettingsTests: XCTestCase {
|
|||
])
|
||||
}
|
||||
|
||||
func test_settingsDictionary_swiftActiveCompilationConditions() {
|
||||
/// Given/When
|
||||
let settings = SettingsDictionary()
|
||||
.swiftActiveCompilationConditions("FIRST", "SECOND", "THIRD")
|
||||
|
||||
/// Then
|
||||
XCTAssertEqual(settings, [
|
||||
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "FIRST SECOND THIRD",
|
||||
])
|
||||
}
|
||||
|
||||
func test_settingsDictionary_SwiftCompilationMode() {
|
||||
/// Given/When
|
||||
let settings1 = SettingsDictionary()
|
||||
|
@ -179,6 +198,39 @@ final class SettingsTests: XCTestCase {
|
|||
])
|
||||
}
|
||||
|
||||
func test_settingsDictionary_swiftObjcBridingHeaderPath() {
|
||||
/// Given/When
|
||||
let settings = SettingsDictionary()
|
||||
.swiftObjcBridingHeaderPath("/my/briding/header/path.h")
|
||||
|
||||
/// Then
|
||||
XCTAssertEqual(settings, [
|
||||
"SWIFT_OBJC_BRIDGING_HEADER": "/my/briding/header/path.h",
|
||||
])
|
||||
}
|
||||
|
||||
func test_settingsDictionary_otherCFlags() {
|
||||
/// Given/When
|
||||
let settings = SettingsDictionary()
|
||||
.otherCFlags(["$(inherited)", "-my-c-flag"])
|
||||
|
||||
/// Then
|
||||
XCTAssertEqual(settings, [
|
||||
"OTHER_CFLAGS": ["$(inherited)", "-my-c-flag"],
|
||||
])
|
||||
}
|
||||
|
||||
func test_settingsDictionary_otherLinkerFlags() {
|
||||
/// Given/When
|
||||
let settings = SettingsDictionary()
|
||||
.otherLinkerFlags(["$(inherited)", "-my-linker-flag"])
|
||||
|
||||
/// Then
|
||||
XCTAssertEqual(settings, [
|
||||
"OTHER_LDFLAGS": ["$(inherited)", "-my-linker-flag"],
|
||||
])
|
||||
}
|
||||
|
||||
func test_settingsDictionary_SwiftOptimizeObjectLifetimes() {
|
||||
/// Given/When
|
||||
let settings1 = SettingsDictionary()
|
||||
|
|
Loading…
Reference in New Issue