Add build scripts

This commit is contained in:
klzgrad 2018-01-25 10:06:30 -05:00
parent 9d7259ff90
commit acf15067f1
4 changed files with 281 additions and 0 deletions

109
src/build.sh Executable file
View File

@ -0,0 +1,109 @@
#!/bin/sh
set -e
export TMPDIR="$PWD/tmp"
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
if which ccache >/dev/null 2>&1; then
export CCACHE_SLOPPINESS=time_macros
export CCACHE_BASEDIR="$PWD"
export CCACHE_CPP2=yes
flags="$flags"'
cc_wrapper="ccache"'
elif [ -f "$HOME"/.cargo/bin/sccache* ]; then
export PATH="$PATH:$HOME/.cargo/bin"
flags="$flags"'
cc_wrapper="sccache"'
fi
flags="$flags"'
is_clang=true
use_sysroot=false
fatal_linker_warnings=false
treat_warnings_as_errors=false
fieldtrial_testing_like_official_build=true
enable_base_tracing=false
enable_nacl=false
enable_print_preview=false
enable_remoting=false
use_alsa=false
use_cups=false
use_dbus=false
use_gio=false
use_platform_icu_alternatives=true
use_gtk=false
use_gnome_keyring=false
use_libpci=false
use_pangocairo=false
use_glib=false
use_pulseaudio=false
use_udev=false
use_x11=false
disable_file_support=true
enable_websockets=false
disable_ftp_support=true
use_kerberos=false
enable_mdns=false
enable_reporting=false
include_transport_security_state_preload_list=false
rtc_use_pipewire=false
'
if [ "$(uname)" = Linux ]; then
flags="$flags"'
use_xkbcommon=false
use_system_libdrm=false
use_ozone=true
ozone_auto_platforms=false
ozone_platform="headless"
ozone_platform_headless=true'
. ./get-sysroot.sh
sysroot=$(get_sysroot)
if [ "$sysroot" ]; then
flags="$flags
sysroot=\"//$sysroot\""
fi
fi
case "$(uname)" in
Linux) PGO_NAME=linux;;
MINGW*|MSYS*)
case "$(uname -m)" in
x86_64) PGO_NAME=win64;;
*) PGO_NAME=win32;;
esac;;
Darwin) PGO_NAME=mac;;
esac
if [ "$PGO_NAME" ]; then
profile=$(cat chrome/build/$PGO_NAME.pgo.txt)
flags="$flags
pgo_data_path=\"../../chrome/build/pgo_profiles/$profile\""
fi
rm -rf "./$out"
mkdir -p out
python2=$(which python2 2>/dev/null || which python 2>/dev/null)
export DEPOT_TOOLS_WIN_TOOLCHAIN=0
./gn/out/gn gen "$out" --args="$flags $EXTRA_FLAGS" --script-executable=$python2
ninja -C "$out" naive

101
src/get-clang.sh Executable file
View File

