aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/toolchain.ts
diff options
context:
space:
mode:
authorvsrs <[email protected]>2021-04-22 13:27:56 +0100
committervsrs <[email protected]>2021-04-22 13:27:56 +0100
commit8f781e782c7e16aa323672620753ec31526d2b90 (patch)
treeacc48eaf35c2794483c9c95591357b71711883d7 /editors/code/src/toolchain.ts
parentd1c9bd134df23aadc7d3fea7907269d841db9063 (diff)
Autodetect rust library source file map
Diffstat (limited to 'editors/code/src/toolchain.ts')
-rw-r--r--editors/code/src/toolchain.ts21
1 files changed, 21 insertions, 0 deletions
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*/
125export 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 */
125export function cargoPath(): string { 146export function cargoPath(): string {
126 return getPathForExecutable("cargo"); 147 return getPathForExecutable("cargo");