|
| 1 | +#!/bin/sh |
| 2 | +set -ex |
| 3 | + |
| 4 | +. ./get-sysroot.sh |
| 5 | + |
| 6 | +if [ "$SYSROOT_ARCH" -a ! -d ./"$WITH_SYSROOT/lib" ]; then |
| 7 | + ./build/linux/sysroot_scripts/sysroot_creator.py build "$SYSROOT_ARCH" |
| 8 | +fi |
| 9 | + |
| 10 | +if [ "$OPENWRT_FLAGS" ]; then |
| 11 | + ./get-openwrt.sh |
| 12 | +fi |
| 13 | + |
| 14 | +# Clang |
| 15 | +# See src/tools/clang/scripts/update.py |
| 16 | +case "$host_os" in |
| 17 | + linux) WITH_CLANG=Linux_x64;; |
| 18 | + win) WITH_CLANG=Win;; |
| 19 | + mac) WITH_CLANG=Mac;; |
| 20 | +esac |
| 21 | +if [ "$host_os" = mac -a "$host_cpu" = arm64 ]; then |
| 22 | + WITH_CLANG=Mac_arm64 |
| 23 | +fi |
| 24 | +mkdir -p third_party/llvm-build/Release+Asserts |
| 25 | +cd tools/clang/scripts |
| 26 | +CLANG_REVISION=$($PYTHON -c 'import update; print(update.PACKAGE_VERSION)') |
| 27 | +cd - |
| 28 | +echo $CLANG_REVISION >third_party/llvm-build/Release+Asserts/cr_build_revision |
| 29 | +if [ ! -d third_party/llvm-build/Release+Asserts/bin ]; then |
| 30 | + mkdir -p third_party/llvm-build/Release+Asserts |
| 31 | + clang_path="clang-$CLANG_REVISION.tar.xz" |
| 32 | + clang_url="https://commondatastorage.googleapis.com/chromium-browser-clang/$WITH_CLANG/$clang_path" |
| 33 | + curl "$clang_url" | tar xJf - -C third_party/llvm-build/Release+Asserts |
| 34 | +fi |
| 35 | + |
| 36 | +# sccache |
| 37 | +if [ "$host_os" = win -a ! -f ~/.cargo/bin/sccache.exe ]; then |
| 38 | + sccache_url="https://github.com/mozilla/sccache/releases/download/0.2.12/sccache-0.2.12-x86_64-pc-windows-msvc.tar.gz" |
| 39 | + mkdir -p ~/.cargo/bin |
| 40 | + curl -L "$sccache_url" | tar xzf - --strip=1 -C ~/.cargo/bin |
| 41 | +fi |
| 42 | + |
| 43 | +# GN |
| 44 | +# See src/DEPS |
| 45 | +case "$host_os" in |
| 46 | + linux) WITH_GN=linux-amd64;; |
| 47 | + win) WITH_GN=windows-amd64;; |
| 48 | + mac) WITH_GN=mac-amd64;; |
| 49 | +esac |
| 50 | +if [ "$host_os" = mac -a "$host_cpu" = arm64 ]; then |
| 51 | + WITH_GN=mac-arm64 |
| 52 | +fi |
| 53 | +if [ ! -f gn/out/gn ]; then |
| 54 | + gn_version=$(grep "'gn_version':" DEPS | cut -d"'" -f4) |
| 55 | + mkdir -p gn/out |
| 56 | + curl -L "https://chrome-infra-packages.appspot.com/dl/gn/gn/$WITH_GN/+/$gn_version" -o gn.zip |
| 57 | + unzip gn.zip -d gn/out |
| 58 | + rm gn.zip |
| 59 | +fi |
| 60 | + |
| 61 | +# See src/build/config/compiler/pgo/BUILD.gn |
| 62 | +case "$target_os" in |
| 63 | + win) |
| 64 | + case "$target_cpu" in |
| 65 | + arm64) WITH_PGO=win-arm64;; |
| 66 | + x64) WITH_PGO=win64;; |
| 67 | + *) WITH_PGO=win32;; |
| 68 | + esac |
| 69 | + ;; |
| 70 | + mac) |
| 71 | + case "$target_cpu" in |
| 72 | + arm64) WITH_PGO=mac-arm;; |
| 73 | + *) WITH_PGO=mac;; |
| 74 | + esac |
| 75 | + ;; |
| 76 | + linux|openwrt) |
| 77 | + WITH_PGO=linux |
| 78 | + ;; |
| 79 | + android) |
| 80 | + case "$target_cpu" in |
| 81 | + arm64) WITH_PGO=android-arm64;; |
| 82 | + *) WITH_PGO=android-arm32;; |
| 83 | + esac |
| 84 | + ;; |
| 85 | +esac |
| 86 | +if [ "$WITH_PGO" ]; then |
| 87 | + PGO_PATH=$(cat chrome/build/$WITH_PGO.pgo.txt) |
| 88 | +fi |
| 89 | +if [ "$WITH_PGO" -a ! -f chrome/build/pgo_profiles/"$PGO_PATH" ]; then |
| 90 | + mkdir -p chrome/build/pgo_profiles |
| 91 | + cd chrome/build/pgo_profiles |
| 92 | + curl --limit-rate 10M -LO "https://storage.googleapis.com/chromium-optimization-profiles/pgo_profiles/$PGO_PATH" |
| 93 | + cd ../../.. |
| 94 | +fi |
| 95 | + |
| 96 | +if [ "$target_os" = android -a ! -d third_party/android_toolchain/ndk ]; then |
| 97 | + # https://dl.google.com/android/repository/android-ndk-r25c-linux.zip |
| 98 | + android_ndk_version=$(grep 'default_android_ndk_version = ' build/config/android/config.gni | cut -d'"' -f2) |
| 99 | + curl -LO https://dl.google.com/android/repository/android-ndk-$android_ndk_version-linux.zip |
| 100 | + unzip android-ndk-$android_ndk_version-linux.zip |
| 101 | + mkdir -p third_party/android_toolchain/ndk |
| 102 | + cd android-ndk-$android_ndk_version |
| 103 | + cp -r --parents sources/android/cpufeatures ../third_party/android_toolchain/ndk |
| 104 | + cp -r --parents toolchains/llvm/prebuilt ../third_party/android_toolchain/ndk |
| 105 | + cd .. |
| 106 | + cd third_party/android_toolchain/ndk |
| 107 | + find toolchains -type f -regextype egrep \! -regex \ |
| 108 | + '.*(lib(atomic|gcc|gcc_real|compiler_rt-extras|android_support|unwind).a|crt.*o|lib(android|c|dl|log|m).so|usr/local.*|usr/include.*)' -delete |
| 109 | + # Works around https://github.com/android/ndk/issues/2082 |
| 110 | + # .../android/hardware_buffer.h:322:42: error: expression is not an integral constant expression |
| 111 | + # 322 | AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1UL << 32, |
| 112 | + # .../android/hardware_buffer.h:322:46: note: shift count 32 >= width of type 'unsigned long' (32 bits) |
| 113 | + # 322 | AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1UL << 32, |
| 114 | + sed -i 's/AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1UL /AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1ULL /' toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h |
| 115 | + cd - |
| 116 | + rm -rf android-ndk-$android_ndk_version android-ndk-$android_ndk_version-linux.zip |
| 117 | +fi |
0 commit comments