Skip to content

Commit 6419477

Browse files
authored
Merge pull request swiftlang#81 from benlangmuir/describe-path
Use AbsolutePath.pathString instead of description
2 parents 0b368e7 + 7735182 commit 6419477

File tree

10 files changed

+62
-62
lines changed

10 files changed

+62
-62
lines changed

Sources/SKCore/FallbackBuildSystem.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public final class FallbackBuildSystem: BuildSystem {
5353
if let sdkpath = sdkpath {
5454
args += [
5555
"-sdk",
56-
sdkpath.description,
56+
sdkpath.pathString,
5757
]
5858
}
59-
args.append(path.description)
59+
args.append(path.pathString)
6060
return FileBuildSettings(preferredToolchain: nil, compilerArguments: args)
6161
}
6262

@@ -65,10 +65,10 @@ public final class FallbackBuildSystem: BuildSystem {
6565
if let sdkpath = sdkpath {
6666
args += [
6767
"-isysroot",
68-
sdkpath.description,
68+
sdkpath.pathString,
6969
]
7070
}
71-
args.append(path.description)
71+
args.append(path.pathString)
7272
return FileBuildSettings(preferredToolchain: nil, compilerArguments: args)
7373
}
7474
}

Sources/SKCore/Toolchain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extension Toolchain {
107107
path: path)
108108
} else {
109109
self.init(
110-
identifier: path.description,
110+
identifier: path.pathString,
111111
displayName: path.basename,
112112
path: path)
113113
}

Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ public final class SwiftPMWorkspace {
9595
var extraSwiftFlags: [String] = []
9696
var extraClangFlags: [String] = []
9797
if let sdk = sdk {
98-
extraSwiftFlags += ["-sdk", sdk.description]
99-
extraClangFlags += ["-isysroot", sdk.description]
98+
extraSwiftFlags += ["-sdk", sdk.pathString]
99+
extraClangFlags += ["-isysroot", sdk.pathString]
100100
}
101101

102102
if let platformPath = platformPath {
103103
let flags = [
104104
"-F",
105-
platformPath.appending(components: "Developer", "Library", "Frameworks").description
105+
platformPath.appending(components: "Developer", "Library", "Frameworks").pathString
106106
]
107107
extraSwiftFlags += flags
108108
extraClangFlags += flags
@@ -277,7 +277,7 @@ extension SwiftPMWorkspace {
277277
/// Retrieve settings for a package manifest (Package.swift).
278278
func settings(forPackageManifest path: AbsolutePath) -> FileBuildSettings? {
279279
for package in packageGraph.packages where path == package.manifest.path {
280-
let compilerArgs = workspace.interpreterFlags(for: package.path) + [path.description]
280+
let compilerArgs = workspace.interpreterFlags(for: package.path) + [path.pathString]
281281
return FileBuildSettings(
282282
preferredToolchain: nil,
283283
compilerArguments: compilerArgs
@@ -311,21 +311,21 @@ extension SwiftPMWorkspace {
311311
"-emit-dependencies",
312312
"-emit-module",
313313
"-emit-module-path",
314-
buildPath.appending(component: "\(td.target.c99name).swiftmodule").description
314+
buildPath.appending(component: "\(td.target.c99name).swiftmodule").pathString
315315
// -output-file-map <path>
316316
]
317317
if td.target.type == .library || td.target.type == .test {
318318
args += ["-parse-as-library"]
319319
}
320320
args += ["-c"]
321-
args += td.target.sources.paths.map { $0.description }
322-
args += ["-I", buildPath.description]
321+
args += td.target.sources.paths.map { $0.pathString }
322+
args += ["-I", buildPath.pathString]
323323
args += td.compileArguments()
324324

325325
return FileBuildSettings(
326326
preferredToolchain: nil,
327327
compilerArguments: args,
328-
workingDirectory: workspacePath.description)
328+
workingDirectory: workspacePath.pathString)
329329
}
330330

331331
/// Retrieve settings for the given C-family language file, which is part of a known target build
@@ -348,7 +348,7 @@ extension SwiftPMWorkspace {
348348
"-MT",
349349
"dependencies",
350350
"-MF",
351-
compilePath.deps.description,
351+
compilePath.deps.pathString,
352352
]
353353
}
354354

@@ -368,27 +368,27 @@ extension SwiftPMWorkspace {
368368
if let compilePath = compilePath {
369369
args += [
370370
"-c",
371-
compilePath.source.description,
371+
compilePath.source.pathString,
372372
"-o",
373-
compilePath.object.description
373+
compilePath.object.pathString
374374
]
375375
} else if path.extension == "h" {
376376
args += ["-c"]
377377
if let xflag = language.xflagHeader {
378378
args += ["-x", xflag]
379379
}
380-
args += [path.description]
380+
args += [path.pathString]
381381
} else {
382382
args += [
383383
"-c",
384-
path.description,
384+
path.pathString,
385385
]
386386
}
387387

388388
return FileBuildSettings(
389389
preferredToolchain: nil,
390390
compilerArguments: args,
391-
workingDirectory: workspacePath.description)
391+
workingDirectory: workspacePath.pathString)
392392
}
393393
}
394394

Sources/SourceKit/SourceKitServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public final class SourceKitServer: LanguageServer {
172172
let resp = try service.sendSync(InitializeRequest(
173173
processId: Int(getpid()),
174174
rootPath: nil,
175-
rootURL: (workspace?.rootPath).map { URL(fileURLWithPath: $0.description) },
175+
rootURL: (workspace?.rootPath).map { URL(fileURLWithPath: $0.pathString) },
176176
initializationOptions: InitializationOptions(),
177177
capabilities: workspace?.clientCapabilities ?? ClientCapabilities(workspace: nil, textDocument: nil),
178178
trace: .off,

Sources/SourceKit/Workspace.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ public final class Workspace {
9595
let libPath = toolchainRegistry.default?.libIndexStore
9696
{
9797
do {
98-
let lib = try IndexStoreLibrary(dylibPath: libPath.description)
98+
let lib = try IndexStoreLibrary(dylibPath: libPath.pathString)
9999
self.index = try IndexStoreDB(
100-
storePath: storePath.description,
101-
databasePath: dbPath.description,
100+
storePath: storePath.pathString,
101+
databasePath: dbPath.pathString,
102102
library: lib)
103103
log("opened IndexStoreDB at \(dbPath) with store path \(storePath)")
104104
} catch {

Sources/SourceKit/clangd/ClangLanguageServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func makeJSONRPCClangServer(client: MessageHandler, clangd: AbsolutePath, buildS
149149
if #available(OSX 10.13, *) {
150150
process.executableURL = clangd.asURL
151151
} else {
152-
process.launchPath = clangd.description
152+
process.launchPath = clangd.pathString
153153
}
154154

155155
process.arguments = [

Sources/SourceKit/sourcekitd/SwiftSourceKitFramework.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class SwiftSourceKitFramework {
4242

4343
init(dylib path: AbsolutePath) throws {
4444
self.path = path
45-
self.dylib = try dlopen(path.description, mode: [.lazy, .local, .first, .deepBind])
45+
self.dylib = try dlopen(path.pathString, mode: [.lazy, .local, .first, .deepBind])
4646

4747
func dlsym_required<T>(_ handle: DLHandle, symbol: String) throws -> T {
4848
guard let sym: T = dlsym(handle, symbol: symbol) else {

Tests/SKCoreTests/FallbackBuildSystemTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ final class FallbackBuildSystemTests: XCTestCase {
3434
let args = settings.compilerArguments
3535
XCTAssertEqual(args, [
3636
"-sdk",
37-
sdk.description,
38-
source.description,
37+
sdk.pathString,
38+
source.pathString,
3939
])
4040

4141
bs.sdkpath = nil
4242

4343
XCTAssertEqual(bs.settings(for: source.asURL, .swift)?.compilerArguments, [
44-
source.description,
44+
source.pathString,
4545
])
4646
}
4747

@@ -59,14 +59,14 @@ final class FallbackBuildSystemTests: XCTestCase {
5959
let args = settings.compilerArguments
6060
XCTAssertEqual(args, [
6161
"-isysroot",
62-
sdk.description,
63-
source.description,
62+
sdk.pathString,
63+
source.pathString,
6464
])
6565

6666
bs.sdkpath = nil
6767

6868
XCTAssertEqual(bs.settings(for: source.asURL, .cpp)?.compilerArguments, [
69-
source.description,
69+
source.pathString,
7070
])
7171
}
7272

@@ -75,7 +75,7 @@ final class FallbackBuildSystemTests: XCTestCase {
7575
let bs = FallbackBuildSystem()
7676
bs.sdkpath = nil
7777
XCTAssertEqual(bs.settings(for: source.asURL, .c)?.compilerArguments, [
78-
source.description,
78+
source.pathString,
7979
])
8080
}
8181

@@ -84,7 +84,7 @@ final class FallbackBuildSystemTests: XCTestCase {
8484
let bs = FallbackBuildSystem()
8585
bs.sdkpath = nil
8686
XCTAssertEqual(bs.settings(for: source.asURL, .objective_c)?.compilerArguments, [
87-
source.description,
87+
source.pathString,
8888
])
8989
}
9090

@@ -93,7 +93,7 @@ final class FallbackBuildSystemTests: XCTestCase {
9393
let bs = FallbackBuildSystem()
9494
bs.sdkpath = nil
9595
XCTAssertEqual(bs.settings(for: source.asURL, .objective_cpp)?.compilerArguments, [
96-
source.description,
96+
source.pathString,
9797
])
9898
}
9999

Tests/SKCoreTests/ToolchainRegistryTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ final class ToolchainRegistryTests: XCTestCase {
197197
}
198198

199199
XCTAssertEqual(tr.default?.identifier, tc.identifier)
200-
XCTAssertEqual(tc.identifier, binPath.description)
200+
XCTAssertEqual(tc.identifier, binPath.pathString)
201201
XCTAssertNil(tc.clang)
202202
XCTAssertNil(tc.clangd)
203203
XCTAssertNil(tc.swiftc)
@@ -215,7 +215,7 @@ final class ToolchainRegistryTests: XCTestCase {
215215
}
216216

217217
XCTAssertEqual(tr.default?.identifier, tc.identifier)
218-
XCTAssertEqual(tc2.identifier, binPath2.description)
218+
XCTAssertEqual(tc2.identifier, binPath2.pathString)
219219
XCTAssertNotNil(tc2.sourcekitd)
220220
}
221221

@@ -228,7 +228,7 @@ final class ToolchainRegistryTests: XCTestCase {
228228
XCTAssertNil(tr.default)
229229
XCTAssert(tr.toolchains.isEmpty)
230230

231-
try! setenv("TEST_SOURCEKIT_TOOLCHAIN_PATH_1", value: binPath.parentDirectory.description)
231+
try! setenv("TEST_SOURCEKIT_TOOLCHAIN_PATH_1", value: binPath.parentDirectory.pathString)
232232

233233
tr.scanForToolchains(environmentVariables: ["TEST_SOURCEKIT_TOOLCHAIN_PATH_1"], fs)
234234

@@ -238,7 +238,7 @@ final class ToolchainRegistryTests: XCTestCase {
238238
}
239239

240240
XCTAssertEqual(tr.default?.identifier, tc.identifier)
241-
XCTAssertEqual(tc.identifier, binPath.parentDirectory.description)
241+
XCTAssertEqual(tc.identifier, binPath.parentDirectory.pathString)
242242
XCTAssertNil(tc.clang)
243243
XCTAssertNil(tc.clangd)
244244
XCTAssertNil(tc.swiftc)
@@ -255,7 +255,7 @@ final class ToolchainRegistryTests: XCTestCase {
255255
XCTAssertNil(tr.default)
256256
XCTAssert(tr.toolchains.isEmpty)
257257

258-
try! setenv("TEST_ENV_SOURCEKIT_TOOLCHAIN_PATH_2", value: binPath.parentDirectory.description)
258+
try! setenv("TEST_ENV_SOURCEKIT_TOOLCHAIN_PATH_2", value: binPath.parentDirectory.pathString)
259259

260260
tr.scanForToolchains(
261261
environmentVariables: ["TEST_ENV_SOURCEKIT_TOOLCHAIN_PATH_2"],
@@ -267,7 +267,7 @@ final class ToolchainRegistryTests: XCTestCase {
267267
return
268268
}
269269

270-
XCTAssertEqual(tc.identifier, binPath.parentDirectory.description)
270+
XCTAssertEqual(tc.identifier, binPath.parentDirectory.pathString)
271271
XCTAssertNil(tc.clang)
272272
XCTAssertNil(tc.clangd)
273273
XCTAssertNil(tc.swiftc)
@@ -298,7 +298,7 @@ final class ToolchainRegistryTests: XCTestCase {
298298
XCTAssertNil(t1.swiftc)
299299

300300
func chmodRX(_ path: AbsolutePath) {
301-
XCTAssertEqual(chmod(path.description, S_IRUSR | S_IXUSR), 0)
301+
XCTAssertEqual(chmod(path.pathString, S_IRUSR | S_IXUSR), 0)
302302
}
303303

304304
chmodRX(path.appending(components: "bin", "clang"))
@@ -471,7 +471,7 @@ private func makeToolchain(
471471
let makeExec = { (path: AbsolutePath) in
472472
try! fs.writeFileContents(path , bytes: "")
473473
if shouldChmod {
474-
XCTAssertEqual(chmod(path.description, S_IRUSR | S_IXUSR), 0)
474+
XCTAssertEqual(chmod(path.pathString, S_IRUSR | S_IXUSR), 0)
475475
}
476476
}
477477

Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ final class SwiftPMWorkspaceTests: XCTestCase {
118118
check("-target", "x86_64-unknown-linux", arguments: arguments)
119119
#endif
120120

121-
check("-I", build.description, arguments: arguments)
121+
check("-I", build.pathString, arguments: arguments)
122122

123-
check(aswift.description, arguments: arguments)
123+
check(aswift.pathString, arguments: arguments)
124124
}
125125

126126
func testBuildSetup() {
@@ -186,7 +186,7 @@ final class SwiftPMWorkspaceTests: XCTestCase {
186186
let arguments = ws.settings(for: source.asURL, .swift)!.compilerArguments
187187

188188
check("-swift-version", "4.2", arguments: arguments)
189-
check(source.description, arguments: arguments)
189+
check(source.pathString, arguments: arguments)
190190
}
191191

192192
func testMultiFileSwift() {
@@ -215,11 +215,11 @@ final class SwiftPMWorkspaceTests: XCTestCase {
215215
let bswift = packageRoot.appending(components: "Sources", "lib", "b.swift")
216216

217217
let argumentsA = ws.settings(for: aswift.asURL, .swift)!.compilerArguments
218-
check(aswift.description, arguments: argumentsA)
219-
check(bswift.description, arguments: argumentsA)
218+
check(aswift.pathString, arguments: argumentsA)
219+
check(bswift.pathString, arguments: argumentsA)
220220
let argumentsB = ws.settings(for: aswift.asURL, .swift)!.compilerArguments
221-
check(aswift.description, arguments: argumentsB)
222-
check(bswift.description, arguments: argumentsB)
221+
check(aswift.pathString, arguments: argumentsB)
222+
check(bswift.pathString, arguments: argumentsB)
223223
}
224224

225225
func testMultiTargetSwift() {
@@ -253,16 +253,16 @@ final class SwiftPMWorkspaceTests: XCTestCase {
253253
let aswift = packageRoot.appending(components: "Sources", "libA", "a.swift")
254254
let bswift = packageRoot.appending(components: "Sources", "libB", "b.swift")
255255
let arguments = ws.settings(for: aswift.asURL, .swift)!.compilerArguments
256-
check(aswift.description, arguments: arguments)
257-
checkNot(bswift.description, arguments: arguments)
256+
check(aswift.pathString, arguments: arguments)
257+
checkNot(bswift.pathString, arguments: arguments)
258258
check(
259-
"-I", packageRoot.appending(components: "Sources", "libC", "include").description,
259+
"-I", packageRoot.appending(components: "Sources", "libC", "include").pathString,
260260
arguments: arguments)
261261

262262
let argumentsB = ws.settings(for: bswift.asURL, .swift)!.compilerArguments
263-
check(bswift.description, arguments: argumentsB)
264-
checkNot(aswift.description, arguments: argumentsB)
265-
checkNot("-I", packageRoot.appending(components: "Sources", "libC", "include").description,
263+
check(bswift.pathString, arguments: argumentsB)
264+
checkNot(aswift.pathString, arguments: argumentsB)
265+
checkNot("-I", packageRoot.appending(components: "Sources", "libC", "include").pathString,
266266
arguments: argumentsB)
267267
}
268268

@@ -341,24 +341,24 @@ final class SwiftPMWorkspaceTests: XCTestCase {
341341
check("-target", "x86_64-unknown-linux", arguments: arguments)
342342
#endif
343343

344-
check("-I", packageRoot.appending(components: "Sources", "lib", "include").description,
344+
check("-I", packageRoot.appending(components: "Sources", "lib", "include").pathString,
345345
arguments: arguments)
346-
checkNot("-I", build.description, arguments: arguments)
347-
checkNot(bcxx.description, arguments: arguments)
346+
checkNot("-I", build.pathString, arguments: arguments)
347+
checkNot(bcxx.pathString, arguments: arguments)
348348
}
349349

350350
let args = ws.settings(for: acxx.asURL, .cpp)!.compilerArguments
351351
checkArgsCommon(args)
352352
check("-MD", "-MT", "dependencies",
353-
"-MF", build.appending(components: "lib.build", "a.cpp.d").description,
353+
"-MF", build.appending(components: "lib.build", "a.cpp.d").pathString,
354354
arguments: args)
355-
check("-c", acxx.description, arguments: args)
356-
check("-o", build.appending(components: "lib.build", "a.cpp.o").description, arguments: args)
355+
check("-c", acxx.pathString, arguments: args)
356+
check("-o", build.appending(components: "lib.build", "a.cpp.o").pathString, arguments: args)
357357

358358
let header = packageRoot.appending(components: "Sources", "lib", "include", "a.h")
359359
let headerArgs = ws.settings(for: header.asURL, .cpp)!.compilerArguments
360360
checkArgsCommon(headerArgs)
361-
check("-c", "-x", "c++-header", header.description, arguments: headerArgs)
361+
check("-c", "-x", "c++-header", header.pathString, arguments: headerArgs)
362362
}
363363

364364
func testDeploymentTargetSwift() {

0 commit comments

Comments
 (0)