This commit is contained in:
klzgrad 2023-11-05 17:35:16 +08:00
parent f80453e25f
commit c1d9cd1340
3 changed files with 141 additions and 106 deletions

View File

@ -21,6 +21,23 @@ fi
. ./get-sysroot.sh
# ccache
case "$host_os" in
linux|mac)
if which ccache >/dev/null 2>&1; then
export CCACHE_SLOPPINESS=time_macros
export CCACHE_BASEDIR="$PWD"
export CCACHE_CPP2=yes
CCACHE=ccache
fi
;;
win)
if [ -f "$HOME"/.cargo/bin/sccache* ]; then
export PATH="$PATH:$HOME/.cargo/bin"
CCACHE=sccache
fi
;;
esac
if [ "$CCACHE" ]; then
flags="$flags
cc_wrapper=\"$CCACHE\""
@ -59,16 +76,18 @@ if [ "$WITH_SYSROOT" ]; then
target_sysroot=\"//$WITH_SYSROOT\""
fi
if [ "$USE_AFDO" ]; then
flags="$flags"'
clang_sample_profile_path="//chrome/android/profiles/afdo.prof"'
fi
if [ "$ARCH" = "Darwin" ]; then
if [ "$host_os" = "mac" ]; then
flags="$flags"'
enable_dsyms=false'
fi
case "$EXTRA_FLAGS" in
*target_os=\"android\"*)
flags="$flags"'
is_high_end_android=true'
;;
esac
if [ "$target_cpu" = "mipsel" -o "$target_cpu" = "mips64el" ]; then
flags="$flags"'
use_thin_lto=false

View File

