@@ -31,23 +31,6 @@ extension BuildSubset {
31
31
}
32
32
33
33
struct BuildToolOptions : ParsableArguments {
34
- enum BuildToolMode {
35
- /// Build the package.
36
- case build
37
-
38
- /// Print the binary output path.
39
- case binPath
40
- }
41
-
42
- /// Returns the mode in which the build tool should run.
43
- func mode( ) throws -> BuildToolMode {
44
- if shouldPrintBinPath {
45
- return . binPath
46
- }
47
- // Get the build configuration or assume debug.
48
- return . build
49
- }
50
-
51
34
/// Returns the build subset specified with the options.
52
35
func buildSubset( diagnostics: DiagnosticsEngine ) -> BuildSubset ? {
53
36
var allSubsets : [ BuildSubset ] = [ ]
@@ -95,29 +78,36 @@ struct BuildToolOptions: ParsableArguments {
95
78
/// swift-build tool namespace
96
79
public struct SwiftBuildTool : ParsableCommand {
97
80
public static let configuration = CommandConfiguration (
98
- commandName: " build " ,
99
- abstract: " Build sources into binary products " )
81
+ commandName: " swift build " ,
82
+ abstract: " Build sources into binary products " ,
83
+ discussion: " SEE ALSO: swift run, swift package, swift test " ,
84
+ version: Versioning . currentVersion. completeDisplayString,
85
+ helpNames: [ . short, . long, . customLong( " help " , withSingleDash: true ) ] )
100
86
101
87
@OptionGroup ( )
102
88
var options : BuildToolOptions
103
-
89
+
104
90
public func run( ) throws {
105
- let swiftTool = SwiftTool ( options: options. swiftOptions)
106
-
107
- switch try options. mode ( ) {
108
- case . build:
109
- #if os(Linux)
110
- // Emit warning if clang is older than version 3.6 on Linux.
111
- // See: <rdar://problem/28108951> SR-2299 Swift isn't using Gold by default on stock 14.04.
112
- checkClangVersion ( )
113
- #endif
114
-
115
- guard let subset = options. buildSubset ( diagnostics: swiftTool. diagnostics) else { return }
116
- let buildSystem = try swiftTool. createBuildSystem ( )
117
- try buildSystem. build ( subset: subset)
91
+ let swiftTool = try SwiftTool ( options: options. swiftOptions)
118
92
119
- case . binPath :
93
+ if options . shouldPrintBinPath {
120
94
try print ( swiftTool. buildParameters ( ) . buildPath. description)
95
+ return
96
+ }
97
+
98
+ #if os(Linux)
99
+ // Emit warning if clang is older than version 3.6 on Linux.
100
+ // See: <rdar://problem/28108951> SR-2299 Swift isn't using Gold by default on stock 14.04.
101
+ checkClangVersion ( )
102
+ #endif
103
+
104
+ guard let subset = options. buildSubset ( diagnostics: swiftTool. diagnostics)
105
+ else { throw ExitCode . failure }
106
+ let buildSystem = try swiftTool. createBuildSystem ( )
107
+ do {
108
+ try buildSystem. build ( subset: subset)
109
+ } catch _ as Diagnostics {
110
+ throw ExitCode . failure
121
111
}
122
112
}
123
113
0 commit comments