pass Cargo errors to the Debug output channel

This commit is contained in:
vsrs 2020-04-30 15:25:04 +03:00
parent 73a1947d19
commit eb6f9c23e1
3 changed files with 19 additions and 7 deletions

View file

@ -399,7 +399,7 @@
"default": "auto", "default": "auto",
"description": "Preffered debug engine.", "description": "Preffered debug engine.",
"markdownEnumDescriptions": [ "markdownEnumDescriptions": [
"First try to use [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb), if it's not installed use [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).", "First try to use [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb), if it's not installed try to use [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).",
"Use [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)", "Use [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)",
"Use [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)" "Use [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)"
] ]

View file

@ -1,5 +1,6 @@
import * as cp from 'child_process'; import * as cp from 'child_process';
import * as readline from 'readline'; import * as readline from 'readline';
import { OutputChannel } from 'vscode';
interface CompilationArtifact { interface CompilationArtifact {
fileName: string; fileName: string;
@ -10,10 +11,13 @@ interface CompilationArtifact {
export class Cargo { export class Cargo {
rootFolder: string; rootFolder: string;
env?: { [key: string]: string }; env?: Record<string, string>;
output: OutputChannel;
public constructor(cargoTomlFolder: string) { public constructor(cargoTomlFolder: string, output: OutputChannel, env: Record<string, string> | undefined = undefined) {
this.rootFolder = cargoTomlFolder; this.rootFolder = cargoTomlFolder;
this.output = output;
this.env = env;
} }
public async artifactsFromArgs(cargoArgs: string[]): Promise<CompilationArtifact[]> { public async artifactsFromArgs(cargoArgs: string[]): Promise<CompilationArtifact[]> {
@ -34,14 +38,17 @@ export class Cargo {
}) })
} }
} }
else if( message.reason == 'compiler-message') {
this.output.append(message.message.rendered);
}
}, },
_stderr => { stderr => {
// TODO: to output this.output.append(stderr);
} }
); );
} }
catch (err) { catch (err) {
// TODO: to output this.output.show(true);
throw new Error(`Cargo invocation has failed: ${err}`); throw new Error(`Cargo invocation has failed: ${err}`);
} }

View file

@ -78,10 +78,15 @@ function getLldbDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, s
}; };
} }
const debugOutput = vscode.window.createOutputChannel("Debug");
async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> { async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> {
let cargo = new Cargo(config.cwd || '.'); debugOutput.clear();
let cargo = new Cargo(config.cwd || '.', debugOutput);
let executable = await cargo.executableFromArgs(config.args, config.extraArgs); let executable = await cargo.executableFromArgs(config.args, config.extraArgs);
// if we are here, there were no compilation errors.
return { return {
type: (os.platform() === "win32") ? "cppvsdbg" : 'cppdbg', type: (os.platform() === "win32") ? "cppvsdbg" : 'cppdbg',
request: "launch", request: "launch",