Skip to content

Commit

Permalink
Run Task: Use DevEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
CyborgPotato authored and David Crompton committed Apr 15, 2024
1 parent 0e06d33 commit f5665a7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/tasks.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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(
{
Expand All @@ -44,9 +43,8 @@ function createRunTask(t: Target, targetName: string) {
},
`Run ${targetDisplayName}`,
"Meson",
new vscode.ProcessExecution(t.filename[0], {
cwd: workspaceState.get<string>("mesonbuild.sourceDir")!,
env: getEnvDict(),
new vscode.ProcessExecution(meson, ["devenv", t.filename[0]], {
cwd: buildDir,
}),
);
runTask.group = vscode.TaskGroup.Test;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f5665a7

Please sign in to comment.