this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at rustic 162 lines 4.5 kB view raw
1#!/bin/bash 2 3FRESH=false 4ASAN=false 5PRO=false 6DEBUG=false 7MACPORTS=false 8HOMEBREW=false 9STATIC=false 10WARNINGS=false 11BUILD_TYPE="MinSizeRel" 12COMPILER_FLAGS="" 13DEBUG_FLAGS="" 14PRO_VERSION_FLAG="" 15STATIC_FLAG="" 16WARNING_FLAGS="-Wall -Wextra" 17 18while (( "$#" )); do 19 case "$1" in 20 -f|--fresh) 21 FRESH=true 22 shift 23 ;; 24 -a|--asan) 25 ASAN=true 26 shift 27 ;; 28 -p|--pro) 29 PRO=true 30 shift 31 ;; 32 -d|--debug) 33 DEBUG=true 34 shift 35 ;; 36 -m|--macports) 37 MACPORTS=true 38 shift 39 ;; 40 -h|--homebrew) 41 HOMEBREW=true 42 shift 43 ;; 44 -s|--static) 45 STATIC=true 46 shift 47 ;; 48 -w|--warnings) 49 WARNINGS=true 50 shift 51 ;; 52 --) 53 shift 54 break 55 ;; 56 -*) 57 echo "Unknown option: $1" >&2 58 exit 1 59 ;; 60 *) 61 echo "Invalid argument: $1" >&2 62 exit 1 63 ;; 64 esac 65done 66 67if [ "$MACPORTS" = true ] && [ "$HOMEBREW" = true ]; then 68 echo "Error: -m/--macports and -h/--homebrew options are mutually exclusive." 69 exit 1 70fi 71 72# remove MacPorts from PATH if we're not using it or we're using Homebrew 73if [ "$MACPORTS" = false ] || [ "$HOMEBREW" = true ]; then 74 PATH=${PATH/\/opt\/local\/bin:/} 75fi 76 77if [ "$FRESH" = true ]; then 78 rm -rf .cache CMakeCache.txt CMakeFiles/ cmake_install.cmake 79 rm -rf build && git restore 'build/*' 80fi 81 82if [ "$ASAN" = true ]; then 83 DEBUG=true 84 DEBUG_FLAGS="-DBUILD_NO_OPTIMIZATION=On -DBUILD_ASAN_DEBUG=On" 85fi 86 87if [ "$PRO" = true ]; then 88 PRO_VERSION_FLAG="-DBUILD_PRO=On" 89fi 90 91if [ "$DEBUG" = true ]; then 92 BUILD_TYPE="Debug" 93fi 94 95if [ "$MACPORTS" = true ]; then 96 CLANG=$(which clang) 97 CLANGPP=$(which clang++) 98 if [ -z "$CLANG" ] || [ -z "$CLANGPP" ]; then 99 echo "clang or clang++ not found. Please ensure they are installed and in your PATH." 100 exit 1 101 fi 102 COMPILER_FLAGS="-DCMAKE_C_COMPILER=$CLANG -DCMAKE_CXX_COMPILER=$CLANGPP" 103 export CPPFLAGS='-isystem/opt/local/include' 104 export LDFLAGS='-L/opt/local/lib' 105 echo 106 echo "Using clang at $CLANG and clang++ at $CLANGPP from MacPorts" 107fi 108 109if [ "$HOMEBREW" = true ]; then 110 export PATH="/opt/homebrew/opt/llvm/bin:$PATH" 111 export LDFLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib" 112 export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" 113 114 # Add explicit compiler flags like MacPorts does 115 CLANG="/opt/homebrew/opt/llvm/bin/clang" 116 CLANGPP="/opt/homebrew/opt/llvm/bin/clang++" 117 if [ -z "$CLANG" ] || [ -z "$CLANGPP" ]; then 118 echo "Homebrew clang or clang++ not found. Please ensure llvm is installed via Homebrew." 119 exit 1 120 fi 121 COMPILER_FLAGS="$COMPILER_FLAGS -DCMAKE_C_COMPILER=$CLANG -DCMAKE_CXX_COMPILER=$CLANGPP" 122 123 echo 124 echo "Using clang at $CLANG and clang++ at $CLANGPP from Homebrew" 125fi 126 127if [ "$STATIC" = true ]; then 128 STATIC_FLAG="-DBUILD_STATIC=On" 129fi 130 131if [ "$WARNINGS" = true ]; then 132 COMPILER_FLAGS="$COMPILER_FLAGS -DCMAKE_C_FLAGS=$WARNING_FLAGS -DCMAKE_CXX_FLAGS=$WARNING_FLAGS" 133fi 134 135echo 136echo "+--------------------------------+-------+" 137echo "| Build Options | Value |" 138echo "+--------------------------------+-------+" 139echo "| Fresh build (-f, --fresh) | $(printf "%-5s" $([ "$FRESH" = true ] && echo "Yes" || echo "No")) |" 140echo "| Address Sanitizer (-a, --asan) | $(printf "%-5s" $([ "$ASAN" = true ] && echo "Yes" || echo "No")) |" 141echo "| Pro version (-p, --pro) | $(printf "%-5s" $([ "$PRO" = true ] && echo "Yes" || echo "No")) |" 142echo "| Debug build (-d, --debug) | $(printf "%-5s" $([ "$DEBUG" = true ] && echo "Yes" || echo "No")) |" 143echo "| MacPorts (-m, --macports) | $(printf "%-5s" $([ "$MACPORTS" = true ] && echo "Yes" || echo "No")) |" 144echo "| Homebrew (-h, --homebrew) | $(printf "%-5s" $([ "$HOMEBREW" = true ] && echo "Yes" || echo "No")) |" 145echo "| Static build (-s, --static) | $(printf "%-5s" $([ "$STATIC" = true ] && echo "Yes" || echo "No")) |" 146echo "| Warnings (-w, --warnings) | $(printf "%-5s" $([ "$WARNINGS" = true ] && echo "Yes" || echo "No")) |" 147echo "+--------------------------------+-------+" 148echo 149 150cd ./build || exit 151 152cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ 153 $PRO_VERSION_FLAG \ 154 -DBUILD_SDLGPU=On \ 155 $DEBUG_FLAGS \ 156 $COMPILER_FLAGS \ 157 $STATIC_FLAG \ 158 -DBUILD_WITH_ALL=On \ 159 -DCMAKE_EXPORT_COMPILE_COMMANDS=On \ 160 -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ 161 .. && \ 162cmake --build . --config "$BUILD_TYPE" --parallel