2
2
//
3
3
// This source file is part of the Swift open source project
4
4
//
5
- // Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See http://swift.org/LICENSE.txt for license information
@@ -16,7 +16,6 @@ import Foundation
16
16
/// environment variables, initial working directory, etc. All paths should be
17
17
/// based on the ones passed to the plugin in the target build context.
18
18
public enum Command {
19
-
20
19
/// Returns a command that runs when any of its output files are needed by
21
20
/// the build, but out-of-date.
22
21
///
@@ -86,8 +85,7 @@ public enum Command {
86
85
)
87
86
}
88
87
89
- public extension Command {
90
-
88
+ extension Command {
91
89
/// Returns a command that runs when any of its output files are needed by
92
90
/// the build, but out-of-date.
93
91
///
@@ -114,20 +112,20 @@ public extension Command {
114
112
/// was generated as if in its source directory; other files are treated
115
113
/// as resources as if explicitly listed in `Package.swift` using
116
114
/// `.process(...)`.
117
- @available ( _PackageDescription, deprecated: 6.0 )
118
- static func buildCommand(
115
+ @available ( _PackageDescription, deprecated: 6.0 , message : " Use `URL` type instead of `Path`. " )
116
+ public static func buildCommand(
119
117
displayName: String ? ,
120
118
executable: Path ,
121
119
arguments: [ CustomStringConvertible ] ,
122
120
environment: [ String : CustomStringConvertible ] = [ : ] ,
123
121
inputFiles: [ Path ] = [ ] ,
124
122
outputFiles: [ Path ] = [ ]
125
123
) -> Command {
126
- return buildCommand (
124
+ self . buildCommand (
127
125
displayName: displayName,
128
126
executable: URL ( fileURLWithPath: executable. stringValue) ,
129
- arguments: arguments. map { $0 . description } ,
130
- environment: environment. mapValues { $0. description } ,
127
+ arguments: arguments. map ( \ . description) ,
128
+ environment: environment. mapValues { $0. description } ,
131
129
inputFiles: inputFiles. map { URL ( fileURLWithPath: $0. stringValue) } ,
132
130
outputFiles: outputFiles. map { URL ( fileURLWithPath: $0. stringValue) }
133
131
)
@@ -160,7 +158,7 @@ public extension Command {
160
158
/// as resources as if explicitly listed in `Package.swift` using
161
159
/// `.process(...)`.
162
160
@available ( * , unavailable, message: " specifying the initial working directory for a command is not yet supported " )
163
- static func buildCommand(
161
+ public static func buildCommand(
164
162
displayName: String ? ,
165
163
executable: Path ,
166
164
arguments: [ CustomStringConvertible ] ,
@@ -169,11 +167,11 @@ public extension Command {
169
167
inputFiles: [ Path ] = [ ] ,
170
168
outputFiles: [ Path ] = [ ]
171
169
) -> Command {
172
- return buildCommand (
170
+ self . buildCommand (
173
171
displayName: displayName,
174
172
executable: URL ( fileURLWithPath: executable. stringValue) ,
175
- arguments: arguments. map { $0 . description } ,
176
- environment: environment. mapValues { $0. description } ,
173
+ arguments: arguments. map ( \ . description) ,
174
+ environment: environment. mapValues { $0. description } ,
177
175
inputFiles: inputFiles. map { URL ( fileURLWithPath: $0. stringValue) } ,
178
176
outputFiles: outputFiles. map { URL ( fileURLWithPath: $0. stringValue) }
179
177
)
@@ -204,19 +202,19 @@ public extension Command {
204
202
/// this command was generated as if in its source directory; other
205
203
/// files are treated as resources as if explicitly listed in
206
204
/// `Package.swift` using `.process(...)`.
207
- @available ( _PackageDescription, deprecated: 6.0 )
208
- static func prebuildCommand(
205
+ @available ( _PackageDescription, deprecated: 6.0 , message : " Use `URL` type instead of `Path`. " )
206
+ public static func prebuildCommand(
209
207
displayName: String ? ,
210
208
executable: Path ,
211
209
arguments: [ CustomStringConvertible ] ,
212
210
environment: [ String : CustomStringConvertible ] = [ : ] ,
213
211
outputFilesDirectory: Path
214
212
) -> Command {
215
- return prebuildCommand (
213
+ self . prebuildCommand (
216
214
displayName: displayName,
217
215
executable: URL ( fileURLWithPath: executable. stringValue) ,
218
- arguments: arguments. map { $0 . description } ,
219
- environment: environment. mapValues { $0. description } ,
216
+ arguments: arguments. map ( \ . description) ,
217
+ environment: environment. mapValues { $0. description } ,
220
218
outputFilesDirectory: URL ( fileURLWithPath: outputFilesDirectory. stringValue)
221
219
)
222
220
}
@@ -247,19 +245,19 @@ public extension Command {
247
245
/// files are treated as resources as if explicitly listed in
248
246
/// `Package.swift` using `.process(...)`.
249
247
@available ( * , unavailable, message: " specifying the initial working directory for a command is not yet supported " )
250
- static func prebuildCommand(
248
+ public static func prebuildCommand(
251
249
displayName: String ? ,
252
250
executable: Path ,
253
251
arguments: [ CustomStringConvertible ] ,
254
252
environment: [ String : CustomStringConvertible ] = [ : ] ,
255
253
workingDirectory: Path ? = . none,
256
254
outputFilesDirectory: Path
257
255
) -> Command {
258
- return prebuildCommand (
256
+ self . prebuildCommand (
259
257
displayName: displayName,
260
258
executable: URL ( fileURLWithPath: executable. stringValue) ,
261
- arguments: arguments. map { $0 . description } ,
262
- environment: environment. mapValues { $0. description } ,
259
+ arguments: arguments. map ( \ . description) ,
260
+ environment: environment. mapValues { $0. description } ,
263
261
outputFilesDirectory: URL ( fileURLWithPath: outputFilesDirectory. stringValue)
264
262
)
265
263
}
0 commit comments