2020-08-07 16:22:05 -07:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set +x
|
|
|
|
|
|
|
|
trap "cd $(pwd -P)" EXIT
|
2021-08-07 15:32:18 +03:00
|
|
|
cd "$(dirname "$0")"
|
2022-03-22 15:14:20 -06:00
|
|
|
SCRIPT_FOLDER=$(pwd -P)
|
2022-04-22 13:35:35 -06:00
|
|
|
source "${SCRIPT_FOLDER}/../utils.sh"
|
2020-08-07 16:22:05 -07:00
|
|
|
|
2021-01-22 00:27:40 -08:00
|
|
|
USAGE=$(cat<<EOF
|
2022-03-22 15:14:20 -06:00
|
|
|
usage: $(basename "$0") [--arm64] [--symbols] [--full] [--goma] <custom targets to compile>
|
|
|
|
|
|
|
|
--arm64 cross-compile for arm64
|
|
|
|
--symbols compile with symbols
|
|
|
|
--full install build dependencies
|
|
|
|
--goma use goma when compiling. Make sure to pre-start goma client beforehand with './goma.sh start'.
|
|
|
|
|
|
|
|
On Linux & MacOS, it is possible to specify custom compilation targets:
|
|
|
|
|
|
|
|
./build.sh --goma blink_tests
|
2021-01-22 00:27:40 -08:00
|
|
|
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2021-07-13 17:12:53 -08:00
|
|
|
source "${SCRIPT_FOLDER}/../utils.sh"
|
2021-01-22 00:27:40 -08:00
|
|
|
|
2022-03-22 15:14:20 -06:00
|
|
|
if [[ $1 == "--help" || $1 == "-h" ]]; then
|
|
|
|
echo "$USAGE"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
args=("$@")
|
|
|
|
IS_ARM64=""
|
|
|
|
IS_SYMBOLS_BUILD=""
|
|
|
|
IS_FULL=""
|
|
|
|
USE_GOMA=""
|
2022-04-05 01:55:13 -06:00
|
|
|
for ((i="${#args[@]}"-1; i >= 0; --i)); do
|
2022-03-22 15:14:20 -06:00
|
|
|
case ${args[i]} in
|
|
|
|
--arm64) IS_ARM64="1"; unset args[i]; ;;
|
|
|
|
--symbols) IS_SYMBOLS_BUILD="1"; unset args[i]; ;;
|
|
|
|
--full) IS_FULL="1"; unset args[i]; ;;
|
|
|
|
--goma) USE_GOMA="1"; unset args[i]; ;;
|
|
|
|
esac
|
|
|
|
done
|
2021-02-12 02:21:39 -07:00
|
|
|
|
2021-01-22 00:27:40 -08:00
|
|
|
compile_chromium() {
|
|
|
|
if [[ -z "${CR_CHECKOUT_PATH}" ]]; then
|
2021-10-28 11:48:57 -07:00
|
|
|
CR_CHECKOUT_PATH="$HOME/chromium"
|
2021-01-22 00:27:40 -08:00
|
|
|
fi
|
2021-01-28 01:43:54 -08:00
|
|
|
|
2021-10-28 11:48:57 -07:00
|
|
|
if [[ ! -d "${CR_CHECKOUT_PATH}/src" ]]; then
|
2021-02-17 14:43:19 -08:00
|
|
|
echo "ERROR: CR_CHECKOUT_PATH does not have src/ subfolder; is this a chromium checkout?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-07-16 01:36:49 -08:00
|
|
|
source "${SCRIPT_FOLDER}/ensure_depot_tools.sh"
|
2021-01-22 00:27:40 -08:00
|
|
|
|
2022-04-22 13:35:35 -06:00
|
|
|
if is_mac; then
|
2022-04-25 07:35:26 -06:00
|
|
|
selectXcodeVersionOrDie $(node "${SCRIPT_FOLDER}/../get_xcode_version.js" chromium)
|
2021-01-22 00:27:40 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd "${CR_CHECKOUT_PATH}/src"
|
|
|
|
|
|
|
|
# Prepare build folder.
|
|
|
|
mkdir -p "./out/Default"
|
2021-06-15 01:18:00 -07:00
|
|
|
echo "is_debug = false" > ./out/Default/args.gn
|
2021-08-07 15:41:13 +03:00
|
|
|
echo "dcheck_always_on = false" >> ./out/Default/args.gn
|
2022-03-22 15:14:20 -06:00
|
|
|
if [[ -n "${IS_SYMBOLS_BUILD}" ]]; then
|
2021-06-15 01:18:00 -07:00
|
|
|
echo "symbol_level = 1" >> ./out/Default/args.gn
|
|
|
|
else
|
|
|
|
echo "symbol_level = 0" >> ./out/Default/args.gn
|
|
|
|
fi
|
2021-01-22 00:27:40 -08:00
|
|
|
|
2022-03-22 15:14:20 -06:00
|
|
|
if [[ -n "${IS_ARM64}" ]]; then
|
2021-11-02 14:52:12 -07:00
|
|
|
echo 'target_cpu = "arm64"' >> ./out/Default/args.gn
|
2021-01-22 00:27:40 -08:00
|
|
|
fi
|
|
|
|
|
2021-02-09 08:33:39 -08:00
|
|
|
if [[ ! -z "$USE_GOMA" ]]; then
|
2022-03-22 15:14:20 -06:00
|
|
|
"${SCRIPT_FOLDER}/goma.sh" args >> ./out/Default/args.gn
|
2021-02-09 08:33:39 -08:00
|
|
|
fi
|
2022-03-04 15:38:02 -07:00
|
|
|
echo 'enable_nacl = false' >> ./out/Default/args.gn
|
2021-02-09 08:33:39 -08:00
|
|
|
|
2021-08-30 17:48:40 +03:00
|
|
|
echo "===== args.gn ====="
|
|
|
|
cat ./out/Default/args.gn
|
|
|
|
echo "===== ======= ====="
|
|
|
|
|
2022-03-22 15:14:20 -06:00
|
|
|
if [[ -n "$IS_FULL" ]]; then
|
2022-04-22 13:35:35 -06:00
|
|
|
if is_linux; then
|
2021-11-02 03:23:15 -07:00
|
|
|
./build/install-build-deps.sh
|
2022-03-22 15:14:20 -06:00
|
|
|
if [[ -n "$IS_ARM64" ]]; then
|
|
|
|
# Install sysroot image, see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/linux/chromium_arm.md
|
|
|
|
./build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
|
|
|
|
fi
|
2021-11-02 03:23:15 -07:00
|
|
|
fi
|
2021-11-01 17:05:39 -07:00
|
|
|
fi
|
|
|
|
|
2022-04-04 15:33:23 -06:00
|
|
|
TARGETS="${args[@]}"
|
2022-04-22 13:35:35 -06:00
|
|
|
if is_win; then
|
2022-03-22 15:14:20 -06:00
|
|
|
if [[ -n "$TARGETS" ]]; then
|
|
|
|
echo "ERROR: cannot compile custom targets on windows yet."
|
|
|
|
echo "Requested to compile chromium targets - ${TARGETS}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-02-09 08:33:39 -08:00
|
|
|
if [[ -z "$USE_GOMA" ]]; then
|
2021-08-07 15:32:18 +03:00
|
|
|
/c/Windows/System32/cmd.exe "/c $(cygpath -w "${SCRIPT_FOLDER}"/buildwin.bat)"
|
2021-02-09 08:33:39 -08:00
|
|
|
else
|
2021-08-07 15:32:18 +03:00
|
|
|
/c/Windows/System32/cmd.exe "/c $(cygpath -w "${SCRIPT_FOLDER}"/buildwingoma.bat)"
|
2021-02-09 08:33:39 -08:00
|
|
|
fi
|
2021-02-07 23:54:10 -08:00
|
|
|
else
|
2022-03-22 15:14:20 -06:00
|
|
|
if [[ -z "$TARGETS" ]]; then
|
2022-04-22 13:35:35 -06:00
|
|
|
if is_linux; then
|
2022-03-22 15:14:20 -06:00
|
|
|
TARGETS="chrome chrome_sandbox clear_key_cdm"
|
|
|
|
else
|
|
|
|
TARGETS="chrome"
|
|
|
|
fi
|
2021-02-09 08:33:39 -08:00
|
|
|
fi
|
2022-04-04 15:33:23 -06:00
|
|
|
echo
|
|
|
|
echo ">> Compiling Targets: $TARGETS"
|
|
|
|
echo
|
|
|
|
|
|
|
|
gn gen out/Default
|
2021-02-09 08:33:39 -08:00
|
|
|
if [[ -z "$USE_GOMA" ]]; then
|
|
|
|
autoninja -C out/Default $TARGETS
|
|
|
|
else
|
|
|
|
ninja -j 200 -C out/Default $TARGETS
|
|
|
|
fi
|
2021-02-03 07:35:29 -07:00
|
|
|
fi
|
2021-01-22 00:27:40 -08:00
|
|
|
}
|
|
|
|
|
2022-03-22 15:14:20 -06:00
|
|
|
compile_chromium "${args[@]}"
|