2021-04-10 08:13:19 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set +x
|
|
|
|
|
2022-05-16 18:39:02 +03:00
|
|
|
RUST_VERSION="1.59.0"
|
2022-07-06 01:47:35 +03:00
|
|
|
CBINDGEN_VERSION="0.24.3"
|
2021-04-10 08:13:19 +03:00
|
|
|
|
|
|
|
trap "cd $(pwd -P)" EXIT
|
|
|
|
|
2021-08-07 15:32:18 +03:00
|
|
|
cd "$(dirname "$0")"
|
2021-04-10 08:13:19 +03:00
|
|
|
SCRIPT_FOLDER="$(pwd -P)"
|
2021-07-14 04:12:53 +03:00
|
|
|
source "${SCRIPT_FOLDER}/../utils.sh"
|
2021-04-10 08:13:19 +03:00
|
|
|
|
|
|
|
if [[ ! -z "${FF_CHECKOUT_PATH}" ]]; then
|
|
|
|
cd "${FF_CHECKOUT_PATH}"
|
|
|
|
echo "WARNING: checkout path from FF_CHECKOUT_PATH env: ${FF_CHECKOUT_PATH}"
|
|
|
|
else
|
2021-10-14 20:20:06 +03:00
|
|
|
cd "$HOME/firefox"
|
2021-04-10 08:13:19 +03:00
|
|
|
fi
|
|
|
|
|
2022-07-22 02:20:09 +03:00
|
|
|
args=("$@")
|
|
|
|
IS_FULL=""
|
|
|
|
IS_JUGGLER=""
|
|
|
|
IS_LINUX_ARM64=""
|
|
|
|
IS_DEBUG=""
|
|
|
|
for ((i="${#args[@]}"-1; i >= 0; --i)); do
|
|
|
|
case ${args[i]} in
|
|
|
|
--full) IS_FULL="1"; unset args[i]; ;;
|
|
|
|
--juggler) IS_JUGGLER="1"; unset args[i]; ;;
|
|
|
|
--linux-arm64) IS_LINUX_ARM64="1"; unset args[i]; ;;
|
|
|
|
--debug) IS_DEBUG="1"; unset args[i]; ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ -n "${IS_JUGGLER}" && -n "${IS_FULL}" ]]; then
|
|
|
|
echo "ERROR: either --full or --juggler is allowed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "== BUILD CONFIGURATION =="
|
|
|
|
if [[ -n "${IS_FULL}" ]]; then
|
|
|
|
echo "- build type: FULL"
|
|
|
|
elif [[ -n "${IS_JUGGLER}" ]]; then
|
|
|
|
echo "- build type: JUGGLER"
|
|
|
|
else
|
|
|
|
echo "- build type: INCREMENTAL"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n "${IS_DEBUG}" ]]; then
|
|
|
|
echo "- debug: YES"
|
|
|
|
else
|
|
|
|
echo "- debug: NO"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n "${IS_LINUX_ARM64}" ]]; then
|
|
|
|
echo "- linux aarch64: YES"
|
|
|
|
else
|
|
|
|
echo "- linux aarch64: NO"
|
|
|
|
fi
|
|
|
|
echo "========================="
|
|
|
|
|
2021-04-10 08:13:19 +03:00
|
|
|
rm -rf .mozconfig
|
|
|
|
|
2022-04-22 22:35:35 +03:00
|
|
|
if is_mac; then
|
2022-04-25 16:35:26 +03:00
|
|
|
selectXcodeVersionOrDie $(node "${SCRIPT_FOLDER}/../get_xcode_version.js" firefox)
|
2021-04-10 08:13:19 +03:00
|
|
|
echo "-- building on Mac"
|
2022-04-22 22:35:35 +03:00
|
|
|
elif is_linux; then
|
2021-04-10 08:13:19 +03:00
|
|
|
echo "-- building on Linux"
|
2022-04-22 22:35:35 +03:00
|
|
|
elif is_win; then
|
2021-04-10 08:13:19 +03:00
|
|
|
echo "ac_add_options --disable-update-agent" >> .mozconfig
|
|
|
|
echo "ac_add_options --disable-default-browser-agent" >> .mozconfig
|
2022-01-27 04:29:53 +03:00
|
|
|
echo "ac_add_options --disable-maintenance-service" >> .mozconfig
|
2021-04-10 08:13:19 +03:00
|
|
|
|
2021-10-28 03:20:23 +03:00
|
|
|
echo "-- building win64 build on MINGW"
|
|
|
|
echo "ac_add_options --target=x86_64-pc-mingw32" >> .mozconfig
|
|
|
|
echo "ac_add_options --host=x86_64-pc-mingw32" >> .mozconfig
|
|
|
|
DLL_FILE=$("C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find '**\Redist\MSVC\*\x64\**\vcruntime140.dll')
|
2021-04-10 08:13:19 +03:00
|
|
|
WIN32_REDIST_DIR=$(dirname "$DLL_FILE")
|
|
|
|
if ! [[ -d $WIN32_REDIST_DIR ]]; then
|
|
|
|
echo "ERROR: cannot find MS VS C++ redistributable $WIN32_REDIST_DIR"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "ERROR: cannot upload on this platform!" 1>&2
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2022-07-22 02:20:09 +03:00
|
|
|
if [[ -n "${IS_LINUX_ARM64}" ]]; then
|
2021-12-14 08:23:25 +03:00
|
|
|
echo "ac_add_options --target=aarch64-linux-gnu" >> .mozconfig
|
|
|
|
fi
|
|
|
|
|
2022-07-12 15:12:51 +03:00
|
|
|
if is_linux "debian" 11; then
|
|
|
|
# There's no pre-built wasi sysroot for Debian 11.
|
|
|
|
echo "ac_add_options --without-wasm-sandboxed-libraries" >> .mozconfig
|
|
|
|
fi
|
|
|
|
|
2021-04-10 08:13:19 +03:00
|
|
|
OBJ_FOLDER="obj-build-playwright"
|
|
|
|
echo "mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/${OBJ_FOLDER}" >> .mozconfig
|
|
|
|
echo "ac_add_options --disable-crashreporter" >> .mozconfig
|
2021-09-08 16:15:22 +03:00
|
|
|
echo "ac_add_options --disable-backgroundtasks" >> .mozconfig
|
|
|
|
|
2022-07-22 02:20:09 +03:00
|
|
|
if [[ -n "${IS_DEBUG}" ]]; then
|
2021-12-14 08:23:25 +03:00
|
|
|
echo "ac_add_options --enable-debug" >> .mozconfig
|
|
|
|
echo "ac_add_options --enable-debug-symbols" >> .mozconfig
|
2021-12-15 19:31:33 +03:00
|
|
|
else
|
|
|
|
echo "ac_add_options --enable-release" >> .mozconfig
|
2021-12-14 08:23:25 +03:00
|
|
|
fi
|
|
|
|
|
2022-04-22 22:35:35 +03:00
|
|
|
if is_mac || is_win; then
|
2021-09-08 16:15:22 +03:00
|
|
|
# This options is only available on win and mac.
|
|
|
|
echo "ac_add_options --disable-update-agent" >> .mozconfig
|
|
|
|
fi
|
2021-04-10 08:13:19 +03:00
|
|
|
|
2022-07-22 02:20:09 +03:00
|
|
|
if [[ -z "${IS_JUGGLER}" ]]; then
|
2021-08-06 20:16:14 +03:00
|
|
|
# TODO: rustup is not in the PATH on Windows
|
|
|
|
if command -v rustup >/dev/null; then
|
|
|
|
# We manage Rust version ourselves.
|
|
|
|
echo "-- Using rust v${RUST_VERSION}"
|
|
|
|
rustup install "${RUST_VERSION}"
|
|
|
|
rustup default "${RUST_VERSION}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# TODO: cargo is not in the PATH on Windows
|
|
|
|
if command -v cargo >/dev/null; then
|
|
|
|
echo "-- Using cbindgen v${CBINDGEN_VERSION}"
|
|
|
|
cargo install cbindgen --version "${CBINDGEN_VERSION}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-07-22 02:20:09 +03:00
|
|
|
if [[ -n "${IS_FULL}" ]]; then
|
2022-05-19 18:08:46 +03:00
|
|
|
# This is a slow but sure way to get all the necessary toolchains.
|
|
|
|
# However, it will not work if tree is dirty.
|
|
|
|
# Bail out if git repo is dirty.
|
|
|
|
if [[ -n $(git status -s --untracked-files=no) ]]; then
|
|
|
|
echo "ERROR: dirty GIT state - commit everything and re-run the script."
|
|
|
|
exit 1
|
2021-04-10 08:13:19 +03:00
|
|
|
fi
|
2022-05-19 18:08:46 +03:00
|
|
|
|
|
|
|
# 1. We have a --single-branch checkout, so we have to add a "master" branch and fetch it
|
|
|
|
git remote set-branches --add browser_upstream master
|
|
|
|
git fetch browser_upstream master
|
|
|
|
# 2. Checkout the master branch and run bootstrap from it.
|
|
|
|
git checkout browser_upstream/master
|
|
|
|
SHELL=/bin/sh ./mach --no-interactive bootstrap --application-choice=browser
|
|
|
|
git checkout -
|
|
|
|
|
2021-04-10 08:13:19 +03:00
|
|
|
if [[ ! -z "${WIN32_REDIST_DIR}" ]]; then
|
|
|
|
# Having this option in .mozconfig kills incremental compilation.
|
|
|
|
echo "export WIN32_REDIST_DIR=\"$WIN32_REDIST_DIR\"" >> .mozconfig
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-06-28 15:40:58 +03:00
|
|
|
# Remove the cbindgen from mozbuild to rely on the one we install manually.
|
|
|
|
# See https://github.com/microsoft/playwright/issues/15174
|
|
|
|
if is_win; then
|
|
|
|
rm -rf "${USERPROFILE}\\.mozbuild\\cbindgen"
|
|
|
|
else
|
|
|
|
rm -rf "${HOME}/.mozbuild/cbindgen"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2022-07-22 02:20:09 +03:00
|
|
|
if [[ -n "${IS_JUGGLER}" ]]; then
|
2021-04-10 08:13:19 +03:00
|
|
|
./mach build faster
|
2021-09-13 18:01:35 +03:00
|
|
|
else
|
2022-05-31 11:50:04 +03:00
|
|
|
export MOZ_AUTOMATION=1
|
|
|
|
# Use winpaths instead of unix paths on Windows.
|
|
|
|
# note: 'cygpath' is not available in MozBuild shell.
|
|
|
|
if is_win; then
|
|
|
|
export MOZ_FETCHES_DIR="${USERPROFILE}\\.mozbuild"
|
|
|
|
else
|
|
|
|
export MOZ_FETCHES_DIR="${HOME}/.mozbuild"
|
|
|
|
fi
|
|
|
|
./mach build
|
2022-04-22 22:35:35 +03:00
|
|
|
if is_mac; then
|
2022-07-22 02:20:09 +03:00
|
|
|
FF_DEBUG_BUILD="${IS_DEBUG}" node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist
|
2021-12-15 19:31:33 +03:00
|
|
|
else
|
2022-07-22 02:20:09 +03:00
|
|
|
FF_DEBUG_BUILD="${IS_DEBUG}" node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist/bin
|
2021-12-15 19:31:33 +03:00
|
|
|
fi
|
2021-04-10 08:13:19 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
|