From d951cb44767b4e54f6689d55a9e2f2fb7f192024 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Thu, 25 Jan 2018 10:06:30 -0500 Subject: [PATCH] Add build scripts --- src/build.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ src/get-clang.sh | 66 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100755 src/build.sh create mode 100755 src/get-clang.sh diff --git a/src/build.sh b/src/build.sh new file mode 100755 index 0000000000..6d26318199 --- /dev/null +++ b/src/build.sh @@ -0,0 +1,74 @@ +#!/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 + use_jumbo_build=true + exclude_unwind_tables=true + 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 + linux_use_bundled_binutils=false + + fatal_linker_warnings=false + treat_warnings_as_errors=false + use_sysroot=false + + fieldtrial_testing_like_official_build=true + + use_cups=false + use_dbus=false + use_gio=false + use_platform_icu_alternatives=true + + disable_file_support=true + enable_websockets=false + disable_ftp_support=true + use_kerberos=false + disable_brotli_filter=true + enable_mdns=false + enable_reporting=false + include_transport_security_state_preload_list=false +' + +if [ "$(uname)" = Linux ]; then + flags="$flags"' + use_ozone=true + ozone_auto_platforms=false + ozone_platform="headless" + ozone_platform_headless=true' +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" --script-executable=$python2 + +ninja -C "$out" naive diff --git a/src/get-clang.sh b/src/get-clang.sh new file mode 100755 index 0000000000..c4e3041710 --- /dev/null +++ b/src/get-clang.sh @@ -0,0 +1,66 @@ +#!/bin/sh +set -ex + +ARCH=$(uname) +case "$ARCH" in MINGW*) + ARCH=Windows +esac + +# Clang +CLANG_REVISION=$(grep -m1 CLANG_REVISION tools/clang/scripts/update.py | cut -d"'" -f2) +CLANG_SUB_REVISION=$(grep -m1 CLANG_SUB_REVISION tools/clang/scripts/update.py | cut -d= -f2) +CLANG_PATH="clang-$CLANG_REVISION-$CLANG_SUB_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" -o- | 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" -o- | bzip2 -cd >chrome/android/profiles/afdo.prof +fi + +# sccache (Windows) +if [ "$ARCH" = Windows ]; then + export PATH="$PATH:$HOME/.cargo/bin" + if ! which cargo >/dev/null 2>&1; then + curl -OJ https://win.rustup.rs/ + ./rustup-init.exe -y -v --no-modify-path + fi + if ! which sccache >/dev/null 2>&1; then + cargo install --git https://github.com/mozilla/sccache.git --debug + fi +fi + +# gn +if [ ! -f gn/out/gn ]; then + if [ "$CI" -o "$ARCH" = Windows ]; then + mkdir -p gn/out + cd gn/out + case "$ARCH" in + Linux) curl -L https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest -o gn.zip;; + Darwin) curl -L https://chrome-infra-packages.appspot.com/dl/gn/gn/mac-amd64/+/latest -o gn.zip;; + Windows) curl -L https://chrome-infra-packages.appspot.com/dl/gn/gn/windows-amd64/+/latest -o gn.zip;; + esac + unzip gn.zip + else + rm -rf gn + git clone --single-branch https://gn.googlesource.com/gn + export PATH="$PWD/third_party/llvm-build/Release+Asserts/bin:$PATH" + cd gn + if which ccache >/dev/null 2>&1; then + export CC='ccache clang' CXX='ccache clang++' CCACHE_BASEDIR="$PWD" + fi + python2=$(which python2 2>/dev/null || which python 2>/dev/null) + $python2 build/gen.py + ninja -C out gn + fi +fi