7643: Automatically detect the rustc-src directory (fixes #3517) r=matklad a=bnjbvr

If the configured rustcSource was not set, then try to automatically
detect a source for the sysroot rustc directory.

I wasn't sure how to do it in the case of the project.json file, though.

7663: Tolerate spaces in nix binary patching r=matklad a=CertainLach

If path to original file contains space (I.e on code insiders, where
default data directory is ~/Code - Insiders/), then there is syntax
error evaluating src arg.

Instead pass path as str, and coerce to path back in nix expression

Co-authored-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: Yaroslav Bolyukin <iam@lach.pw>
This commit is contained in:
bors[bot] 2021-02-14 15:42:07 +00:00 committed by GitHub
commit d50a37d3aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 70 additions and 23 deletions

View file

@ -707,7 +707,7 @@
}
},
"rust-analyzer.rustcSource": {
"markdownDescription": "Path to the rust compiler sources, for usage in rustc_private projects.",
"markdownDescription": "Path to the rust compiler sources, for usage in rustc_private projects, or \"discover\" to try to automatically find it.",
"default": null,
"type": [
"null",

View file

@ -246,10 +246,10 @@ async function patchelf(dest: PathLike): Promise<void> {
},
async (progress, _) => {
const expression = `
{src, pkgs ? import <nixpkgs> {}}:
{srcStr, pkgs ? import <nixpkgs> {}}:
pkgs.stdenv.mkDerivation {
name = "rust-analyzer";
inherit src;
src = /. + srcStr;
phases = [ "installPhase" "fixupPhase" ];
installPhase = "cp $src $out";
fixupPhase = ''
@ -262,7 +262,7 @@ async function patchelf(dest: PathLike): Promise<void> {
await fs.rename(dest, origFile);
progress.report({ message: "Patching executable", increment: 20 });
await new Promise((resolve, reject) => {
const handle = exec(`nix-build -E - --arg src '${origFile}' -o ${dest}`,
const handle = exec(`nix-build -E - --argstr srcStr '${origFile}' -o '${dest}'`,
(err, stdout, stderr) => {
if (err != null) {
reject(Error(stderr));