From 1ebfe11730191e914dcf20297cdfdac5b7c297fc Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 22 Apr 2021 16:09:46 +0300 Subject: Add special `auto` value for `debug.sourceFileMap` --- editors/code/src/util.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'editors/code/src/util.ts') diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 53492a445c4..fc5c9e94e5e 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts @@ -1,7 +1,7 @@ import * as lc from "vscode-languageclient/node"; import * as vscode from "vscode"; import { strict as nativeAssert } from "assert"; -import { spawnSync } from "child_process"; +import { exec, ExecOptions, spawnSync } from "child_process"; import { inspect } from "util"; export function assert(condition: boolean, explanation: string): asserts condition { @@ -141,3 +141,22 @@ export function memoize(func: (this: TThis, ar return result; }; } + +/** Awaitable wrapper around `child_process.exec` */ +export function execute(command: string, options: ExecOptions): Promise { + return new Promise((resolve, reject) => { + exec(command, options, (err, stdout, stderr) => { + if (err) { + reject(err); + return; + } + + if (stderr) { + reject(new Error(stderr)); + return; + } + + resolve(stdout.trimEnd()); + }); + }); +} \ No newline at end of file -- cgit 1.4.1-3-g733a5 From 1b4197cb3520e4a71f118aac61a83bab1a6f5931 Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 22 Apr 2021 18:30:44 +0300 Subject: Use explicit rustc commit-hash Required for lldb on mac --- editors/code/src/debug.ts | 6 ++++-- editors/code/src/toolchain.ts | 10 ++++++++++ editors/code/src/util.ts | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'editors/code/src/util.ts') diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 8c6969dc670..830980f968c 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, getSysroot } from './toolchain'; +import { Cargo, getRustcId, getSysroot } from './toolchain'; import { Ctx } from "./ctx"; import { prepareEnv } from "./run"; @@ -107,9 +107,11 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise { return execute(`${rustcPath} --print sysroot`, { cwd: dir }); } +export async function getRustcId(dir: string): Promise { + const rustcPath = getPathForExecutable("rustc"); + + // do not memoize the result because the toolchain may change between runs + const data = await execute(`${rustcPath} -V -v`, { cwd: dir }); + const rx = /commit-hash:\s(.*)$/m.compile(); + + return rx.exec(data)![1]; +} + /** Mirrors `toolchain::cargo()` implementation */ export function cargoPath(): string { return getPathForExecutable("cargo"); diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index fc5c9e94e5e..56e0e439e98 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 resolve(stdout.trimEnd()); }); }); -} \ No newline at end of file +} -- cgit 1.4.1-3-g733a5