From eb6f9c23e19eae9015bd859941c5e8cbf4622cba Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 30 Apr 2020 15:25:04 +0300 Subject: pass Cargo errors to the Debug output channel --- editors/code/src/cargo.ts | 17 ++++++++++++----- editors/code/src/commands/runnables.ts | 7 ++++++- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts index 5999187f4..857b84d59 100644 --- a/editors/code/src/cargo.ts +++ b/editors/code/src/cargo.ts @@ -1,5 +1,6 @@ import * as cp from 'child_process'; import * as readline from 'readline'; +import { OutputChannel } from 'vscode'; interface CompilationArtifact { fileName: string; @@ -10,10 +11,13 @@ interface CompilationArtifact { export class Cargo { rootFolder: string; - env?: { [key: string]: string }; + env?: Record; + output: OutputChannel; - public constructor(cargoTomlFolder: string) { + public constructor(cargoTomlFolder: string, output: OutputChannel, env: Record | undefined = undefined) { this.rootFolder = cargoTomlFolder; + this.output = output; + this.env = env; } public async artifactsFromArgs(cargoArgs: string[]): Promise { @@ -34,14 +38,17 @@ export class Cargo { }) } } + else if( message.reason == 'compiler-message') { + this.output.append(message.message.rendered); + } }, - _stderr => { - // TODO: to output + stderr => { + this.output.append(stderr); } ); } catch (err) { - // TODO: to output + this.output.show(true); throw new Error(`Cargo invocation has failed: ${err}`); } diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 9b0780650..e8035c7d2 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -78,10 +78,15 @@ function getLldbDebugConfig(config: ra.Runnable, sourceFileMap: Record): Promise { - let cargo = new Cargo(config.cwd || '.'); + debugOutput.clear(); + + let cargo = new Cargo(config.cwd || '.', debugOutput); let executable = await cargo.executableFromArgs(config.args, config.extraArgs); + // if we are here, there were no compilation errors. return { type: (os.platform() === "win32") ? "cppvsdbg" : 'cppdbg', request: "launch", -- cgit v1.2.3