@@ -36,17 +36,14 @@ import struct TSCBasic.OrderedSet
36
36
import enum TSCUtility. Diagnostics
37
37
import struct TSCUtility. Version
38
38
39
- await { ( ) async in
40
- await SwiftBootstrapBuildTool . main ( )
41
- } ( )
42
-
43
39
private struct EmptyWorkspaceLoader : WorkspaceLoader {
44
40
func load( workspace: AbsolutePath ) throws -> [ AbsolutePath ] {
45
41
[ ]
46
42
}
47
43
}
48
44
49
- struct SwiftBootstrapBuildTool : AsyncSwiftCommand {
45
+ @main
46
+ struct SwiftBootstrapCommand : AsyncSwiftCommand {
50
47
@OptionGroup ( visibility: . hidden)
51
48
var globalOptions : GlobalOptions
52
49
@@ -60,78 +57,10 @@ struct SwiftBootstrapBuildTool: AsyncSwiftCommand {
60
57
shouldDisplay: false
61
58
)
62
59
63
- @Option ( name: . shortAndLong, help: " Build with configuration " )
64
- public var configuration : BuildConfiguration = . debug
65
-
66
- @Option ( name: . customLong( " Xcc " , withSingleDash: true ) ,
67
- parsing: . unconditionalSingleValue,
68
- help: " Pass flag through to all C compiler invocations " )
69
- var cCompilerFlags : [ String ] = [ ]
70
-
71
- @Option ( name: . customLong( " Xswiftc " , withSingleDash: true ) ,
72
- parsing: . unconditionalSingleValue,
73
- help: " Pass flag through to all Swift compiler invocations " )
74
- var swiftCompilerFlags : [ String ] = [ ]
75
-
76
- @Option ( name: . customLong( " Xlinker " , withSingleDash: true ) ,
77
- parsing: . unconditionalSingleValue,
78
- help: " Pass flag through to all linker invocations " )
79
- var linkerFlags : [ String ] = [ ]
80
-
81
- @Option ( name: . customLong( " Xcxx " , withSingleDash: true ) ,
82
- parsing: . unconditionalSingleValue,
83
- help: " Pass flag through to all C++ compiler invocations " )
84
- var cxxCompilerFlags : [ String ] = [ ]
85
-
86
- @Option ( name: . customLong( " Xxcbuild " , withSingleDash: true ) ,
87
- parsing: . unconditionalSingleValue,
88
- help: ArgumentHelp (
89
- " Pass flag through to the Xcode build system invocations " ,
90
- visibility: . hidden) )
91
- public var xcbuildFlags : [ String ] = [ ]
92
-
93
- @Option ( name: . customLong( " Xbuild-tools-swiftc " , withSingleDash: true ) ,
94
- parsing: . unconditionalSingleValue,
95
- help: ArgumentHelp ( " Pass flag to the manifest build invocation " ,
96
- visibility: . hidden) )
97
- public var manifestFlags : [ String ] = [ ]
98
-
99
- @Option (
100
- name: . customLong( " arch " ) ,
101
- help: ArgumentHelp ( " Build the package for the these architectures " , visibility: . hidden) )
102
- public var architectures : [ String ] = [ ]
103
-
104
- /// The verbosity of informational output.
105
- @Flag ( name: . shortAndLong, help: " Increase verbosity to include informational output " )
106
- public var verbose : Bool = false
107
-
108
- /// The verbosity of informational output.
109
- @Flag ( name: [ . long, . customLong( " vv " ) ] , help: " Increase verbosity to include debug output " )
110
- public var veryVerbose : Bool = false
111
-
112
- /// Whether to use the integrated Swift driver rather than shelling out
113
- /// to a separate process.
114
- @Flag ( )
115
- public var useIntegratedSwiftDriver : Bool = false
116
-
117
- /// An option that indicates this build should check whether targets only import
118
- /// their explicitly-declared dependencies
119
- @Option ( help: " Check that targets only import their explicitly-declared dependencies " )
120
- public var explicitTargetDependencyImportCheck : TargetDependencyImportCheckingMode = . none
121
-
122
- enum TargetDependencyImportCheckingMode : String , Codable , ExpressibleByArgument , CaseIterable {
123
- case none
124
- case error
125
- }
126
-
127
- /// Disables adding $ORIGIN/@loader_path to the rpath, useful when deploying
128
- @Flag ( name: . customLong( " disable-local-rpath " ) , help: " Disable adding $ORIGIN/@loader_path to the rpath by default " )
129
- public var shouldDisableLocalRpath : Bool = false
130
-
131
60
private var buildSystem : BuildSystemProvider . Kind {
132
61
#if os(macOS)
133
62
// Force the Xcode build system if we want to build more than one arch.
134
- return self . architectures. count > 1 ? . xcode : . native
63
+ return self . globalOptions . build . architectures. count > 1 ? . xcode : . native
135
64
#else
136
65
// Force building with the native build system on other platforms than macOS.
137
66
return . native
@@ -140,32 +69,22 @@ struct SwiftBootstrapBuildTool: AsyncSwiftCommand {
140
69
141
70
public var buildFlags : BuildFlags {
142
71
BuildFlags (
143
- cCompilerFlags: self . cCompilerFlags,
144
- cxxCompilerFlags: self . cxxCompilerFlags,
145
- swiftCompilerFlags: self . swiftCompilerFlags,
146
- linkerFlags: self . linkerFlags,
147
- xcbuildFlags: self . xcbuildFlags
72
+ cCompilerFlags: self . globalOptions . build . cCompilerFlags,
73
+ cxxCompilerFlags: self . globalOptions . build . cxxCompilerFlags,
74
+ swiftCompilerFlags: self . globalOptions . build . swiftCompilerFlags,
75
+ linkerFlags: self . globalOptions . build . linkerFlags,
76
+ xcbuildFlags: self . globalOptions . build . xcbuildFlags
148
77
)
149
78
}
150
79
151
- private var logLevel : Basics . Diagnostic . Severity {
152
- if self . verbose {
153
- return . info
154
- } else if self . veryVerbose {
155
- return . debug
156
- } else {
157
- return . warning
158
- }
159
- }
160
-
161
80
public init ( ) { }
162
81
163
82
public func run( _ swiftCommandState: SwiftCommandState ) async throws {
164
83
do {
165
84
let fileSystem = localFileSystem
166
85
167
86
let observabilityScope = ObservabilitySystem { _, diagnostics in
168
- if diagnostics. severity >= logLevel {
87
+ if diagnostics. severity >= self . globalOptions . logging . logLevel {
169
88
print ( diagnostics)
170
89
}
171
90
} . topScope
@@ -186,19 +105,19 @@ struct SwiftBootstrapBuildTool: AsyncSwiftCommand {
186
105
let builder = try Builder (
187
106
fileSystem: localFileSystem,
188
107
observabilityScope: observabilityScope,
189
- logLevel: self . logLevel
108
+ logLevel: self . globalOptions . logging . logLevel
190
109
)
191
110
try await builder. build (
192
111
packagePath: packagePath,
193
112
scratchDirectory: scratchDirectory,
194
113
buildSystem: self . buildSystem,
195
- configuration: self . configuration,
196
- architectures: self . architectures,
114
+ configuration: self . globalOptions . build . configuration ?? . debug ,
115
+ architectures: self . globalOptions . build . architectures,
197
116
buildFlags: self . buildFlags,
198
- manifestBuildFlags: self . manifestFlags,
199
- useIntegratedSwiftDriver: self . useIntegratedSwiftDriver,
200
- explicitTargetDependencyImportCheck: self . explicitTargetDependencyImportCheck,
201
- shouldDisableLocalRpath: self . shouldDisableLocalRpath
117
+ manifestBuildFlags: self . globalOptions . build . manifestFlags,
118
+ useIntegratedSwiftDriver: self . globalOptions . build . useIntegratedSwiftDriver,
119
+ explicitTargetDependencyImportCheck: self . globalOptions . build . explicitTargetDependencyImportCheck,
120
+ shouldDisableLocalRpath: self . globalOptions . linker . shouldDisableLocalRpath
202
121
)
203
122
} catch _ as Diagnostics {
204
123
throw ExitCode . failure
@@ -240,7 +159,7 @@ struct SwiftBootstrapBuildTool: AsyncSwiftCommand {
240
159
buildFlags: BuildFlags ,
241
160
manifestBuildFlags: [ String ] ,
242
161
useIntegratedSwiftDriver: Bool ,
243
- explicitTargetDependencyImportCheck: TargetDependencyImportCheckingMode ,
162
+ explicitTargetDependencyImportCheck: BuildOptions . TargetDependencyImportCheckingMode ,
244
163
shouldDisableLocalRpath: Bool
245
164
) async throws {
246
165
let buildSystem = try createBuildSystem (
@@ -268,7 +187,7 @@ struct SwiftBootstrapBuildTool: AsyncSwiftCommand {
268
187
buildFlags: BuildFlags ,
269
188
manifestBuildFlags: [ String ] ,
270
189
useIntegratedSwiftDriver: Bool ,
271
- explicitTargetDependencyImportCheck: TargetDependencyImportCheckingMode ,
190
+ explicitTargetDependencyImportCheck: BuildOptions . TargetDependencyImportCheckingMode ,
272
191
shouldDisableLocalRpath: Bool ,
273
192
logLevel: Basics . Diagnostic . Severity
274
193
) throws -> BuildSystem {
0 commit comments