diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/src/debug.ts | 12 | ||||
-rw-r--r-- | editors/code/src/toolchain.ts | 21 |
2 files changed, 31 insertions, 2 deletions
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'; | |||
3 | import * as path from 'path'; | 3 | import * as path from 'path'; |
4 | import * as ra from './lsp_ext'; | 4 | import * as ra from './lsp_ext'; |
5 | 5 | ||
6 | import { Cargo } from './toolchain'; | 6 | import { Cargo, sysrootForDir as getSysroot } from './toolchain'; |
7 | import { Ctx } from "./ctx"; | 7 | import { Ctx } from "./ctx"; |
8 | import { prepareEnv } from "./run"; | 8 | import { prepareEnv } from "./run"; |
9 | 9 | ||
@@ -104,7 +104,15 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v | |||
104 | 104 | ||
105 | const executable = await getDebugExecutable(runnable); | 105 | const executable = await getDebugExecutable(runnable); |
106 | const env = prepareEnv(runnable, ctx.config.runnableEnv); | 106 | const env = prepareEnv(runnable, ctx.config.runnableEnv); |
107 | const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, debugOptions.sourceFileMap); | 107 | let sourceFileMap = debugOptions.sourceFileMap; |
108 | if ( !sourceFileMap || Object.keys(sourceFileMap).length === 0 ) { | ||
109 | // let's try to use the default toolchain | ||
110 | const sysroot = await getSysroot(wsFolder); | ||
111 | const rustlib_src = path.normalize(sysroot + "/lib/rustlib/src/rust"); | ||
112 | sourceFileMap = { "/rustc/*": rustlib_src }; | ||
113 | } | ||
114 | |||
115 | const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, sourceFileMap); | ||
108 | if (debugConfig.type in debugOptions.engineSettings) { | 116 | if (debugConfig.type in debugOptions.engineSettings) { |
109 | const settingsMap = (debugOptions.engineSettings as any)[debugConfig.type]; | 117 | const settingsMap = (debugOptions.engineSettings as any)[debugConfig.type]; |
110 | for (var key in settingsMap) { | 118 | for (var key in settingsMap) { |
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index a5dc3cf0c..b746da1d9 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts | |||
@@ -121,6 +121,27 @@ export class Cargo { | |||
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | /** Mirrors `project_model::sysroot::discover_sysroot_dir()` implementation*/ | ||
125 | export function sysrootForDir(dir: string): Promise<string> { | ||
126 | const rustc_path = getPathForExecutable("rustc"); | ||
127 | |||
128 | return new Promise((resolve, reject) => { | ||
129 | cp.exec(`${rustc_path} --print sysroot`, { cwd: dir }, (err, stdout, stderr) => { | ||
130 | if (err) { | ||
131 | reject(err); | ||
132 | return; | ||
133 | } | ||
134 | |||
135 | if (stderr) { | ||
136 | reject(new Error(stderr)); | ||
137 | return; | ||
138 | } | ||
139 | |||
140 | resolve(stdout.trimEnd()); | ||
141 | }); | ||
142 | }); | ||
143 | } | ||
144 | |||
124 | /** Mirrors `toolchain::cargo()` implementation */ | 145 | /** Mirrors `toolchain::cargo()` implementation */ |
125 | export function cargoPath(): string { | 146 | export function cargoPath(): string { |
126 | return getPathForExecutable("cargo"); | 147 | return getPathForExecutable("cargo"); |