Add support for runOncePerArchitecture (#950)

Add changelog and small change

Fix build error
This commit is contained in:
Sascha Schwabbauer 2021-01-12 23:51:11 +01:00 committed by GitHub
parent 7e536e5a3a
commit 2277b323f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 4 deletions

View File

@ -7,6 +7,7 @@
- Add `useBaseInternationalization` to Project Spec Options to opt out of Base Internationalization. [#961](https://github.com/yonaskolb/XcodeGen/pull/961) @liamnichols
- More detailed error message with method arguments. [#990](https://github.com/yonaskolb/XcodeGen/pull/990) @bannzai
- Added `basedOnDependencyAnalysis` to Project Spec Build Script to be able to choose not to skip the script. [#992](https://github.com/yonaskolb/XcodeGen/pull/992) @myihsan
- Add `BuildRule.runOncePerArchitecture` to allow running build rules once per architecture. [#950](https://github.com/yonaskolb/XcodeGen/pull/950) @sascha
#### Changed
- **Breaking**: Info.plists with custom prefixes are no longer added to the Copy Bundle Resources build phase [#945](https://github.com/yonaskolb/XcodeGen/pull/945) @anivaros

View File

@ -605,6 +605,7 @@ targets:
- [ ] **name**: **String** - The name of a build rule. Defaults to `Build Rule`
- [ ] **outputFiles**: **[String]** - The list of output files
- [ ] **outputFilesCompilerFlags**: **[String]** - The list of compiler flags to apply to the output files
- [ ] **runOncePerArchitecture**: **Bool** - a boolean that indicates if this rule should run once per architecture. This defaults to true
```yaml
targets:
@ -619,6 +620,7 @@ targets:
compilerSpec: com.apple.xcode.tools.swift.compiler
outputFiles:
- $(SRCROOT)/Generated.swift
runOncePerArchitecture: false
```
### Target Scheme

View File

@ -5,6 +5,7 @@ public struct BuildRule: Equatable {
public static let scriptCompilerSpec = "com.apple.compilers.proxy.script"
public static let filePatternFileType = "pattern.proxy"
public static let runOncePerArchitectureDefault = true
public enum FileType: Equatable {
case type(String)
@ -49,13 +50,22 @@ public struct BuildRule: Equatable {
public var outputFiles: [String]
public var outputFilesCompilerFlags: [String]
public var name: String?
public var runOncePerArchitecture: Bool
public init(fileType: FileType, action: Action, name: String? = nil, outputFiles: [String] = [], outputFilesCompilerFlags: [String] = []) {
public init(
fileType: FileType,
action: Action,
name: String? = nil,
outputFiles: [String] = [],
outputFilesCompilerFlags: [String] = [],
runOncePerArchitecture: Bool = runOncePerArchitectureDefault
) {
self.fileType = fileType
self.action = action
self.name = name
self.outputFiles = outputFiles
self.outputFilesCompilerFlags = outputFilesCompilerFlags
self.runOncePerArchitecture = runOncePerArchitecture
}
}
@ -78,6 +88,7 @@ extension BuildRule: JSONObjectConvertible {
outputFiles = jsonDictionary.json(atKeyPath: "outputFiles") ?? []
outputFilesCompilerFlags = jsonDictionary.json(atKeyPath: "outputFilesCompilerFlags") ?? []
name = jsonDictionary.json(atKeyPath: "name")
runOncePerArchitecture = jsonDictionary.json(atKeyPath: "runOncePerArchitecture") ?? BuildRule.runOncePerArchitectureDefault
}
}
@ -103,6 +114,10 @@ extension BuildRule: JSONEncodable {
dict["script"] = string
}
if runOncePerArchitecture != BuildRule.runOncePerArchitectureDefault {
dict["runOncePerArchitecture"] = runOncePerArchitecture
}
return dict
}
}

View File

@ -1150,7 +1150,8 @@ public class PBXProjGenerator {
name: buildRule.name ?? "Build Rule",
outputFiles: buildRule.outputFiles,
outputFilesCompilerFlags: buildRule.outputFilesCompilerFlags,
script: buildRule.action.script
script: buildRule.action.script,
runOncePerArchitecture: buildRule.runOncePerArchitecture
)
)
}

View File

@ -414,12 +414,14 @@ class ProjectSpecTests: XCTestCase {
action: .script("pre_process_swift.py"),
name: "My Build Rule",
outputFiles: ["$(SRCROOT)/Generated.swift"],
outputFilesCompilerFlags: ["foo"]),
outputFilesCompilerFlags: ["foo"],
runOncePerArchitecture: false),
BuildRule(fileType: .type("sourcecode.swift"),
action: .compilerSpec("com.apple.xcode.tools.swift.compiler"),
name: nil,
outputFiles: ["bar"],
outputFilesCompilerFlags: ["foo"])],
outputFilesCompilerFlags: ["foo"],
runOncePerArchitecture: true)],
scheme: TargetScheme(testTargets: [Scheme.Test.TestTarget(targetReference: "test target",
randomExecutionOrder: false,
parallelizable: false)],