Visual Studio Code, rebuilt in Rust
Rust
#!/bin/bash
# Runs a command (bash -c) in the Linux build container, at the Studio mirror root this script lives in.
# Called by port/tools/linux-build; on the Studio itself: port/tools/linux/run 'cd native && cargo gc check -p app'.
# The image is built from Dockerfile beside this script and tagged by its hash; older tags are deleted.
# Cargo's home (registry, git checkouts) and the Linux target dir are docker volumes, so the mirror's native/target is never touched.
set -euo pipefail
cd "$(dirname "$0")/../../.."
tag=$(shasum -a 256 port/tools/linux/Dockerfile | cut -c1-12)
if ! docker image inspect "vsrustium-linux:$tag" >/dev/null 2>&1; then
docker build -q -t "vsrustium-linux:$tag" port/tools/linux
docker images vsrustium-linux --format '{{.Tag}}' | { grep -vx "$tag" || true; } | xargs -I{} docker rmi -f vsrustium-linux:{}
fi
# The mirror and its upstream/ link's target (the Studio's reference checkout) sit at their Studio paths, so absolute
# links such as out-exthost/node_modules resolve.
ref=
[[ ! -L upstream ]] || ref=$(readlink upstream)
docker run --rm --init \
-v "$PWD:$PWD" -w "$PWD" \
${ref:+-v "$ref:$ref:ro"} \
-v vsrustium-linux-cargo:/cargo -e CARGO_HOME=/cargo \
-v vsrustium-linux-target:/target -e CARGO_TARGET_DIR=/target \
"vsrustium-linux:$tag" bash -c "$1"