diff options
-rw-r--r-- | editors/code/src/debug.ts | 6 | ||||
-rw-r--r-- | editors/code/src/toolchain.ts | 10 | ||||
-rw-r--r-- | editors/code/src/util.ts | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 8c6969dc6..830980f96 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, getSysroot } from './toolchain'; | 6 | import { Cargo, getRustcId, 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 | ||
@@ -107,9 +107,11 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v | |||
107 | let sourceFileMap = debugOptions.sourceFileMap; | 107 | let sourceFileMap = debugOptions.sourceFileMap; |
108 | if (sourceFileMap === "auto") { | 108 | if (sourceFileMap === "auto") { |
109 | // let's try to use the default toolchain | 109 | // let's try to use the default toolchain |
110 | const commitHash = await getRustcId(wsFolder); | ||
110 | const sysroot = await getSysroot(wsFolder); | 111 | const sysroot = await getSysroot(wsFolder); |
111 | const rustlib = path.normalize(sysroot + "/lib/rustlib/src/rust"); | 112 | const rustlib = path.normalize(sysroot + "/lib/rustlib/src/rust"); |
112 | sourceFileMap = { "/rustc/*": rustlib }; | 113 | sourceFileMap = {}; |
114 | sourceFileMap[`/rustc/${commitHash}/`] = rustlib; | ||
113 | } | 115 | } |
114 | 116 | ||
115 | const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, sourceFileMap); | 117 | const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, sourceFileMap); |
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index 5725bcafe..68826c478 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts | |||
@@ -129,6 +129,16 @@ export function getSysroot(dir: string): Promise<string> { | |||
129 | return execute(`${rustcPath} --print sysroot`, { cwd: dir }); | 129 | return execute(`${rustcPath} --print sysroot`, { cwd: dir }); |
130 | } | 130 | } |
131 | 131 | ||
132 | export async function getRustcId(dir: string): Promise<string> { | ||
133 | const rustcPath = getPathForExecutable("rustc"); | ||
134 | |||
135 | // do not memoize the result because the toolchain may change between runs | ||
136 | const data = await execute(`${rustcPath} -V -v`, { cwd: dir }); | ||
137 | const rx = /commit-hash:\s(.*)$/m.compile(); | ||
138 | |||
139 | return rx.exec(data)![1]; | ||
140 | } | ||
141 | |||
132 | /** Mirrors `toolchain::cargo()` implementation */ | 142 | /** Mirrors `toolchain::cargo()` implementation */ |
133 | export function cargoPath(): string { | 143 | export function cargoPath(): string { |
134 | return getPathForExecutable("cargo"); | 144 | return getPathForExecutable("cargo"); |
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index fc5c9e94e..56e0e439e 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts | |||
@@ -159,4 +159,4 @@ export function execute(command: string, options: ExecOptions): Promise<string> | |||
159 | resolve(stdout.trimEnd()); | 159 | resolve(stdout.trimEnd()); |
160 | }); | 160 | }); |
161 | }); | 161 | }); |
162 | } \ No newline at end of file | 162 | } |