mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-21 21:06:12 +03:00
Add build scripts
This commit is contained in:
parent
46633d96fb
commit
f80453e25f
85
src/build.sh
Executable file
85
src/build.sh
Executable file
@ -0,0 +1,85 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
export TMPDIR="$PWD/tmp"
|
||||
rm -rf "$TMPDIR"
|
||||
mkdir -p "$TMPDIR"
|
||||
|
||||
if [ "$1" = debug ]; then
|
||||
out=out/Debug
|
||||
flags="
|
||||
is_debug=true
|
||||
is_component_build=true"
|
||||
else
|
||||
out=out/Release
|
||||
flags="
|
||||
is_official_build=true
|
||||
exclude_unwind_tables=true
|
||||
enable_resource_allowlist_generation=false
|
||||
symbol_level=0"
|
||||
fi
|
||||
|
||||
. ./get-sysroot.sh
|
||||
|
||||
if [ "$CCACHE" ]; then
|
||||
flags="$flags
|
||||
cc_wrapper=\"$CCACHE\""
|
||||
fi
|
||||
|
||||
flags="$flags"'
|
||||
is_clang=true
|
||||
use_sysroot=false
|
||||
|
||||
fatal_linker_warnings=false
|
||||
treat_warnings_as_errors=false
|
||||
|
||||
enable_base_tracing=false
|
||||
use_udev=false
|
||||
use_aura=false
|
||||
use_ozone=false
|
||||
use_gio=false
|
||||
use_gtk=false
|
||||
use_platform_icu_alternatives=true
|
||||
use_glib=false
|
||||
|
||||
disable_file_support=true
|
||||
enable_websockets=false
|
||||
use_kerberos=false
|
||||
enable_mdns=false
|
||||
enable_reporting=false
|
||||
include_transport_security_state_preload_list=false
|
||||
use_nss_certs=false
|
||||
|
||||
enable_backup_ref_ptr_support=false
|
||||
enable_dangling_raw_ptr_checks=false
|
||||
'
|
||||
|
||||
if [ "$WITH_SYSROOT" ]; then
|
||||
flags="$flags
|
||||
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
|
||||
flags="$flags"'
|
||||
enable_dsyms=false'
|
||||
fi
|
||||
|
||||
if [ "$target_cpu" = "mipsel" -o "$target_cpu" = "mips64el" ]; then
|
||||
flags="$flags"'
|
||||
use_thin_lto=false
|
||||
chrome_pgo_phase=0'
|
||||
fi
|
||||
|
||||
rm -rf "./$out"
|
||||
mkdir -p out
|
||||
|
||||
export DEPOT_TOOLS_WIN_TOOLCHAIN=0
|
||||
|
||||
./gn/out/gn gen "$out" --args="$flags $EXTRA_FLAGS" --script-executable=$PYTHON
|
||||
|
||||
ninja -C "$out" naive
|
63
src/get-clang.sh
Executable file
63
src/get-clang.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
|
||||
. ./get-sysroot.sh
|
||||
|
||||
if [ "$SYSROOT_ARCH" -a ! -d ./"$WITH_SYSROOT/lib" ]; then
|
||||
./build/linux/sysroot_scripts/sysroot-creator.sh build "$SYSROOT_ARCH"
|
||||
fi
|
||||
|
||||
if [ "$OPENWRT_FLAGS" ]; then
|
||||
./get-openwrt.sh
|
||||
fi
|
||||
|
||||
if [ ! -d third_party/llvm-build/Release+Asserts/bin ]; then
|
||||
mkdir -p third_party/llvm-build/Release+Asserts
|
||||
clang_path="clang-$CLANG_REVISION.tgz"
|
||||
clang_url="https://commondatastorage.googleapis.com/chromium-browser-clang/$WITH_CLANG/$clang_path"
|
||||
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
|
||||
fi
|
||||
|
||||
if [ "$WITH_PGO" -a ! -f chrome/build/pgo_profiles/"$PGO_PATH" ]; then
|
||||
mkdir -p chrome/build/pgo_profiles
|
||||
cd chrome/build/pgo_profiles
|
||||
curl --limit-rate 10M -LO "https://storage.googleapis.com/chromium-optimization-profiles/pgo_profiles/$PGO_PATH"
|
||||
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
|
||||
# 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
|
||||
unzip android-ndk-$android_ndk_version-linux.zip
|
||||
mkdir -p third_party/android_toolchain/ndk
|
||||
cd android-ndk-$android_ndk_version
|
||||
cp -r --parents sources/android/cpufeatures ../third_party/android_toolchain/ndk
|
||||
cp -r --parents toolchains/llvm/prebuilt ../third_party/android_toolchain/ndk
|
||||
cd ..
|
||||
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 ../..
|
||||
rm -rf android-ndk-$android_ndk_version android-ndk-$android_ndk_version-linux.zip
|
||||
fi
|
50
src/get-openwrt.sh
Executable file
50
src/get-openwrt.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
eval "$OPENWRT_FLAGS"
|
||||
|
||||
sysroot=$PWD/out/sysroot-build/openwrt/$release/$arch
|
||||
if [ -d $sysroot/lib ]; then
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p $sysroot
|
||||
|
||||
case "$arch" in
|
||||
arm_*) abi=musl_eabi;;
|
||||
*) abi=musl;;
|
||||
esac
|
||||
|
||||
if [ "$subtarget" ]; then
|
||||
SDK_PATH=openwrt-toolchain-$release-$target-${subtarget}_gcc-${gcc_ver}_${abi}.Linux-x86_64
|
||||
else
|
||||
subtarget='generic'
|
||||
SDK_PATH=openwrt-toolchain-$release-${target}_gcc-${gcc_ver}_${abi}.Linux-x86_64
|
||||
fi
|
||||
SDK_URL=https://downloads.openwrt.org/releases/$release/targets/$target/$subtarget/$SDK_PATH.tar.xz
|
||||
rm -rf $SDK_PATH
|
||||
curl $SDK_URL | tar xJf -
|
||||
cd $SDK_PATH
|
||||
full_root=toolchain-*_gcc-${gcc_ver}_${abi}
|
||||
cat >include.txt <<EOF
|
||||
./include
|
||||
./lib/*.o
|
||||
./lib/gcc/*/libgcc.a
|
||||
./lib/gcc/*/libgcc_eh.a
|
||||
./lib/libatomic.so*
|
||||
./lib/libatomic.a
|
||||
./lib/libc.so
|
||||
./lib/libc.a
|
||||
./lib/libdl.a
|
||||
./lib/ld-*
|
||||
./lib/libgcc_s.*
|
||||
./lib/libm.a
|
||||
./lib/libpthread.a
|
||||
./lib/libresolv.a
|
||||
./lib/librt.a
|
||||
./usr
|
||||
EOF
|
||||
tar cf - -C $full_root --hard-dereference . | tar xf - -C $sysroot --wildcards --wildcards-match-slash -T include.txt
|
||||
rm -rf include.txt
|
||||
cd ..
|
||||
rm -rf $SDK_PATH
|
90
src/get-sysroot.sh
Normal file
90
src/get-sysroot.sh
Normal file
@ -0,0 +1,90 @@
|
||||
ARCH=$(uname)
|
||||
|
||||
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
|
||||
case "$target_cpu" in
|
||||
x64) SYSROOT_ARCH=amd64;;
|
||||
x86) SYSROOT_ARCH=i386;;
|
||||
arm64) SYSROOT_ARCH=arm64;;
|
||||
arm) SYSROOT_ARCH=armhf;;
|
||||
mipsel) SYSROOT_ARCH=mipsel;;
|
||||
mips64el) SYSROOT_ARCH=mips64el;;
|
||||
riscv64) SYSROOT_ARCH=riscv64;;
|
||||
esac
|
||||
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
|
||||
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;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
if [ "$WITH_PGO" ]; then
|
||||
PGO_PATH=$(cat chrome/build/$WITH_PGO.pgo.txt)
|
||||
fi
|
Loading…
Reference in New Issue
Block a user