From 8f781e782c7e16aa323672620753ec31526d2b90 Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 22 Apr 2021 15:27:56 +0300 Subject: Autodetect rust library source file map --- editors/code/src/debug.ts | 12 ++++++++++-- editors/code/src/toolchain.ts | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'editors') diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 3889a2773..fe8ec1be4 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -3,7 +3,7 @@ import * as vscode from 'vscode'; import * as path from 'path'; import * as ra from './lsp_ext'; -import { Cargo } from './toolchain'; +import { Cargo, sysrootForDir as getSysroot } from './toolchain'; import { Ctx } from "./ctx"; import { prepareEnv } from "./run"; @@ -104,7 +104,15 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise { + const rustc_path = getPathForExecutable("rustc"); + + return new Promise((resolve, reject) => { + cp.exec(`${rustc_path} --print sysroot`, { cwd: dir }, (err, stdout, stderr) => { + if (err) { + reject(err); + return; + } + + if (stderr) { + reject(new Error(stderr)); + return; + } + + resolve(stdout.trimEnd()); + }); + }); +} + /** Mirrors `toolchain::cargo()` implementation */ export function cargoPath(): string { return getPathForExecutable("cargo"); -- cgit v1.2.3