diff --git a/src/tasks.ts b/src/tasks.ts index ea85291..80dc192 100644 --- a/src/tasks.ts +++ b/src/tasks.ts @@ -1,9 +1,8 @@ import * as vscode from "vscode"; import { getMesonTargets, getMesonTests, getMesonBenchmarks } from "./introspection"; -import { extensionConfiguration, getOutputChannel, getTargetName, getEnvDict } from "./utils"; +import { extensionConfiguration, getOutputChannel, getTargetName } from "./utils"; import { Test, Target } from "./types"; import { checkMesonIsConfigured } from "./utils"; -import { workspaceState } from "./extension"; import { mesonProgram } from "./utils"; interface MesonTaskDefinition extends vscode.TaskDefinition { @@ -33,7 +32,7 @@ function createTestTask(meson: string, t: Test, buildDir: string, isBenchmark: b return testTask; } -function createRunTask(t: Target, targetName: string) { +function createRunTask(meson: string, t: Target, targetName: string, buildDir: string) { const targetDisplayName = targetName.split(":")[0]; let runTask = new vscode.Task( { @@ -44,9 +43,8 @@ function createRunTask(t: Target, targetName: string) { }, `Run ${targetDisplayName}`, "Meson", - new vscode.ProcessExecution(t.filename[0], { - cwd: workspaceState.get("mesonbuild.sourceDir")!, - env: getEnvDict(), + new vscode.ProcessExecution(meson, ["devenv", t.filename[0]], { + cwd: buildDir, }), ); runTask.group = vscode.TaskGroup.Test; @@ -157,7 +155,7 @@ export async function getMesonTasks(buildDir: string, sourceDir: string) { // Create run tasks for executables that are not tests, // both installed and uninstalled (eg: examples) if (!tests.some((test) => test.name === t.name)) { - return [buildTask, createRunTask(t, targetName)]; + return [buildTask, createRunTask(meson, t, targetName, buildDir)]; } } return buildTask; diff --git a/src/utils.ts b/src/utils.ts index 09ec6bc..722e8e5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -146,8 +146,6 @@ export function isThenable(x: vscode.ProviderResult): x is Thenable { return arrayIncludes(Object.getOwnPropertyNames(x), "then"); } -let _envDict: { [key: string]: string } | undefined = undefined; - export async function genEnvFile(buildDir: string) { const envfile = path.join(buildDir, "meson-vscode.env"); try { @@ -164,22 +162,6 @@ export async function genEnvFile(buildDir: string) { // Ignore errors, Meson could be too old to support --dump-format. return; } - - // Load into a dict because vscode.ProcessExecution() does not support envFile. - _envDict = {}; - const data = await fs.promises.readFile(envfile); - for (const i of data.toString().split(/\r?\n/)) { - // Poor man's i.split("=", 1), JS won't return part after first equal sign. - // Value is quoted, remove first and last " char and also possible \r ending. - const index = i.indexOf("="); - const key = i.substring(0, index); - const value = i.slice(index + 2, -1); - _envDict[key] = value; - } -} - -export function getEnvDict() { - return _envDict; } // meson setup --reconfigure is needed if and only if coredata.dat exists.