package_bin.sh 3.8 KB

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