@@ -57,17 +57,16 @@ public final class ArgsResolver {
57
57
}
58
58
}
59
59
60
- public func resolveArgumentList( for job: Job , useResponseFiles: ResponseFileHandling = . heuristic,
61
- quotePaths: Bool = false ) throws -> [ String ] {
62
- let ( arguments, _) = try resolveArgumentList ( for: job, useResponseFiles: useResponseFiles,
63
- quotePaths: quotePaths)
60
+ public func resolveArgumentList( for job: Job , useResponseFiles: ResponseFileHandling = . heuristic)
61
+ throws -> [ String ] {
62
+ let ( arguments, _) = try resolveArgumentList ( for: job, useResponseFiles: useResponseFiles)
64
63
return arguments
65
64
}
66
65
67
- public func resolveArgumentList( for job: Job , useResponseFiles: ResponseFileHandling = . heuristic,
68
- quotePaths : Bool = false ) throws -> ( [ String ] , usingResponseFile: Bool ) {
69
- let tool = try resolve ( . path( job. tool) , quotePaths : quotePaths )
70
- var arguments = [ tool] + ( try job. commandLine. map { try resolve ( $0, quotePaths : quotePaths ) } )
66
+ public func resolveArgumentList( for job: Job , useResponseFiles: ResponseFileHandling = . heuristic)
67
+ throws -> ( [ String ] , usingResponseFile: Bool ) {
68
+ let tool = try resolve ( . path( job. tool) )
69
+ var arguments = [ tool] + ( try job. commandLine. map { try resolve ( $0) } )
71
70
let usingResponseFile = try createResponseFileIfNeeded ( for: job, resolvedArguments: & arguments,
72
71
useResponseFiles: useResponseFiles)
73
72
return ( arguments, usingResponseFile)
@@ -77,46 +76,45 @@ public final class ArgsResolver {
77
76
public func resolveArgumentList( for job: Job , forceResponseFiles: Bool ,
78
77
quotePaths: Bool = false ) throws -> [ String ] {
79
78
let useResponseFiles : ResponseFileHandling = forceResponseFiles ? . forced : . heuristic
80
- return try resolveArgumentList ( for: job, useResponseFiles: useResponseFiles, quotePaths : quotePaths )
79
+ return try resolveArgumentList ( for: job, useResponseFiles: useResponseFiles)
81
80
}
82
81
83
82
@available ( * , deprecated, message: " use resolveArgumentList(for:,useResponseFiles:,quotePaths:) " )
84
83
public func resolveArgumentList( for job: Job , forceResponseFiles: Bool ,
85
84
quotePaths: Bool = false ) throws -> ( [ String ] , usingResponseFile: Bool ) {
86
85
let useResponseFiles : ResponseFileHandling = forceResponseFiles ? . forced : . heuristic
87
- return try resolveArgumentList ( for: job, useResponseFiles: useResponseFiles, quotePaths : quotePaths )
86
+ return try resolveArgumentList ( for: job, useResponseFiles: useResponseFiles)
88
87
}
89
88
90
89
/// Resolve the given argument.
91
- public func resolve( _ arg: Job . ArgTemplate ,
92
- quotePaths: Bool = false ) throws -> String {
90
+ public func resolve( _ arg: Job . ArgTemplate ) throws -> String {
93
91
switch arg {
94
92
case . flag( let flag) :
95
93
return flag
96
94
97
95
case . path( let path) :
98
96
return try lock. withLock {
99
- return try unsafeResolve ( path: path, quotePaths : quotePaths )
97
+ return try unsafeResolve ( path: path)
100
98
}
101
99
102
100
case . responseFilePath( let path) :
103
- return " @ \( try resolve ( . path( path) , quotePaths : quotePaths ) ) "
101
+ return " @ \( try resolve ( . path( path) ) ) "
104
102
105
103
case let . joinedOptionAndPath( option, path) :
106
- return option + ( try resolve ( . path( path) , quotePaths : quotePaths ) )
104
+ return option + ( try resolve ( . path( path) ) )
107
105
108
106
case let . squashedArgumentList( option: option, args: args) :
109
107
return try option + args. map {
110
- try resolve ( $0, quotePaths : quotePaths )
108
+ try resolve ( $0)
111
109
} . joined ( separator: " " )
112
110
}
113
111
}
114
112
115
113
/// Needs to be done inside of `lock`. Marked unsafe to make that more obvious.
116
- private func unsafeResolve( path: VirtualPath , quotePaths : Bool ) throws -> String {
114
+ private func unsafeResolve( path: VirtualPath ) throws -> String {
117
115
// If there was a path mapping, use it.
118
116
if let actualPath = pathMapping [ path] {
119
- return quotePaths ? quoteArgument ( actualPath ) : actualPath
117
+ return actualPath
120
118
}
121
119
122
120
// Return the path from the temporary directory if this is a temporary file.
@@ -140,21 +138,21 @@ public final class ArgsResolver {
140
138
141
139
let result = actualPath. name
142
140
pathMapping [ path] = result
143
- return quotePaths ? " ' \( result ) ' " : result
141
+ return result
144
142
}
145
143
146
144
// Otherwise, return the path.
147
145
let result = path. name
148
146
pathMapping [ path] = result
149
- return quotePaths ? quoteArgument ( result ) : result
147
+ return result
150
148
}
151
149
152
150
private func createFileList( path: VirtualPath , contents: [ VirtualPath ] ) throws {
153
151
// FIXME: Need a way to support this for distributed build systems...
154
152
if let absPath = path. absolutePath {
155
153
try fileSystem. writeFileContents ( absPath) { out in
156
154
for path in contents {
157
- try ! out <<< unsafeResolve ( path: path, quotePaths : false ) <<< " \n "
155
+ try ! out <<< unsafeResolve ( path: path) <<< " \n "
158
156
}
159
157
}
160
158
}
@@ -184,7 +182,7 @@ public final class ArgsResolver {
184
182
}
185
183
186
184
private func quoteAndEscape( path: VirtualPath ) -> String {
187
- let inputNode = Node . scalar ( Node . Scalar ( try ! unsafeResolve ( path: path, quotePaths : false ) ,
185
+ let inputNode = Node . scalar ( Node . Scalar ( try ! unsafeResolve ( path: path) ,
188
186
Tag ( . str) , . doubleQuoted) )
189
187
// Width parameter of -1 sets preferred line-width to unlimited so that no extraneous
190
188
// line-breaks will be inserted during serialization.
0 commit comments