Skip to content

Visual Studio Code, rebuilt in Rust

Rust

fix(windows): build the exthost bundle and VSCODE_SRC paths on Windows

rokarturde2188b89b0e
diff --git a/native/vscode_src.rs b/native/vscode_src.rs
index a5403b0b7ef..e300e0fce9e 100644
--- a/native/vscode_src.rs
+++ b/native/vscode_src.rs
@@ -6,6 +6,11 @@ fn emit_vscode_src() -> std::path::PathBuf {
let repo = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../..");
let src = repo.join(std::env::var_os("VSCODE_SRC").unwrap_or_else(|| "upstream".into()));
let src = src.canonicalize().unwrap_or_else(|error| panic!("VSCODE_SRC {}: {error} (README.md: clone VS Code into upstream/)", src.display()));
+ // Windows canonicalizes to `\\?\C:\...`, where the `/` of include_str!(concat!(env!("VSCODE_SRC"), "/src/...")) is no separator.
+ let src = match src.to_str().and_then(|path| path.strip_prefix(r"\\?\")) {
+ Some(path) => std::path::PathBuf::from(path),
+ None => src,
+ };
println!("cargo::rustc-env=VSCODE_SRC={}", src.display());
src
}
diff --git a/port/tools/build-exthost b/port/tools/build-exthost
index c527adbfc77..2984be31579 100755
--- a/port/tools/build-exthost
+++ b/port/tools/build-exthost
@@ -31,12 +31,13 @@ for (const [marker, value] of [['BUILD_INSERT_PRODUCT_CONFIGURATION', product],
writeFileSync(meta, source);
// The bundle keeps its packages external; Node and Bun resolve them from out-exthost/node_modules.
-symlinkSync(join(vscodeSrc, 'node_modules'), 'out-exthost/node_modules');
+// A junction on Windows: a directory symlink there needs Developer Mode or an administrator; elsewhere the type is ignored.
+symlinkSync(join(vscodeSrc, 'node_modules'), 'out-exthost/node_modules', 'junction');
// The host loads AMD modules (iconv-lite-umd, jschardet) from node_modules beside out-exthost (network.ts
// `nodeModulesPath`), where package-app puts them in the app. A real folder there (a Studio mirror's install from
// before the split, milestone 22) stays.
if (!lstatSync('node_modules', { throwIfNoEntry: false })?.isDirectory()) {
rmSync('node_modules', { force: true });
- symlinkSync(join(vscodeSrc, 'node_modules'), 'node_modules');
+ symlinkSync(join(vscodeSrc, 'node_modules'), 'node_modules', 'junction');
}
await $`bun build ${build}/src/bootstrap-exthost.ts --target=node --format=esm --packages=external --outdir out-exthost`;