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/toolchain.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'editors/code/src/toolchain.ts') 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 { } } +/** Mirrors `project_model::sysroot::discover_sysroot_dir()` implementation*/ +export function sysrootForDir(dir: string): 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 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/toolchain.ts | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'editors/code/src/toolchain.ts') diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index b746da1d9..5725bcafe 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import * as fs from 'fs'; import * as readline from 'readline'; import { OutputChannel } from 'vscode'; -import { log, memoize } from './util'; +import { execute, log, memoize } from './util'; interface CompilationArtifact { fileName: string; @@ -122,24 +122,11 @@ export class Cargo { } /** Mirrors `project_model::sysroot::discover_sysroot_dir()` implementation*/ -export function sysrootForDir(dir: string): 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; - } +export function getSysroot(dir: string): Promise { + const rustcPath = getPathForExecutable("rustc"); - resolve(stdout.trimEnd()); - }); - }); + // do not memoize the result because the toolchain may change between runs + return execute(`${rustcPath} --print sysroot`, { cwd: dir }); } /** Mirrors `toolchain::cargo()` implementation */ -- cgit v1.2.3 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/toolchain.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'editors/code/src/toolchain.ts') 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 { 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"); -- cgit v1.2.3