feat: cli binary (#2313)

This commit is contained in:
Baptiste Augrain
2025-04-07 16:24:12 +02:00
parent bbc892183f
commit 6c5a8eb3fb
9 changed files with 509 additions and 173 deletions

61
build_cli.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/usr/bin/env bash
set -ex
cd cli
export CARGO_NET_GIT_FETCH_WITH_CLI="true"
export VSCODE_CLI_APP_NAME="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
export VSCODE_CLI_BINARY_NAME="$( node -p "require(\"../product.json\").serverApplicationName" )"
TUNNEL_APPLICATION_NAME="$( node -p "require(\"../product.json\").tunnelApplicationName" )"
NAME_SHORT="$( node -p "require(\"../product.json\").nameShort" )"
if [[ "${OS_NAME}" == "osx" ]]; then
if [[ "${VSCODE_ARCH}" == "arm64" ]]; then
VSCODE_CLI_TARGET="aarch64-apple-darwin"
else
VSCODE_CLI_TARGET="x86_64-apple-darwin"
fi
cargo build --release --target "${VSCODE_CLI_TARGET}" --bin=code
cp "target/${VSCODE_CLI_TARGET}/release/code" "../../VSCode-darwin-${VSCODE_ARCH}/${NAME_SHORT}.app/Contents/Resources/app/bin/${TUNNEL_APPLICATION_NAME}"
elif [[ "${OS_NAME}" == "windows" ]]; then
if [[ "${VSCODE_ARCH}" == "arm64" ]]; then
VSCODE_CLI_TARGET="aarch64-pc-windows-msvc"
export VSCODE_CLI_RUST="-C target-feature=+crt-static -Clink-args=/guard:cf -Clink-args=/CETCOMPAT:NO"
else
VSCODE_CLI_TARGET="x86_64-pc-windows-msvc"
export VSCODE_CLI_RUSTFLAGS="-Ctarget-feature=+crt-static -Clink-args=/guard:cf -Clink-args=/CETCOMPAT"
fi
export VSCODE_CLI_CFLAGS="/guard:cf /Qspectre"
rustup target add x86_64-pc-windows-msvc
cargo build --release --target "${VSCODE_CLI_TARGET}" --bin=code
cp "target/${VSCODE_CLI_TARGET}/release/code.exe" "../../VSCode-win32-${VSCODE_ARCH}/bin/${TUNNEL_APPLICATION_NAME}.exe"
else
if [[ "${VSCODE_ARCH}" == "arm64" ]]; then
VSCODE_CLI_TARGET="aarch64-unknown-linux-gnu"
elif [[ "${VSCODE_ARCH}" == "armhf" ]]; then
VSCODE_CLI_TARGET="armv7-unknown-linux-gnueabihf"
elif [[ "${VSCODE_ARCH}" == "x64" ]]; then
VSCODE_CLI_TARGET="x86_64-unknown-linux-gnu"
elif [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
VSCODE_CLI_TARGET="powerpc64-unknown-linux-gnu"
elif [[ "${VSCODE_ARCH}" == "riscv64" ]]; then
VSCODE_CLI_TARGET="riscv64-unknown-linux-gnu"
elif [[ "${VSCODE_ARCH}" == "loong64" ]]; then
VSCODE_CLI_TARGET="loongarch64-unknown-linux-gnu"
fi
if [[ -n "${VSCODE_CLI_TARGET}" ]]; then
cargo build --release --target "${VSCODE_CLI_TARGET}" --bin=code
cp "target/${VSCODE_CLI_TARGET}/release/code" "../../VSCode-linux-${VSCODE_ARCH}/bin/${TUNNEL_APPLICATION_NAME}"
fi
fi
cd ..