package_linux_bin.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC1091
  3. set -ex
  4. if [[ "${CI_BUILD}" == "no" ]]; then
  5. exit 1
  6. fi
  7. tar -xzf ./vscode.tar.gz
  8. chown -R root:root vscode
  9. cd vscode || { echo "'vscode' dir not found"; exit 1; }
  10. export VSCODE_PLATFORM='linux'
  11. export VSCODE_SKIP_NODE_VERSION_CHECK=1
  12. export VSCODE_SYSROOT_PREFIX='-glibc-2.17'
  13. if [[ "${VSCODE_ARCH}" == "arm64" || "${VSCODE_ARCH}" == "armhf" ]]; then
  14. export VSCODE_SKIP_SYSROOT=1
  15. export USE_GNUPP2A=1
  16. elif [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
  17. export VSCODE_SYSROOT_REPOSITORY='VSCodium/vscode-linux-build-agent'
  18. export VSCODE_SYSROOT_VERSION='20240129-253798'
  19. export VSCODE_SYSROOT_PREFIX='-glibc-2.28'
  20. export USE_GNUPP2A=1
  21. elif [[ "${VSCODE_ARCH}" == "riscv64" ]]; then
  22. export VSCODE_ELECTRON_REPOSITORY='riscv-forks/electron-riscv-releases'
  23. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  24. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  25. export VSCODE_SKIP_SETUPENV=1
  26. elif [[ "${VSCODE_ARCH}" == "loong64" ]]; then
  27. export VSCODE_ELECTRON_REPOSITORY='darkyzhou/electron-loong64'
  28. export ELECTRON_SKIP_BINARY_DOWNLOAD=1
  29. export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
  30. export VSCODE_SKIP_SETUPENV=1
  31. fi
  32. if [[ -f "../electron_linux_${VSCODE_ARCH}.sh" ]]; then
  33. # add newline at the end of the file
  34. echo "" >> build/checksums/electron.txt
  35. if [[ -f "../electron_linux_${VSCODE_ARCH}.sha256sums" ]]; then
  36. cat "../electron_linux_${VSCODE_ARCH}.sha256sums" >> build/checksums/electron.txt
  37. fi
  38. # shellcheck disable=SC1090
  39. source "../electron_linux_${VSCODE_ARCH}.sh"
  40. if [[ "${ELECTRON_VERSION}" != "$( yarn config get target )" ]]; then
  41. # Fail the pipeline if electron target doesn't match what is used.
  42. echo "Electron ${VSCODE_ARCH} binary version doesn't match target electron version!"
  43. echo "Releases available at: https://github.com/${VSCODE_ELECTRON_REPOSITORY}/releases"
  44. exit 1
  45. fi
  46. fi
  47. if [[ -d "../patches/linux/client/" ]]; then
  48. for file in "../patches/linux/client/"*.patch; do
  49. if [[ -f "${file}" ]]; then
  50. echo applying patch: "${file}";
  51. if ! git apply --ignore-whitespace "${file}"; then
  52. echo failed to apply patch "${file}" >&2
  53. exit 1
  54. fi
  55. fi
  56. done
  57. fi
  58. if [[ -n "${USE_GNUPP2A}" ]]; then
  59. INCLUDES=$(cat <<EOF
  60. {
  61. "target_defaults": {
  62. "conditions": [
  63. ["OS=='linux'", {
  64. 'cflags_cc!': [ '-std=gnu++20' ],
  65. 'cflags_cc': [ '-std=gnu++2a' ],
  66. }]
  67. ]
  68. }
  69. }
  70. EOF
  71. )
  72. if [ ! -d "$HOME/.gyp" ]; then
  73. mkdir -p "$HOME/.gyp"
  74. fi
  75. echo "${INCLUDES}" > "$HOME/.gyp/include.gypi"
  76. fi
  77. for i in {1..5}; do # try 5 times
  78. npm ci --prefix build && break
  79. if [[ $i == 3 ]]; then
  80. echo "Npm install failed too many times" >&2
  81. exit 1
  82. fi
  83. echo "Npm install failed $i, trying again..."
  84. done
  85. if [[ -z "${VSCODE_SKIP_SETUPENV}" ]]; then
  86. if [[ -n "${VSCODE_SKIP_SYSROOT}" ]]; then
  87. source ./build/azure-pipelines/linux/setup-env.sh --skip-sysroot
  88. else
  89. source ./build/azure-pipelines/linux/setup-env.sh
  90. fi
  91. fi
  92. for i in {1..5}; do # try 5 times
  93. npm ci && break
  94. if [[ $i -eq 3 ]]; then
  95. echo "Npm install failed too many times" >&2
  96. exit 1
  97. fi
  98. echo "Npm install failed $i, trying again..."
  99. done
  100. node build/azure-pipelines/distro/mixin-npm
  101. yarn gulp "vscode-linux-${VSCODE_ARCH}-min-ci"
  102. if [[ -f "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" ]]; then
  103. bash "../ripgrep_${VSCODE_PLATFORM}_${VSCODE_ARCH}.sh" "../VSCode-linux-${VSCODE_ARCH}/resources/app/node_modules"
  104. fi
  105. find "../VSCode-linux-${VSCODE_ARCH}" -print0 | xargs -0 touch -c
  106. cd ..