Skip to content

Commit

Permalink
Add ability to override 'objc_defines' via --user-options (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeykhliustin authored Mar 8, 2024
1 parent 7b7b570 commit 299f652
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ OPTIONS:
If 'user_options' not specified, but --user_options exist, user_options patch are applied automatically.
--user-options <user-options>
User extra options.
Supported fields: 'sdk_frameworks', 'sdk_dylibs', 'weak_sdk_frameworks', 'vendored_libraries', 'vendored_frameworks', 'vendored_xcframeworks', 'testonly', 'link_dynamic', 'data', 'runner', 'test_host', 'timeout'.
Supported fields: 'sdk_frameworks', 'sdk_dylibs', 'weak_sdk_frameworks', 'vendored_libraries', 'vendored_frameworks', 'vendored_xcframeworks', 'testonly', 'link_dynamic', 'data', 'objc_defines', 'runner', 'test_host', 'timeout'.
Supported operators: '+=' (append), '-=' (delete), ':=' (replace).
Example:
'SomePod.sdk_dylibs += something,something'
Expand Down Expand Up @@ -139,7 +139,7 @@ OPTIONS:
If 'user_options' not specified, but --user_options exist, user_options patch are applied automatically.
--user-options <user-options>
User extra options.
Supported fields: 'sdk_frameworks', 'sdk_dylibs', 'weak_sdk_frameworks', 'vendored_libraries', 'vendored_frameworks', 'vendored_xcframeworks', 'testonly', 'link_dynamic', 'data', 'runner', 'test_host', 'timeout'.
Supported fields: 'sdk_frameworks', 'sdk_dylibs', 'weak_sdk_frameworks', 'vendored_libraries', 'vendored_frameworks', 'vendored_xcframeworks', 'testonly', 'link_dynamic', 'data', 'objc_defines', 'runner', 'test_host', 'timeout'.
Supported operators: '+=' (append), '-=' (delete), ':=' (replace).
Example:
'SomePod.sdk_dylibs += something,something'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import Foundation

struct BuildSettingsAnalyzer<S: XCConfigRepresentable> {
struct Result {
let swiftCopts: [String]
let objcCopts: [String]
let ccCopts: [String]
let linkOpts: [String]
let objcDefines: [String]
let xcconfig: [String: StarlarkNode]
var swiftCopts: [String]
var objcCopts: [String]
var ccCopts: [String]
var linkOpts: [String]
var objcDefines: [String]
var xcconfig: [String: StarlarkNode]
}
private let platform: Platform
private let spec: S
Expand Down
4 changes: 4 additions & 0 deletions Sources/BazelPodsCore/Core/UserOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public struct UserOption {
case testonly(Bool)
case link_dynamic(Bool)
case data([String])
case objc_defines([String])
case runner(String)
case test_host(String)
case timeout(TestsTimeout)
Expand All @@ -68,6 +69,7 @@ public struct UserOption {
case testonly
case link_dynamic
case data
case objc_defines
case runner
case test_host
case timeout
Expand Down Expand Up @@ -175,6 +177,8 @@ public struct UserOption {
attribute = .link_dynamic(bool)
case .data:
attribute = .data(value)
case .objc_defines:
attribute = .objc_defines(value)
case .runner:
guard opt == .replace else {
log_error("Incorrect option for \(string). '\(keyPath)' supports only \(Opt.replace.rawValue) operator. Skipping...")
Expand Down
9 changes: 9 additions & 0 deletions Sources/BazelPodsCore/Patches/UserOptionsPatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ struct UserOptionsPatch: Patch, TestSpecSpecificPatch {
case .replace:
resources.resources = value
}
case .objc_defines(let value):
switch option.opt {
case .append:
buildSettings.objcDefines += value.filter({ !buildSettings.objcDefines.contains($0) })
case .delete:
buildSettings.objcDefines.removeAll(where: { value.contains($0) })
case .replace:
buildSettings.objcDefines = value
}
case .runner:
// test spec specific option
break
Expand Down

0 comments on commit 299f652

Please sign in to comment.