Skip to content

Toolchain path is one folder up from swift bin path #606

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 2 commits into from
Sep 13, 2023
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
1 change: 1 addition & 0 deletions src/debugger/lldb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { SwiftToolchain } from "../toolchain/toolchain";
* @returns Library path for LLDB
*/
export async function getLLDBLibPath(toolchain: SwiftToolchain): Promise<Result<string>> {
// can't use toolchain path here as LLDB is not in macOS toolchain path
const executable = path.join(toolchain.swiftFolderPath, "lldb");
let pathHint = path.dirname(toolchain.swiftFolderPath);
try {
Expand Down
17 changes: 7 additions & 10 deletions src/sourcekit-lsp/LanguageClientManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,13 @@ export class LanguageClientManager {
configuration.path.length > 0 &&
serverPathConfig !== toolchainSourceKitLSP
) {
// if configuration has custom swift path then set toolchain path
if (configuration.path) {
// eslint-disable-next-line @typescript-eslint/naming-convention
sourcekit.options = {
env: {
...sourcekit.options?.env,
SOURCEKIT_TOOLCHAIN_PATH: this.workspaceContext.toolchain.toolchainPath,
},
};
}
// eslint-disable-next-line @typescript-eslint/naming-convention
sourcekit.options = {
env: {
...sourcekit.options?.env,
SOURCEKIT_TOOLCHAIN_PATH: this.workspaceContext.toolchain.toolchainPath,
},
};
}

const serverOptions: langclient.ServerOptions = sourcekit;
Expand Down
4 changes: 2 additions & 2 deletions src/toolchain/Sanitizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export class Sanitizer {
}
}

/** Return runtime environment variables */
/** Return runtime environment variables for macOS */
get runtimeEnvironment(): Record<string, string> | undefined {
if (!this.toolchain.toolchainPath) {
return undefined;
}
const lib = `/usr/lib/swift/clang/lib/darwin/libclang_rt.${this.clangName}_osx_dynamic.dylib`;
const lib = `/lib/swift/clang/lib/darwin/libclang_rt.${this.clangName}_osx_dynamic.dylib`;
const libFullPath = path.join(this.toolchain.toolchainPath, lib);
return { DYLD_INSERT_LIBRARIES: libFullPath };
}
Expand Down
16 changes: 8 additions & 8 deletions src/toolchain/toolchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export function getDarwinTargetTriple(target: DarwinCompatibleTarget): string |

export class SwiftToolchain {
constructor(
public swiftFolderPath: string,
public toolchainPath: string,
public swiftVersionString: string,
public swiftVersion: Version,
public runtimePath?: string,
public swiftFolderPath: string, // folder swift executable in $PATH was found in
public toolchainPath: string, // toolchain folder. One folder up from swift bin folder. This is to support toolchains without usr folder
public swiftVersionString: string, // Swift version as a string, including description
public swiftVersion: Version, // Swift version as semVar variable
public runtimePath?: string, // runtime library included in output from `swift -print-target-info`
private defaultTarget?: string,
private defaultSDK?: string,
private customSDK?: string,
Expand Down Expand Up @@ -179,7 +179,7 @@ export class SwiftToolchain {
public getToolchainExecutable(exe: string): string {
// should we add `.exe` at the end of the executable name
const windowsExeSuffix = process.platform === "win32" ? ".exe" : "";
return `${this.toolchainPath}/usr/bin/${exe}${windowsExeSuffix}`;
return `${this.toolchainPath}/bin/${exe}${windowsExeSuffix}`;
}

logDiagnostics(channel: SwiftOutputChannel) {
Expand Down Expand Up @@ -286,10 +286,10 @@ export class SwiftToolchain {
env: configuration.swiftEnvironmentVariables,
});
const swift = stdout.trimEnd();
return path.dirname(path.dirname(path.dirname(swift)));
return path.dirname(path.dirname(swift));
}
default: {
return path.dirname(path.dirname(swiftPath));
return path.dirname(swiftPath);
}
}
} catch {
Expand Down