#!/usr/bin/env bash set -euo pipefail usage() { echo "Usage: $(basename "$0") [force|missing] [Release|RelWithDebInfo|Debug] [--profile=] [--build-profile=] [--variant=toolmode|game] [--unity=ON|OFF] [--tracy=True|False]" echo " force - Rebuild all packages from source" echo " missing - Only build packages not already cached" echo " build_type (optional) - One of: Release, RelWithDebInfo, Debug" echo " If omitted, all build types are processed" echo " --profile= (optional) - Conan host profile under ./ConanProfiles/host (default: clang)" echo " --build-profile= (optional) - Conan build profile under ./ConanProfiles/build" echo " If omitted, it is derived from --profile: ./ConanProfiles/build/clang," echo " or .../clang_asan when contains 'asan'" echo " --variant= (optional) - One of: toolmode, game. If omitted, both are processed" echo " --unity= (optional) - Sets CMAKE_UNITY_BUILD. If omitted, CMake's own default applies" echo " --tracy= (optional) - Sets the bigfoot/*:tracy option (default: True)" } # ─── Validate arguments ─────────────────────────────────────────────────────── if [[ $# -lt 1 ]]; then usage exit 1 fi case "$1" in force) build_option="--build=*" ;; missing) build_option="--build=missing" ;; *) usage exit 1 ;; esac shift profile_name="clang" build_profile_arg="" variant_arg="" unity_val="" tracy_val="True" build_type_arg="" for arg in "$@"; do case "$arg" in --profile=*) profile_name="${arg#--profile=}" ;; --build-profile=*) build_profile_arg="${arg#--build-profile=}" ;; --variant=*) variant_arg="${arg#--variant=}" case "$variant_arg" in toolmode|game) ;; *) echo "ERROR: Invalid variant '${variant_arg}'. Must be one of: toolmode, game" exit 1 ;; esac ;; --unity=*) unity_val="${arg#--unity=}" case "$unity_val" in ON|OFF) ;; *) echo "ERROR: Invalid value for --unity '${unity_val}'. Must be ON or OFF" exit 1 ;; esac ;; --tracy=*) tracy_val="${arg#--tracy=}" case "$tracy_val" in True|False) ;; *) echo "ERROR: Invalid value for --tracy '${tracy_val}'. Must be True or False" exit 1 ;; esac ;; Release|RelWithDebInfo|Debug) if [[ -n "$build_type_arg" ]]; then echo "ERROR: build type specified more than once" exit 1 fi build_type_arg="$arg" ;; *) echo "ERROR: Unrecognized argument '${arg}'" usage exit 1 ;; esac done all_build_types=(Release RelWithDebInfo Debug) if [[ -n "$build_type_arg" ]]; then build_types=("$build_type_arg") else build_types=("${all_build_types[@]}") fi if [[ -n "$variant_arg" ]]; then variants=("$variant_arg") else variants=(toolmode game) fi # ─── Register remote (skip if already registered) ───────────────────────────── if conan remote list 2>/dev/null | grep -qi "bigfootpackages"; then echo "Conan remote 'bigfootpackages' already registered, skipping." else echo "Adding Conan remote: bigfootpackages" if ! conan remote add bigfootpackages https://conan.romainboullard.com/artifactory/api/conan/BigfootPackages; then echo "ERROR: Failed to add Conan remote." exit 1 fi fi # ─── Shared flags ───────────────────────────────────────────────────────────── host_profile="./ConanProfiles/host/${profile_name}" if [[ -n "$build_profile_arg" ]]; then build_profile="./ConanProfiles/build/${build_profile_arg}" else build_profile="./ConanProfiles/build/clang" if [[ "$profile_name" == *asan* ]]; then build_profile="./ConanProfiles/build/clang_asan" fi fi conan_common_base=( --remote=bigfootpackages -pr:h="${host_profile}" -pr:b="${build_profile}" -o "bigfoot/*:build_tests=True" -o "bigfoot/*:build_benchmarks=True" -o "bigfoot/*:tracy=${tracy_val}" -o "bigfoot/*:vulkan=True" ) # ─── Install dependencies for each build type/variant ───────────────────────── for build_type in "${build_types[@]}"; do echo echo "[${build_type}] Installing dependencies..." config_profile="./ConanProfiles/Configurations/${build_type,,}" if [[ "$profile_name" == *asan* && "$build_type" == "Release" ]]; then config_profile="./ConanProfiles/Configurations/release_noipo" fi for variant in "${variants[@]}"; do toolmode_val="False" [[ "$variant" == "toolmode" ]] && toolmode_val="True" if ! conan install . "${conan_common_base[@]}" ${build_option} \ -pr:h="${config_profile}" -pr:b="${config_profile}" \ -o "bigfoot/*:toolmode=${toolmode_val}" \ -of "build-linux-${variant}"; then echo "ERROR: conan install failed for build type ${build_type} (${variant})" exit 1 fi done echo "[${build_type}] Done." done echo echo "All build types installed successfully." # ─── Configure CMake for each build type ───────────────────────────────────── echo echo "Configuring CMake for each build type..." unity_args=() if [[ -n "$unity_val" ]]; then unity_args=(-DCMAKE_UNITY_BUILD="${unity_val}") fi for build_type in "${build_types[@]}"; do echo echo "[${build_type}] Activating build environment..." for variant in "${variants[@]}"; do # shellcheck disable=SC1090 source "build-linux-${variant}/build/${build_type}/generators/conanbuild.sh" mkdir -p "graphviz-linux-${variant}/${build_type}" echo "[${build_type}] Running CMake (${variant})..." if ! cmake -S . -B "build-linux-${variant}/${build_type}" \ --toolchain "build-linux-${variant}/build/${build_type}/generators/conan_toolchain.cmake" \ -DCMAKE_BUILD_TYPE="${build_type}" \ "${unity_args[@]}" \ -G "Ninja" \ --graphviz="graphviz-linux-${variant}/${build_type}/graph.dot"; then echo "ERROR: CMake configuration failed for build type ${build_type} (${variant})." exit 1 fi done echo "[${build_type}] Done." done echo echo "CMake configuration successful."