forked from Carthage/Carthage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildArguments.swift
109 lines (85 loc) · 3.13 KB
/
BuildArguments.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/// Configures a build with Xcode.
public struct BuildArguments {
/// The project to build.
public let project: ProjectLocator
/// The scheme to build in the project.
public var scheme: String?
/// The configuration to use when building the project.
public var configuration: String?
/// The path to the derived data.
public var derivedDataPath: String?
/// The platform SDK to build for.
public var sdk: SDK?
/// The run destination to try building for.
public var destination: String?
/// The amount of time xcodebuild spends searching for the destination (in seconds).
public var destinationTimeout: UInt?
/// The build setting whether the product includes only object code for
/// the native architecture.
public var onlyActiveArchitecture: Bool? = nil
/// The build setting whether full bitcode should be embedded in the binary.
public var bitcodeGenerationMode: BitcodeGenerationMode? = nil
public init(project: ProjectLocator, scheme: String? = nil, configuration: String? = nil, derivedDataPath: String? = nil, sdk: SDK? = nil) {
self.project = project
self.scheme = scheme
self.configuration = configuration
self.derivedDataPath = derivedDataPath
self.sdk = sdk
}
/// The `xcodebuild` invocation corresponding to the receiver.
public var arguments: [String] {
var args = [ "xcodebuild" ]
switch project {
case let .Workspace(URL):
args += [ "-workspace", URL.path! ]
case let .ProjectFile(URL):
args += [ "-project", URL.path! ]
}
if let scheme = scheme {
args += [ "-scheme", scheme ]
}
if let configuration = configuration {
args += [ "-configuration", configuration ]
}
if let derivedDataPath = derivedDataPath, let standarizedPath = NSURL(fileURLWithPath: (derivedDataPath as NSString).stringByExpandingTildeInPath).URLByStandardizingPath?.path where !derivedDataPath.isEmpty && !standarizedPath.isEmpty {
args += [ "-derivedDataPath", standarizedPath ]
}
if let sdk = sdk {
// Passing in -sdk macosx appears to break implicit dependency
// resolution (see Carthage/Carthage#347).
//
// Since we wouldn't be trying to build this target unless it were
// for OS X already, just let xcodebuild figure out the SDK on its
// own.
if sdk != .MacOSX {
args += [ "-sdk", sdk.rawValue ]
}
}
if let destination = destination {
args += [ "-destination", destination ]
}
if let destinationTimeout = destinationTimeout {
args += [ "-destination-timeout", String(destinationTimeout) ]
}
if let onlyActiveArchitecture = onlyActiveArchitecture {
if onlyActiveArchitecture {
args += [ "ONLY_ACTIVE_ARCH=YES" ]
} else {
args += [ "ONLY_ACTIVE_ARCH=NO" ]
}
}
if let bitcodeGenerationMode = bitcodeGenerationMode {
args += [ "BITCODE_GENERATION_MODE=\(bitcodeGenerationMode.rawValue)" ]
}
// Disable code signing requirement for all builds
// Frameworks get signed in the copy-frameworks action
args += [ "CODE_SIGNING_REQUIRED=NO", "CODE_SIGN_IDENTITY=" ]
args += [ "CARTHAGE=YES" ]
return args
}
}
extension BuildArguments: CustomStringConvertible {
public var description: String {
return arguments.joinWithSeparator(" ")
}
}