diff options
Diffstat (limited to 'editors/vscode/src')
| -rw-r--r-- | editors/vscode/src/commands.ts | 38 | ||||
| -rw-r--r-- | editors/vscode/src/debug.ts | 2 |
2 files changed, 30 insertions, 10 deletions
diff --git a/editors/vscode/src/commands.ts b/editors/vscode/src/commands.ts index 2035f49..69850ce 100644 --- a/editors/vscode/src/commands.ts +++ b/editors/vscode/src/commands.ts @@ -1,13 +1,10 @@ import * as vscode from 'vscode'; -import * as lc from 'vscode-languageclient'; import { Ctx, Cmd } from './ctx'; -import { execFile, spawnSync } from 'child_process'; -import { LanguageClient } from 'vscode-languageclient/node'; +import { execFile } from 'child_process'; import path = require('path'); +import fs = require('fs'); import { getDebugConfiguration } from './debug'; -import { getPathForExecutable } from './toolchain'; -import { promises as fs, PathLike, constants, writeFileSync} from "fs"; export function runDebugTest(ctx: Ctx): Cmd { return async(debugConfig: any) => { @@ -44,19 +41,40 @@ export function runDebugTest(ctx: Ctx): Cmd { } }); - const executableName = path.join(workspaceFolder, pkg); - odinExecution.on("exit", (code) => { if(code !== 0) { throw Error("Odin test failed!"); } - vscode.debug.startDebugging(undefined, getDebugConfiguration(ctx.config, executableName)).then(r => console.log("Result", r)); + const possibleExecutables = [ + path.join(workspaceFolder, pkg), + path.join(workspaceFolder, pkg) + '.bin' + ]; + + let promises : Promise<string | null>[] = []; + possibleExecutables.forEach((executable) => { + promises.push(new Promise<string | null>((resolve) => { + fs.stat(executable, (exists) => { + resolve(exists === null ? executable : null); + }); + })); + }); + + Promise.all(promises).then(results => { + let found = false; + results.forEach((r) => { + if (r !== null && !found) { + found = true; + vscode.debug.startDebugging(undefined, getDebugConfiguration(ctx.config, r)).then(r => console.log("Result", r)); + } + }); + if (!found) { + throw Error("Not possible to find executable, candidates are: " + possibleExecutables); + } + }); }); - }; - } export function runTest(ctx: Ctx): Cmd { diff --git a/editors/vscode/src/debug.ts b/editors/vscode/src/debug.ts index 7cf4b89..f386be0 100644 --- a/editors/vscode/src/debug.ts +++ b/editors/vscode/src/debug.ts @@ -42,6 +42,7 @@ function getLldbDebugConfig(executable: string): vscode.DebugConfiguration { request: "launch", name: "test debug", program: executable, + cwd: vscode.workspace.workspaceFolders?.[0].uri.path }; } @@ -51,5 +52,6 @@ function getCppvsDebugConfig(executable: string): vscode.DebugConfiguration { request: "launch", name: "test debug", program: executable, + cwd: vscode.workspace.workspaceFolders?.[0].uri.path }; }
\ No newline at end of file |