@ -0,0 +1,101 @@
#!/bin/sh
set -ex
ARCH=$(uname)
case "$ARCH" in
MINGW*) ARCH=Windows;;
MSYS*) ARCH=Windows;;
esac
build_sysroot() {
. ./get-sysroot.sh
sysroot=$(get_sysroot)
if [ -d $sysroot/lib ]; then
return
fi
./build/linux/sysroot_scripts/sysroot-creator-sid-naive.sh "BuildSysroot$1"
}
if [ "$ARCH" = Linux ]; then
if [ "$OPENWRT_FLAGS" ]; then
./get-openwrt.sh
else
eval "$EXTRA_FLAGS"
case "$target_cpu" in
x64) build_sysroot Amd64;;
x86) build_sysroot I386;;
arm64) build_sysroot ARM64;;
arm) build_sysroot ARM;;
esac
fi
fi
# Clang
python2=$(which python2 2>/dev/null || which python 2>/dev/null)
CLANG_REVISION=$($python2 tools/clang/scripts/update.py --print-revision)
CLANG_PATH="clang-$CLANG_REVISION.tgz"
case "$ARCH" in
Linux) clang_url="https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/$CLANG_PATH";;
Darwin) clang_url="https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/$CLANG_PATH";;
Windows) clang_url="https://commondatastorage.googleapis.com/chromium-browser-clang/Win/$CLANG_PATH";;
*) exit 1;;
esac
if [ ! -d third_party/llvm-build/Release+Asserts/bin ]; then
mkdir -p third_party/llvm-build/Release+Asserts
curl "$clang_url" | tar xzf - -C third_party/llvm-build/Release+Asserts
fi
# AFDO profile (Linux)
if [ "$ARCH" = Linux -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
# Profiles (Windows, Mac)
case "$ARCH" in
Linux) PGO_NAME=linux;;
Windows)
case "$(uname -m)" in
x86_64) PGO_NAME=win64;;
*) PGO_NAME=win32;;
esac;;
Darwin) PGO_NAME=mac;;
esac
if [ "$PGO_NAME" ]; then
mkdir -p chrome/build/pgo_profiles
profile=$(cat chrome/build/$PGO_NAME.pgo.txt)
cd chrome/build/pgo_profiles
if [ ! -f "$profile" ]; then
curl --limit-rate 10M -LO "https://storage.googleapis.com/chromium-optimization-profiles/pgo_profiles/$profile"
fi
cd ../../..
fi
# dsymutil (Mac)
if [ "$ARCH" = Darwin -a ! -f tools/clang/dsymutil/bin/dsymutil ]; then
mkdir -p tools/clang/dsymutil
DSYMUTIL_PATH="dsymutil-$CLANG_REVISION.tgz"
dsymutil_url="https://commondatastorage.googleapis.com/chromium-browser-clang-staging/Mac/$DSYMUTIL_PATH"
curl "$dsymutil_url" | tar xzf - -C tools/clang/dsymutil
fi
# sccache (Windows)
if [ "$ARCH" = Windows -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
if [ ! -f gn/out/gn ]; then
GN_VERSION=$(grep "'gn_version':" buildtools/DEPS | cut -d"'" -f4)
mkdir -p gn/out
cd gn/out
case "$ARCH" in
Linux) curl -L "https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/$GN_VERSION" -o gn.zip;;
Darwin) curl -L "https://chrome-infra-packages.appspot.com/dl/gn/gn/mac-amd64/+/$GN_VERSION" -o gn.zip;;
Windows) curl -L "https://chrome-infra-packages.appspot.com/dl/gn/gn/windows-amd64/+/$GN_VERSION" -o gn.zip;;
esac
unzip gn.zip
fi

50
src/get-openwrt.sh Executable file
View 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
SDK_PATH=openwrt-sdk-$release-$target-${subtarget}_gcc-${gcc_ver}_${abi}.Linux-x86_64
if [ "$target" = bcm53xx ]; then
SDK_PATH=openwrt-sdk-$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
./scripts/feeds update base packages
./scripts/feeds install libnss
make defconfig
for flag in ALL_NONSHARED ALL_KMODS ALL SIGNED_PACKAGES; do
sed -i "s/CONFIG_$flag=y/# CONFIG_$flag is not set/" .config
done
make oldconfig
make
full_root=staging_dir/toolchain-*_gcc-${gcc_ver}_${abi}
cp -r staging_dir/target-*_${abi}/usr $full_root
echo '
./include
./lib/*.o
./lib/gcc/*/libgcc.a
./lib/libatomic.so*
./lib/libc.so
./lib/libdl.a
./lib/ld-*
./lib/libgcc_s.*
./lib/libm.a
./lib/libpthread.a
./lib/libresolv.a
./lib/librt.a
./usr
*.ld.bin
' >include.txt
tar cf - -C $full_root --hard-dereference . | tar xf - -C $sysroot --wildcards --wildcards-match-slash -T include.txt
rm include.txt
cd $sysroot/*-openwrt-linux-musl*/bin
mv .ld.bin ld

21
src/get-sysroot.sh Normal file
View File

@ -0,0 +1,21 @@
get_sysroot() {
if [ "$OPENWRT_FLAGS" ]; then
eval "$OPENWRT_FLAGS"
echo "out/sysroot-build/openwrt/$release/$arch"
return
fi
eval "$EXTRA_FLAGS"
if [ ! "$target_sysroot" ]; then
local sysroot_type
case "$target_cpu" in
x64) sysroot_type=amd64;;
x86) sysroot_type=i386;;
arm64) sysroot_type=arm64;;
arm) sysroot_type=arm;;
mipsel) sysroot_type=mips;;
esac
if [ "$sysroot_type" ]; then
echo "out/sysroot-build/sid/sid_${sysroot_type}_staging"
fi
fi
}