@ -11,6 +11,21 @@ if [ "$OPENWRT_FLAGS" ]; then
./get-openwrt.sh
fi
# Clang
# See src/tools/clang/scripts/update.py
case "$host_os" in
linux) WITH_CLANG=Linux_x64;;
win) WITH_CLANG=Win;;
mac) WITH_CLANG=Mac;;
esac
if [ "$host_os" = mac -a "$host_cpu" = arm64 ]; then
WITH_CLANG=Mac_arm64
fi
mkdir -p third_party/llvm-build/Release+Asserts
cd tools/clang/scripts
CLANG_REVISION=$($PYTHON -c 'import update; print(update.PACKAGE_VERSION)')
cd -
echo $CLANG_REVISION >third_party/llvm-build/Release+Asserts/cr_build_revision
if [ ! -d third_party/llvm-build/Release+Asserts/bin ]; then
mkdir -p third_party/llvm-build/Release+Asserts
clang_path="clang-$CLANG_REVISION.tgz"
@ -18,12 +33,59 @@ if [ ! -d third_party/llvm-build/Release+Asserts/bin ]; then
curl "$clang_url" | tar xzf - -C third_party/llvm-build/Release+Asserts
fi
if [ "$USE_AFDO" -a ! -f chrome/android/profiles/afdo.prof ]; then
afdo_path=$(cat chrome/android/profiles/newest.txt)
afdo_url="https://storage.googleapis.com/chromeos-prebuilt/afdo-job/llvm/$afdo_path"
curl "$afdo_url" | bzip2 -cd >chrome/android/profiles/afdo.prof
# sccache
if [ "$host_os" = win -a ! -f ~/.cargo/bin/sccache.exe ]; then
sccache_url="https://github.com/mozilla/sccache/releases/download/0.2.12/sccache-0.2.12-x86_64-pc-windows-msvc.tar.gz"
mkdir -p ~/.cargo/bin
curl -L "$sccache_url" | tar xzf - --strip=1 -C ~/.cargo/bin
fi
# GN
# See src/DEPS
case "$host_os" in
linux) WITH_GN=linux-amd64;;
win) WITH_GN=windows-amd64;;
mac) WITH_GN=mac-amd64;;
esac
if [ "$host_os" = mac -a "$host_cpu" = arm64 ]; then
WITH_GN=mac-arm64
fi
if [ ! -f gn/out/gn ]; then
gn_version=$(grep "'gn_version':" DEPS | cut -d"'" -f4)
mkdir -p gn/out
curl -L "https://chrome-infra-packages.appspot.com/dl/gn/gn/$WITH_GN/+/$gn_version" -o gn.zip
unzip gn.zip -d gn/out
rm gn.zip
fi
# See src/build/config/compiler/pgo/BUILD.gn
case "$target_os" in
win)
case "$target_cpu" in
arm64) WITH_PGO=win-arm64;;
x64) WITH_PGO=win64;;
*) WITH_PGO=win32;;
esac
;;
mac)
case "$target_cpu" in
arm64) WITH_PGO=mac-arm;;
*) WITH_PGO=mac;;
esac
;;
linux|openwrt)
WITH_PGO=linux
;;
android)
case "$target_cpu" in
arm64) WITH_PGO=android-arm64;;
*) WITH_PGO=android-arm32;;
esac
;;
esac
if [ "$WITH_PGO" ]; then
PGO_PATH=$(cat chrome/build/$WITH_PGO.pgo.txt)
fi
if [ "$WITH_PGO" -a ! -f chrome/build/pgo_profiles/"$PGO_PATH" ]; then
mkdir -p chrome/build/pgo_profiles
cd chrome/build/pgo_profiles
@ -31,21 +93,7 @@ if [ "$WITH_PGO" -a ! -f chrome/build/pgo_profiles/"$PGO_PATH" ]; then
cd ../../..
fi
if [ "$USE_SCCACHE" -a ! -f ~/.cargo/bin/sccache.exe ]; then
sccache_url="https://github.com/mozilla/sccache/releases/download/0.2.12/sccache-0.2.12-x86_64-pc-windows-msvc.tar.gz"
mkdir -p ~/.cargo/bin
curl -L "$sccache_url" | tar xzf - --strip=1 -C ~/.cargo/bin
fi
if [ ! -f gn/out/gn ]; then
gn_version=$(grep "'gn_version':" DEPS | cut -d"'" -f4)
mkdir -p gn/out
curl -L "https://chrome-infra-packages.appspot.com/dl/gn/gn/$WITH_GN-amd64/+/$gn_version" -o gn.zip
unzip gn.zip -d gn/out
rm gn.zip
fi
if [ "$USE_ANDROID_NDK" -a ! -d third_party/android_toolchain/ndk ]; then
if [ "$target_os" = android -a ! -d third_party/android_toolchain/ndk ]; then
# https://dl.google.com/android/repository/android-ndk-r25c-linux.zip
android_ndk_version=$(grep 'default_android_ndk_version = ' build/config/android/config.gni | cut -d'"' -f2)
curl -LO https://dl.google.com/android/repository/android-ndk-$android_ndk_version-linux.zip
@ -58,6 +106,6 @@ if [ "$USE_ANDROID_NDK" -a ! -d third_party/android_toolchain/ndk ]; then
cd third_party/android_toolchain/ndk
find toolchains -type f -regextype egrep \! -regex \
'.*(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
cd ../..
cd -
rm -rf android-ndk-$android_ndk_version android-ndk-$android_ndk_version-linux.zip
fi

View File

