Files
IronFox/scripts/build.sh
celenity 4bde1d952c feat: Improve granularity of the build scripts
Notably, this means that:

- It's now possible to build components individually
    - This should especially be useful for ex. CI, so we can avoid timeouts and improve build speed by building certain components simultaneously

- It's now possible to rebuild only a specific project and its consumers (instead of always having to build everything...)
    - ex. If I make a change to Gecko, I can just use `rebuild-gecko`, which only builds Gecko and its consumers (GeckoView, AC, and Fenix), instead of trying to build everything unconditionally

The default build behavior (ex. if no argument is specified) still remains the same

This also adds checks to ensure that the build script fails fast if important variables are not properly set/configured

Also includes some minor tweaks, such as a renaming of a couple of the CI jobs for clarity, and the addition of an `IRONFOX_TEMP` variable to indicate the temporary build directory

Signed-off-by: celenity <celenity@celenity.dev>
2026-06-17 22:09:00 +00:00

77 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Set-up our environment
if [[ -z "${IRONFOX_SET_ENVS+x}" ]]; then
bash -x $(dirname $0)/env.sh
fi
source $(dirname $0)/env.sh
# Include utilities
source "${IRONFOX_UTILS}"
# Set-up target parameters
if [[ -z "${1+x}" ]]; then
echo_red_text "Usage: $0 arm|arm64|x86_64|bundle" >&1
exit 1
fi
readonly target=$(echo "${1}" | "${IRONFOX_AWK}" '{print tolower($0)}')
if [[ -z "${2+x}" ]]; then
readonly project='fenix'
else
readonly project=$(echo "${2}" | "${IRONFOX_AWK}" '{print tolower($0)}')
fi
# Build IronFox
readonly IRONFOX_FROM_BUILD=1
export IRONFOX_FROM_BUILD
if [[ "${IRONFOX_LOG_BUILD}" == 1 ]]; then
readonly BUILD_LOG_FILE="${IRONFOX_LOG_DIR}/build-${target}.log"
# If the log file already exists, remove it
if [[ -f "${BUILD_LOG_FILE}" ]]; then
rm "${BUILD_LOG_FILE}"
fi
# Ensure our log directory exists
mkdir -vp "${IRONFOX_LOG_DIR}"
bash -x "${IRONFOX_SCRIPTS}/build-if.sh" "${target}" "${project}" > >(tee -a "${BUILD_LOG_FILE}") 2>&1
else
bash -x "${IRONFOX_SCRIPTS}/build-if.sh" "${target}" "${project}"
fi
# We should only try to sign IronFox if we actually built Fenix, so check that first
## (All `rebuild-` targets eventually build Fenix, because eventually Fenix consumes everything...)
if [[ "${project}" == 'fenix' ]] || [[ "${project}" == 'rebuild-ac-core' ]] || [[ "${project}" == 'rebuild-ac' ]] ||
[[ "${project}" == 'rebuild-as' ]] || [[ "${project}" == 'rebuild-fenix' ]] || [[ "${project}" == 'rebuild-gecko' ]] ||
[[ "${project}" == 'rebuild-geckoview' ]] || [[ "${project}" == 'rebuild-glean' ]] || [[ "${project}" == 'rebuild-llvm' ]] ||
[[ "${project}" == 'rebuild-microg' ]] || [[ "${project}" == 'rebuild-nimbus-fml' ]] || [[ "${project}" == 'rebuild-uniffi' ]] ||
[[ "${project}" == 'rebuild-up-ac' ]] || [[ "${project}" == 'rebuild-wasi' ]]; then
readonly IRONFOX_BUILT_FENIX=1
else
readonly IRONFOX_BUILT_FENIX=0
fi
# Sign IronFox
if [[ "${IRONFOX_SIGN}" == 1 ]] && [[ "${IRONFOX_BUILT_FENIX}" == 1 ]]; then
if [[ "${IRONFOX_LOG_SIGN}" == 1 ]]; then
readonly SIGN_LOG_FILE="${IRONFOX_LOG_DIR}/sign.log"
# If the log file already exists, remove it
if [[ -f "${SIGN_LOG_FILE}" ]]; then
rm "${SIGN_LOG_FILE}"
fi
# Ensure our log directory exists
mkdir -vp "${IRONFOX_LOG_DIR}"
bash "${IRONFOX_SCRIPTS}/sign.sh" "${target}" > >(tee -a "${SIGN_LOG_FILE}") 2>&1
else
bash "${IRONFOX_SCRIPTS}/sign.sh" "${target}"
fi
fi