@@ -5,111 +5,111 @@ import Foundation
55// Usage: build.swift platforms
66
77func execute( commandPath: String , arguments: [ String ] ) throws {
8- let task = Process ( )
9- task. executableURL = . init( filePath: commandPath)
10- task. arguments = arguments
11- print ( " Launching command: \( commandPath) \( arguments. joined ( separator: " " ) ) " )
12- try task. run ( )
13- task. waitUntilExit ( )
14- guard task. terminationStatus == 0 else {
15- throw TaskError . code ( task. terminationStatus)
16- }
8+ let task = Process ( )
9+ task. executableURL = . init( filePath: commandPath)
10+ task. arguments = arguments
11+ print ( " Launching command: \( commandPath) \( arguments. joined ( separator: " " ) ) " )
12+ try task. run ( )
13+ task. waitUntilExit ( )
14+ guard task. terminationStatus == 0 else {
15+ throw TaskError . code ( task. terminationStatus)
16+ }
1717}
1818
1919enum TaskError : Error {
20- case code( Int32 )
20+ case code( Int32 )
2121}
2222
2323enum Platform : String , CaseIterable , CustomStringConvertible {
24- case iOS_18
25- case tvOS_18
26- case macOS_15
27- case macCatalyst_15
28- case watchOS_11
29- case visionOS_2
30-
31- var destination : String {
32- switch self {
33- case . iOS_18:
34- " platform=iOS Simulator,OS=18.0,name=iPad (10th generation) "
35-
36- case . tvOS_18:
37- " platform=tvOS Simulator,OS=18.0,name=Apple TV "
38-
39- case . macOS_15,
40- . macCatalyst_15:
41- " platform=OS X "
42-
43- case . watchOS_11:
44- " OS=11.0,name=Apple Watch Series 10 (46mm) "
45-
46- case . visionOS_2:
47- " OS=2.0,name=Apple Vision Pro "
48- }
49- }
50-
51- var sdk : String {
52- switch self {
53- case . iOS_18:
54- " iphonesimulator "
55-
56- case . tvOS_18:
57- " appletvsimulator "
58-
59- case . macOS_15,
60- . macCatalyst_15:
61- " macosx15.0 "
62-
63- case . watchOS_11:
64- " watchsimulator "
65-
66- case . visionOS_2:
67- " xrsimulator "
68- }
69- }
70-
71- var derivedDataPath : String {
72- " .build/derivedData/ " + description
73- }
74-
75- var description : String {
76- rawValue
77- }
24+ case iOS_18
25+ case tvOS_18
26+ case macOS_15
27+ case macCatalyst_15
28+ case watchOS_11
29+ case visionOS_2
30+
31+ var destination : String {
32+ switch self {
33+ case . iOS_18:
34+ " platform=iOS Simulator,OS=18.0,name=iPad (10th generation) "
35+
36+ case . tvOS_18:
37+ " platform=tvOS Simulator,OS=18.0,name=Apple TV "
38+
39+ case . macOS_15,
40+ . macCatalyst_15:
41+ " platform=OS X "
42+
43+ case . watchOS_11:
44+ " OS=11.0,name=Apple Watch Series 10 (46mm) "
45+
46+ case . visionOS_2:
47+ " OS=2.0,name=Apple Vision Pro "
48+ }
49+ }
50+
51+ var sdk : String {
52+ switch self {
53+ case . iOS_18:
54+ " iphonesimulator "
55+
56+ case . tvOS_18:
57+ " appletvsimulator "
58+
59+ case . macOS_15,
60+ . macCatalyst_15:
61+ " macosx15.0 "
62+
63+ case . watchOS_11:
64+ " watchsimulator "
65+
66+ case . visionOS_2:
67+ " xrsimulator "
68+ }
69+ }
70+
71+ var derivedDataPath : String {
72+ " .build/derivedData/ " + description
73+ }
74+
75+ var description : String {
76+ rawValue
77+ }
7878}
7979
8080guard CommandLine . arguments. count > 1 else {
81- print ( " Usage: build.swift platforms " )
82- throw TaskError . code ( 1 )
81+ print ( " Usage: build.swift platforms " )
82+ throw TaskError . code ( 1 )
8383}
8484
8585let rawPlatforms = CommandLine . arguments [ 1 ] . components ( separatedBy: " , " )
8686
8787for rawPlatform in rawPlatforms {
88- guard let platform = Platform ( rawValue: rawPlatform) else {
89- print ( " Received unknown platform type \( rawPlatform) " )
90- print ( " Possible platform types are: \( Platform . allCases) " )
91- throw TaskError . code ( 1 )
92- }
93-
94- var xcodeBuildArguments = [
95- " -scheme " , " swift-async-queue " ,
96- " -sdk " , platform. sdk,
97- " -derivedDataPath " , platform. derivedDataPath,
98- " -PBXBuildsContinueAfterErrors=0 " ,
99- " OTHER_SWIFT_FLAGS=-warnings-as-errors " ,
100- ]
101-
102- if !platform. destination. isEmpty {
103- xcodeBuildArguments. append ( " -destination " )
104- xcodeBuildArguments. append ( platform. destination)
105- }
106- xcodeBuildArguments. append ( " -enableCodeCoverage " )
107- xcodeBuildArguments. append ( " YES " )
108- xcodeBuildArguments. append ( " build " )
109- xcodeBuildArguments. append ( " test " )
110- xcodeBuildArguments. append ( " -test-iterations " )
111- xcodeBuildArguments. append ( " 100 " )
112- xcodeBuildArguments. append ( " -run-tests-until-failure " )
113-
114- try execute ( commandPath: " /usr/bin/xcodebuild " , arguments: xcodeBuildArguments)
88+ guard let platform = Platform ( rawValue: rawPlatform) else {
89+ print ( " Received unknown platform type \( rawPlatform) " )
90+ print ( " Possible platform types are: \( Platform . allCases) " )
91+ throw TaskError . code ( 1 )
92+ }
93+
94+ var xcodeBuildArguments = [
95+ " -scheme " , " swift-async-queue " ,
96+ " -sdk " , platform. sdk,
97+ " -derivedDataPath " , platform. derivedDataPath,
98+ " -PBXBuildsContinueAfterErrors=0 " ,
99+ " OTHER_SWIFT_FLAGS=-warnings-as-errors " ,
100+ ]
101+
102+ if !platform. destination. isEmpty {
103+ xcodeBuildArguments. append ( " -destination " )
104+ xcodeBuildArguments. append ( platform. destination)
105+ }
106+ xcodeBuildArguments. append ( " -enableCodeCoverage " )
107+ xcodeBuildArguments. append ( " YES " )
108+ xcodeBuildArguments. append ( " build " )
109+ xcodeBuildArguments. append ( " test " )
110+ xcodeBuildArguments. append ( " -test-iterations " )
111+ xcodeBuildArguments. append ( " 100 " )
112+ xcodeBuildArguments. append ( " -run-tests-until-failure " )
113+
114+ try execute ( commandPath: " /usr/bin/xcodebuild " , arguments: xcodeBuildArguments)
115115}
0 commit comments