Skip to content

Use AbsolutePath.pathString instead of description #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/SKCore/FallbackBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public final class FallbackBuildSystem: BuildSystem {
if let sdkpath = sdkpath {
args += [
"-sdk",
sdkpath.description,
sdkpath.pathString,
]
}
args.append(path.description)
args.append(path.pathString)
return FileBuildSettings(preferredToolchain: nil, compilerArguments: args)
}

Expand All @@ -65,10 +65,10 @@ public final class FallbackBuildSystem: BuildSystem {
if let sdkpath = sdkpath {
args += [
"-isysroot",
sdkpath.description,
sdkpath.pathString,
]
}
args.append(path.description)
args.append(path.pathString)
return FileBuildSettings(preferredToolchain: nil, compilerArguments: args)
}
}
2 changes: 1 addition & 1 deletion Sources/SKCore/Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ extension Toolchain {
path: path)
} else {
self.init(
identifier: path.description,
identifier: path.pathString,
displayName: path.basename,
path: path)
}
Expand Down
28 changes: 14 additions & 14 deletions Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ public final class SwiftPMWorkspace {
var extraSwiftFlags: [String] = []
var extraClangFlags: [String] = []
if let sdk = sdk {
extraSwiftFlags += ["-sdk", sdk.description]
extraClangFlags += ["-isysroot", sdk.description]
extraSwiftFlags += ["-sdk", sdk.pathString]
extraClangFlags += ["-isysroot", sdk.pathString]
}

if let platformPath = platformPath {
let flags = [
"-F",
platformPath.appending(components: "Developer", "Library", "Frameworks").description
platformPath.appending(components: "Developer", "Library", "Frameworks").pathString
]
extraSwiftFlags += flags
extraClangFlags += flags
Expand Down Expand Up @@ -277,7 +277,7 @@ extension SwiftPMWorkspace {
/// Retrieve settings for a package manifest (Package.swift).
func settings(forPackageManifest path: AbsolutePath) -> FileBuildSettings? {
for package in packageGraph.packages where path == package.manifest.path {
let compilerArgs = workspace.interpreterFlags(for: package.path) + [path.description]
let compilerArgs = workspace.interpreterFlags(for: package.path) + [path.pathString]
return FileBuildSettings(
preferredToolchain: nil,
compilerArguments: compilerArgs
Expand Down Expand Up @@ -311,21 +311,21 @@ extension SwiftPMWorkspace {
"-emit-dependencies",
"-emit-module",
"-emit-module-path",
buildPath.appending(component: "\(td.target.c99name).swiftmodule").description
buildPath.appending(component: "\(td.target.c99name).swiftmodule").pathString
// -output-file-map <path>
]
if td.target.type == .library || td.target.type == .test {
args += ["-parse-as-library"]
}
args += ["-c"]
args += td.target.sources.paths.map { $0.description }
args += ["-I", buildPath.description]
args += td.target.sources.paths.map { $0.pathString }
args += ["-I", buildPath.pathString]
args += td.compileArguments()

return FileBuildSettings(
preferredToolchain: nil,
compilerArguments: args,
workingDirectory: workspacePath.description)
workingDirectory: workspacePath.pathString)
}

/// Retrieve settings for the given C-family language file, which is part of a known target build
Expand All @@ -348,7 +348,7 @@ extension SwiftPMWorkspace {
"-MT",
"dependencies",
"-MF",
compilePath.deps.description,
compilePath.deps.pathString,
]
}

Expand All @@ -368,27 +368,27 @@ extension SwiftPMWorkspace {
if let compilePath = compilePath {
args += [
"-c",
compilePath.source.description,
compilePath.source.pathString,
"-o",
compilePath.object.description
compilePath.object.pathString
]
} else if path.extension == "h" {
args += ["-c"]
if let xflag = language.xflagHeader {
args += ["-x", xflag]
}
args += [path.description]
args += [path.pathString]
} else {
args += [
"-c",
path.description,
path.pathString,
]
}

return FileBuildSettings(
preferredToolchain: nil,
compilerArguments: args,
workingDirectory: workspacePath.description)
workingDirectory: workspacePath.pathString)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceKit/SourceKitServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public final class SourceKitServer: LanguageServer {
let resp = try service.sendSync(InitializeRequest(
processId: Int(getpid()),
rootPath: nil,
rootURL: (workspace?.rootPath).map { URL(fileURLWithPath: $0.description) },
rootURL: (workspace?.rootPath).map { URL(fileURLWithPath: $0.pathString) },
initializationOptions: InitializationOptions(),
capabilities: workspace?.clientCapabilities ?? ClientCapabilities(workspace: nil, textDocument: nil),
trace: .off,
Expand Down
6 changes: 3 additions & 3 deletions Sources/SourceKit/Workspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public final class Workspace {
let libPath = toolchainRegistry.default?.libIndexStore
{
do {
let lib = try IndexStoreLibrary(dylibPath: libPath.description)
let lib = try IndexStoreLibrary(dylibPath: libPath.pathString)
self.index = try IndexStoreDB(
storePath: storePath.description,
databasePath: dbPath.description,
storePath: storePath.pathString,
databasePath: dbPath.pathString,
library: lib)
log("opened IndexStoreDB at \(dbPath) with store path \(storePath)")
} catch {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceKit/clangd/ClangLanguageServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func makeJSONRPCClangServer(client: MessageHandler, clangd: AbsolutePath, buildS
if #available(OSX 10.13, *) {
process.executableURL = clangd.asURL
} else {
process.launchPath = clangd.description
process.launchPath = clangd.pathString
}

process.arguments = [
Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceKit/sourcekitd/SwiftSourceKitFramework.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class SwiftSourceKitFramework {

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

func dlsym_required<T>(_ handle: DLHandle, symbol: String) throws -> T {
guard let sym: T = dlsym(handle, symbol: symbol) else {
Expand Down
18 changes: 9 additions & 9 deletions Tests/SKCoreTests/FallbackBuildSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ final class FallbackBuildSystemTests: XCTestCase {
let args = settings.compilerArguments
XCTAssertEqual(args, [
"-sdk",
sdk.description,
source.description,
sdk.pathString,
source.pathString,
])

bs.sdkpath = nil

XCTAssertEqual(bs.settings(for: source.asURL, .swift)?.compilerArguments, [
source.description,
source.pathString,
])
}

Expand All @@ -59,14 +59,14 @@ final class FallbackBuildSystemTests: XCTestCase {
let args = settings.compilerArguments
XCTAssertEqual(args, [
"-isysroot",
sdk.description,
source.description,
sdk.pathString,
source.pathString,
])

bs.sdkpath = nil

XCTAssertEqual(bs.settings(for: source.asURL, .cpp)?.compilerArguments, [
source.description,
source.pathString,
])
}

Expand All @@ -75,7 +75,7 @@ final class FallbackBuildSystemTests: XCTestCase {
let bs = FallbackBuildSystem()
bs.sdkpath = nil
XCTAssertEqual(bs.settings(for: source.asURL, .c)?.compilerArguments, [
source.description,
source.pathString,
])
}

Expand All @@ -84,7 +84,7 @@ final class FallbackBuildSystemTests: XCTestCase {
let bs = FallbackBuildSystem()
bs.sdkpath = nil
XCTAssertEqual(bs.settings(for: source.asURL, .objective_c)?.compilerArguments, [
source.description,
source.pathString,
])
}

Expand All @@ -93,7 +93,7 @@ final class FallbackBuildSystemTests: XCTestCase {
let bs = FallbackBuildSystem()
bs.sdkpath = nil
XCTAssertEqual(bs.settings(for: source.asURL, .objective_cpp)?.compilerArguments, [
source.description,
source.pathString,
])
}

Expand Down
16 changes: 8 additions & 8 deletions Tests/SKCoreTests/ToolchainRegistryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ final class ToolchainRegistryTests: XCTestCase {
}

XCTAssertEqual(tr.default?.identifier, tc.identifier)
XCTAssertEqual(tc.identifier, binPath.description)
XCTAssertEqual(tc.identifier, binPath.pathString)
XCTAssertNil(tc.clang)
XCTAssertNil(tc.clangd)
XCTAssertNil(tc.swiftc)
Expand All @@ -215,7 +215,7 @@ final class ToolchainRegistryTests: XCTestCase {
}

XCTAssertEqual(tr.default?.identifier, tc.identifier)
XCTAssertEqual(tc2.identifier, binPath2.description)
XCTAssertEqual(tc2.identifier, binPath2.pathString)
XCTAssertNotNil(tc2.sourcekitd)
}

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

try! setenv("TEST_SOURCEKIT_TOOLCHAIN_PATH_1", value: binPath.parentDirectory.description)
try! setenv("TEST_SOURCEKIT_TOOLCHAIN_PATH_1", value: binPath.parentDirectory.pathString)

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

Expand All @@ -238,7 +238,7 @@ final class ToolchainRegistryTests: XCTestCase {
}

XCTAssertEqual(tr.default?.identifier, tc.identifier)
XCTAssertEqual(tc.identifier, binPath.parentDirectory.description)
XCTAssertEqual(tc.identifier, binPath.parentDirectory.pathString)
XCTAssertNil(tc.clang)
XCTAssertNil(tc.clangd)
XCTAssertNil(tc.swiftc)
Expand All @@ -255,7 +255,7 @@ final class ToolchainRegistryTests: XCTestCase {
XCTAssertNil(tr.default)
XCTAssert(tr.toolchains.isEmpty)

try! setenv("TEST_ENV_SOURCEKIT_TOOLCHAIN_PATH_2", value: binPath.parentDirectory.description)
try! setenv("TEST_ENV_SOURCEKIT_TOOLCHAIN_PATH_2", value: binPath.parentDirectory.pathString)

tr.scanForToolchains(
environmentVariables: ["TEST_ENV_SOURCEKIT_TOOLCHAIN_PATH_2"],
Expand All @@ -267,7 +267,7 @@ final class ToolchainRegistryTests: XCTestCase {
return
}

XCTAssertEqual(tc.identifier, binPath.parentDirectory.description)
XCTAssertEqual(tc.identifier, binPath.parentDirectory.pathString)
XCTAssertNil(tc.clang)
XCTAssertNil(tc.clangd)
XCTAssertNil(tc.swiftc)
Expand Down Expand Up @@ -298,7 +298,7 @@ final class ToolchainRegistryTests: XCTestCase {
XCTAssertNil(t1.swiftc)

func chmodRX(_ path: AbsolutePath) {
XCTAssertEqual(chmod(path.description, S_IRUSR | S_IXUSR), 0)
XCTAssertEqual(chmod(path.pathString, S_IRUSR | S_IXUSR), 0)
}

chmodRX(path.appending(components: "bin", "clang"))
Expand Down Expand Up @@ -471,7 +471,7 @@ private func makeToolchain(
let makeExec = { (path: AbsolutePath) in
try! fs.writeFileContents(path , bytes: "")
if shouldChmod {
XCTAssertEqual(chmod(path.description, S_IRUSR | S_IXUSR), 0)
XCTAssertEqual(chmod(path.pathString, S_IRUSR | S_IXUSR), 0)
}
}

Expand Down
40 changes: 20 additions & 20 deletions Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ final class SwiftPMWorkspaceTests: XCTestCase {
check("-target", "x86_64-unknown-linux", arguments: arguments)
#endif

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

check(aswift.description, arguments: arguments)
check(aswift.pathString, arguments: arguments)
}

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

check("-swift-version", "4.2", arguments: arguments)
check(source.description, arguments: arguments)
check(source.pathString, arguments: arguments)
}

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

let argumentsA = ws.settings(for: aswift.asURL, .swift)!.compilerArguments
check(aswift.description, arguments: argumentsA)
check(bswift.description, arguments: argumentsA)
check(aswift.pathString, arguments: argumentsA)
check(bswift.pathString, arguments: argumentsA)
let argumentsB = ws.settings(for: aswift.asURL, .swift)!.compilerArguments
check(aswift.description, arguments: argumentsB)
check(bswift.description, arguments: argumentsB)
check(aswift.pathString, arguments: argumentsB)
check(bswift.pathString, arguments: argumentsB)
}

func testMultiTargetSwift() {
Expand Down Expand Up @@ -253,16 +253,16 @@ final class SwiftPMWorkspaceTests: XCTestCase {
let aswift = packageRoot.appending(components: "Sources", "libA", "a.swift")
let bswift = packageRoot.appending(components: "Sources", "libB", "b.swift")
let arguments = ws.settings(for: aswift.asURL, .swift)!.compilerArguments
check(aswift.description, arguments: arguments)
checkNot(bswift.description, arguments: arguments)
check(aswift.pathString, arguments: arguments)
checkNot(bswift.pathString, arguments: arguments)
check(
"-I", packageRoot.appending(components: "Sources", "libC", "include").description,
"-I", packageRoot.appending(components: "Sources", "libC", "include").pathString,
arguments: arguments)

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

Expand Down Expand Up @@ -341,24 +341,24 @@ final class SwiftPMWorkspaceTests: XCTestCase {
check("-target", "x86_64-unknown-linux", arguments: arguments)
#endif

check("-I", packageRoot.appending(components: "Sources", "lib", "include").description,
check("-I", packageRoot.appending(components: "Sources", "lib", "include").pathString,
arguments: arguments)
checkNot("-I", build.description, arguments: arguments)
checkNot(bcxx.description, arguments: arguments)
checkNot("-I", build.pathString, arguments: arguments)
checkNot(bcxx.pathString, arguments: arguments)
}

let args = ws.settings(for: acxx.asURL, .cpp)!.compilerArguments
checkArgsCommon(args)
check("-MD", "-MT", "dependencies",
"-MF", build.appending(components: "lib.build", "a.cpp.d").description,
"-MF", build.appending(components: "lib.build", "a.cpp.d").pathString,
arguments: args)
check("-c", acxx.description, arguments: args)
check("-o", build.appending(components: "lib.build", "a.cpp.o").description, arguments: args)
check("-c", acxx.pathString, arguments: args)
check("-o", build.appending(components: "lib.build", "a.cpp.o").pathString, arguments: args)

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

func testDeploymentTargetSwift() {
Expand Down