build_cli.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env bash
  2. set -ex
  3. cd cli
  4. export CARGO_NET_GIT_FETCH_WITH_CLI="true"
  5. export VSCODE_CLI_APP_NAME="$( echo "${APP_NAME}" | awk '{print tolower($0)}' )"
  6. export VSCODE_CLI_BINARY_NAME="$( node -p "require(\"../product.json\").serverApplicationName" )"
  7. TUNNEL_APPLICATION_NAME="$( node -p "require(\"../product.json\").tunnelApplicationName" )"
  8. NAME_SHORT="$( node -p "require(\"../product.json\").nameShort" )"
  9. npm pack @vscode/openssl-prebuilt@0.0.11
  10. mkdir openssl
  11. tar -xvzf vscode-openssl-prebuilt-0.0.11.tgz --strip-components=1 --directory=openssl
  12. if [[ "${OS_NAME}" == "osx" ]]; then
  13. if [[ "${VSCODE_ARCH}" == "arm64" ]]; then
  14. VSCODE_CLI_TARGET="aarch64-apple-darwin"
  15. else
  16. VSCODE_CLI_TARGET="x86_64-apple-darwin"
  17. fi
  18. export OPENSSL_LIB_DIR="$( pwd )/openssl/out/${VSCODE_ARCH}-osx/lib"
  19. export OPENSSL_INCLUDE_DIR="$( pwd )/openssl/out/${VSCODE_ARCH}-osx/include"
  20. cargo build --release --target "${VSCODE_CLI_TARGET}" --bin=code
  21. cp "target/${VSCODE_CLI_TARGET}/release/code" "../../VSCode-darwin-${VSCODE_ARCH}/${NAME_SHORT}.app/Contents/Resources/app/bin/${TUNNEL_APPLICATION_NAME}"
  22. elif [[ "${OS_NAME}" == "windows" ]]; then
  23. if [[ "${VSCODE_ARCH}" == "arm64" ]]; then
  24. VSCODE_CLI_TARGET="aarch64-pc-windows-msvc"
  25. export VSCODE_CLI_RUST="-C target-feature=+crt-static -Clink-args=/guard:cf -Clink-args=/CETCOMPAT:NO"
  26. else
  27. VSCODE_CLI_TARGET="x86_64-pc-windows-msvc"
  28. export VSCODE_CLI_RUSTFLAGS="-Ctarget-feature=+crt-static -Clink-args=/guard:cf -Clink-args=/CETCOMPAT"
  29. fi
  30. export VSCODE_CLI_CFLAGS="/guard:cf /Qspectre"
  31. export OPENSSL_LIB_DIR="$( pwd )/openssl/out/${VSCODE_ARCH}-windows-static/lib"
  32. export OPENSSL_INCLUDE_DIR="$( pwd )/openssl/out/${VSCODE_ARCH}-windows-static/include"
  33. rustup target add "${VSCODE_CLI_TARGET}"
  34. cargo build --release --target "${VSCODE_CLI_TARGET}" --bin=code
  35. cp "target/${VSCODE_CLI_TARGET}/release/code.exe" "../../VSCode-win32-${VSCODE_ARCH}/bin/${TUNNEL_APPLICATION_NAME}.exe"
  36. else
  37. export OPENSSL_LIB_DIR="$( pwd )/openssl/out/${VSCODE_ARCH}-linux/lib"
  38. export OPENSSL_INCLUDE_DIR="$( pwd )/openssl/out/${VSCODE_ARCH}-linux/include"
  39. export VSCODE_SYSROOT_DIR="../.build/sysroots"
  40. if [[ "${VSCODE_ARCH}" == "arm64" ]]; then
  41. VSCODE_CLI_TARGET="aarch64-unknown-linux-gnu"
  42. export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
  43. export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
  44. export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
  45. export PKG_CONFIG_ALLOW_CROSS=1
  46. sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu crossbuild-essential-arm64
  47. elif [[ "${VSCODE_ARCH}" == "armhf" ]]; then
  48. VSCODE_CLI_TARGET="armv7-unknown-linux-gnueabihf"
  49. export OPENSSL_LIB_DIR="$( pwd )/openssl/out/arm-linux/lib"
  50. export OPENSSL_INCLUDE_DIR="$( pwd )/openssl/out/arm-linux/include"
  51. export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
  52. export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
  53. export CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
  54. export PKG_CONFIG_ALLOW_CROSS=1
  55. sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf crossbuild-essential-armhf
  56. elif [[ "${VSCODE_ARCH}" == "x64" ]]; then
  57. VSCODE_CLI_TARGET="x86_64-unknown-linux-gnu"
  58. fi
  59. if [[ -n "${VSCODE_CLI_TARGET}" ]]; then
  60. rustup target add "${VSCODE_CLI_TARGET}"
  61. cargo build --release --target "${VSCODE_CLI_TARGET}" --bin=code
  62. cp "target/${VSCODE_CLI_TARGET}/release/code" "../../VSCode-linux-${VSCODE_ARCH}/bin/${TUNNEL_APPLICATION_NAME}"
  63. fi
  64. fi
  65. cd ..