@ -1,46 +1,34 @@
ARCH=$(uname)
eval "$EXTRA_FLAGS"
case "$(uname)" in
MINGW*|MSYS*) host_os=win;;
Linux) host_os=linux;;
Darwin) host_os=mac;;
*) echo "Unsupported host OS" >&2; exit 1;;
esac
case "$(uname -m)" in
x86_64|x64) host_cpu=x64;;
x86|i386|i686) host_cpu=x86;;
arm) host_cpu=arm;;
arm64|aarch64|armv8b|armv8l) host_cpu=arm64;;
*) echo "Unsupported host CPU" >&2; exit 1;;
esac
# See src/build/config/BUILDCONFIG.gn
if [ ! "$target_os" ]; then
target_os="$host_os"
fi
if [ ! "$target_cpu" ]; then
target_cpu="$host_cpu"
fi
PYTHON=$(which python3 2>/dev/null || which python 2>/dev/null)
mkdir -p third_party/llvm-build/Release+Asserts
cd tools/clang/scripts
CLANG_REVISION=$($PYTHON -c 'import update; print(update.PACKAGE_VERSION)')
cd -
echo $CLANG_REVISION >third_party/llvm-build/Release+Asserts/cr_build_revision
eval "$EXTRA_FLAGS"
case "$ARCH" in
Linux)
if which ccache >/dev/null 2>&1; then
export CCACHE_SLOPPINESS=time_macros
export CCACHE_BASEDIR="$PWD"
export CCACHE_CPP2=yes
CCACHE=ccache
fi
WITH_CLANG=Linux_x64
# See build/config/compiler/pgo/BUILD.gn
WITH_PGO=linux
WITH_GN=linux
if [ "$OPENWRT_FLAGS" ]; then
eval "$OPENWRT_FLAGS"
WITH_SYSROOT="out/sysroot-build/openwrt/$release/$arch"
elif [ "$target_os" = android ]; then
case "$target_cpu" in
arm64) WITH_PGO=android-arm64;;
*) WITH_PGO=android-arm32;;
esac
# Continue to use mac-arm profile while investigating Android results.
# TODO(crbug.com/4828524, crbug.com/1308749): Remove the following.
WITH_PGO=mac-arm
USE_AFDO=
USE_ANDROID_NDK=y
WITH_SYSROOT=
case "$target_cpu" in
x64) WITH_ANDROID_IMG=x86_64-24_r08;;
x86) WITH_ANDROID_IMG=x86-24_r08;;
arm64) WITH_ANDROID_IMG=arm64-v8a-24_r07;;
arm) WITH_ANDROID_IMG=armeabi-v7a-24_r07;;
esac
else
# sysroot
case "$target_os" in
linux)
case "$target_cpu" in
x64) SYSROOT_ARCH=amd64;;
x86) SYSROOT_ARCH=i386;;
@ -53,38 +41,18 @@ case "$ARCH" in
if [ "$SYSROOT_ARCH" ]; then
WITH_SYSROOT="out/sysroot-build/bullseye/bullseye_${SYSROOT_ARCH}_staging"
fi
fi
;;
MINGW*|MSYS*)
ARCH=Windows
if [ -f "$HOME"/.cargo/bin/sccache* ]; then
export PATH="$PATH:$HOME/.cargo/bin"
CCACHE=sccache
fi
WITH_CLANG=Win
USE_SCCACHE=y
WITH_GN=windows
openwrt)
eval "$OPENWRT_FLAGS"
WITH_SYSROOT="out/sysroot-build/openwrt/$release/$arch"
;;
android)
WITH_SYSROOT=
case "$target_cpu" in
arm64) WITH_PGO=win-arm64;;
x64) WITH_PGO=win64;;
*) WITH_PGO=win32;;
esac
;;
Darwin)
if which ccache >/dev/null 2>&1; then
export CCACHE_SLOPPINESS=time_macros
export CCACHE_BASEDIR="$PWD"
export CCACHE_CPP2=yes
CCACHE=ccache
fi
WITH_CLANG=Mac
WITH_GN=mac
case "$target_cpu" in
arm64) WITH_PGO=mac-arm;;
*) WITH_PGO=mac;;
x64) WITH_ANDROID_IMG=x86_64-24_r08;;
x86) WITH_ANDROID_IMG=x86-24_r08;;
arm64) WITH_ANDROID_IMG=arm64-v8a-24_r07;;
arm) WITH_ANDROID_IMG=armeabi-v7a-24_r07;;
esac
;;
esac
if [ "$WITH_PGO" ]; then
PGO_PATH=$(cat chrome/build/$WITH_PGO.pgo.txt)
fi