From a6d44cec6f3ca5fbcd77479270fd60a2d0872438 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Thu, 23 Nov 2023 10:45:53 -0600 Subject: [PATCH] Fix absolute build directories --- CHANGELOG.md | 1 + src/extension.ts | 4 ++-- src/utils.ts | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eae1e70..fcfa295e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## next - Bump Swift-MesonLSP to v3.1.3 +- Fix absolute build directories ## 1.18.1 diff --git a/src/extension.ts b/src/extension.ts index 8c01ce62..c82f7f48 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -10,7 +10,7 @@ import { clearCache, checkMesonIsConfigured, getOutputChannel, - relativeBuildDir, + getBuildDirectory, rootMesonFiles, } from "./utils"; import { DebugConfigurationProviderCppdbg } from "./debug/cppdbg"; @@ -57,7 +57,7 @@ export async function activate(ctx: vscode.ExtensionContext) { const mesonFile = savedMesonFile ?? mesonFiles[0].fsPath; const sourceDir = dirname(mesonFile); - const buildDir = relativeBuildDir(mesonFile); + const buildDir = getBuildDirectory(sourceDir); workspaceState.update("mesonbuild.mesonFile", mesonFile); workspaceState.update("mesonbuild.buildDir", buildDir); diff --git a/src/utils.ts b/src/utils.ts index d7b99134..e31b3a03 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -57,9 +57,11 @@ export function extensionRelative(filepath: string) { return path.join(extensionPath, filepath); } -export function relativeBuildDir(mesonFile: string) { +export function getBuildDirectory(sourceDir: string) { const buildDir = extensionConfiguration("buildFolder"); - return path.join(path.dirname(mesonFile), buildDir); + if (path.isAbsolute(buildDir)) return buildDir; + + return path.join(sourceDir, buildDir); } let _layoutPromise: Promise | null = null;