2021-04-10 08:13:19 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set +x
|
|
|
|
|
2021-08-03 19:15:52 +03:00
|
|
|
RUST_VERSION="1.51.0"
|
2021-06-01 23:16:45 +03:00
|
|
|
CBINDGEN_VERSION="0.19.0"
|
2021-04-10 08:13:19 +03:00
|
|
|
# Certain minimal SDK Version is required by firefox
|
|
|
|
MACOS_SDK_VERSION="10.12"
|
|
|
|
# XCode version can be determined from https://en.wikipedia.org/wiki/Xcode
|
|
|
|
XCODE_VERSION_WITH_REQUIRED_SDK_VERSION="8.3.3"
|
|
|
|
|
|
|
|
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-05-05 03:46:24 +03:00
|
|
|
cd "../firefox/checkout"
|
2021-04-10 08:13:19 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf .mozconfig
|
|
|
|
|
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
2021-07-14 04:12:53 +03:00
|
|
|
CURRENT_HOST_OS_VERSION=$(getMacVersion)
|
2021-10-08 02:23:00 +03:00
|
|
|
# As of Oct 2021, building Firefox requires XCode 12.2
|
|
|
|
if [[ "${CURRENT_HOST_OS_VERSION}" == "11."* ]]; then
|
2021-07-14 04:12:53 +03:00
|
|
|
selectXcodeVersionOrDie "12.2"
|
2021-04-10 08:13:19 +03:00
|
|
|
else
|
2021-07-14 04:12:53 +03:00
|
|
|
echo "ERROR: ${CURRENT_HOST_OS_VERSION} is not supported"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-10-08 02:23:00 +03:00
|
|
|
|
|
|
|
# Firefox on Mac Intel requires SDK for 10.12 to work on old versions of MacOS.
|
|
|
|
# Mac on Apple Silicon doesn't exist on old versions of MacOS, so this is not needed.
|
|
|
|
if [[ "$(uname -m)" == "x86_64" ]]; then
|
2021-04-10 08:13:19 +03:00
|
|
|
if ! [[ -d $HOME/SDK-archive/MacOSX${MACOS_SDK_VERSION}.sdk ]]; then
|
2021-07-14 04:12:53 +03:00
|
|
|
echo "As of Dec 2020, Firefox does not build on Mac ${CURRENT_HOST_OS_VERSION} without ${MACOS_SDK_VERSION} SDK."
|
2021-04-10 08:13:19 +03:00
|
|
|
echo "Download XCode ${XCODE_VERSION_WITH_REQUIRED_SDK_VERSION} from https://developer.apple.com/download/more/ and"
|
|
|
|
echo "extract SDK to $HOME/SDK-archive/MacOSX${MACOS_SDK_VERSION}.sdk"
|
|
|
|
echo ""
|
|
|
|
echo "More info: https://firefox-source-docs.mozilla.org/setup/macos_build.html"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "-- configuting .mozconfig with ${MACOS_SDK_VERSION} SDK path"
|
|
|
|
echo "ac_add_options --with-macos-sdk=$HOME/SDK-archive/MacOSX${MACOS_SDK_VERSION}.sdk/" >> .mozconfig
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "-- building on Mac"
|
|
|
|
elif [[ "$(uname)" == "Linux" ]]; then
|
|
|
|
echo "-- building on Linux"
|
|
|
|
echo "ac_add_options --disable-av1" >> .mozconfig
|
|
|
|
elif [[ "$(uname)" == MINGW* ]]; then
|
|
|
|
echo "ac_add_options --disable-update-agent" >> .mozconfig
|
|
|
|
echo "ac_add_options --disable-default-browser-agent" >> .mozconfig
|
|
|
|
|
|
|
|
DLL_FILE=""
|
|
|
|
if [[ $1 == "--win64" ]]; then
|
|
|
|
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')
|
|
|
|
else
|
|
|
|
echo "-- building win32 build on MINGW"
|
|
|
|
DLL_FILE=$("C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find '**\Redist\MSVC\*\x86\**\vcruntime140.dll')
|
|
|
|
fi
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
if [[ "$(uname)" == MINGW* || "$(uname)" == "Darwin" ]]; then
|
|
|
|
# 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
|
|
|
|
2021-08-06 20:16:14 +03:00
|
|
|
if [[ $1 != "--juggler" ]]; then
|
|
|
|
# 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
|
|
|
|
|
2021-04-10 08:13:19 +03:00
|
|
|
if [[ $1 == "--full" || $2 == "--full" ]]; then
|
2021-06-11 12:04:08 +03:00
|
|
|
if [[ "$(uname)" == "Darwin" || "$(uname)" == "Linux" ]]; then
|
2021-06-01 23:16:45 +03:00
|
|
|
SHELL=/bin/sh ./mach --no-interactive bootstrap --application-choice=browser
|
2021-04-10 08:13:19 +03:00
|
|
|
fi
|
|
|
|
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
|
|
|
|
|
|
|
|
if ! [[ -f "$HOME/.mozbuild/_virtualenvs/mach/bin/python" ]]; then
|
|
|
|
./mach create-mach-environment
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "--juggler" ]]; then
|
|
|
|
./mach build faster
|
2021-09-13 18:01:35 +03:00
|
|
|
else
|
|
|
|
./mach build
|
2021-04-10 08:13:19 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
2021-08-07 15:32:18 +03:00
|
|
|
node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist
|
2021-04-10 08:13:19 +03:00
|
|
|
else
|
2021-08-07 15:32:18 +03:00
|
|
|
node "${SCRIPT_FOLDER}"/install-preferences.js "$PWD"/${OBJ_FOLDER}/dist/bin
|
2021-04-10 08:13:19 +03:00
|
|
|
fi
|
|
|
|
|