|
|
|
|
@ -7,6 +7,7 @@ MODE=normal
|
|
|
|
|
CLEAN=0 |
|
|
|
|
FULL=0 |
|
|
|
|
BUILD_GUI=1 |
|
|
|
|
BUILD_INSTALLER=0 |
|
|
|
|
JOBS=4 |
|
|
|
|
MAKE_ARGS=() |
|
|
|
|
MAKE_SETTINGS=() |
|
|
|
|
@ -15,18 +16,20 @@ STATE=.utun-build-state
|
|
|
|
|
while [[ $# -gt 0 ]]; do |
|
|
|
|
case "$1" in |
|
|
|
|
-h|--help) |
|
|
|
|
echo "Usage: ./build.sh [--clean] [--full] [--asan|--hardened] [--no-gui] [-jN] [make arguments]" |
|
|
|
|
echo "Usage: ./build.sh [--clean] [--full] [--asan|--hardened] [--no-gui] [--installer] [-jN] [make arguments]" |
|
|
|
|
echo " --clean Rebuild objects without forcing configure" |
|
|
|
|
echo " --full Regenerate, configure and rebuild everything" |
|
|
|
|
echo " --asan AddressSanitizer; skip tests" |
|
|
|
|
echo " --hardened Enable compiler security hardening" |
|
|
|
|
echo " --no-gui Skip the separately configured ChatGUI" |
|
|
|
|
echo " --installer Build Windows ChatGUI in Release and create its Inno Setup installer" |
|
|
|
|
echo " -jN, -j N Parallel jobs (default: 4)" |
|
|
|
|
echo " CC/CFLAGS/CPPFLAGS/LDFLAGS/LIBS assignments are passed to configure" |
|
|
|
|
exit 0 ;; |
|
|
|
|
--clean) CLEAN=1 ;; |
|
|
|
|
--full) FULL=1 ;; |
|
|
|
|
--no-gui) BUILD_GUI=0 ;; |
|
|
|
|
--installer) BUILD_INSTALLER=1 ;; |
|
|
|
|
--asan|--hardened) |
|
|
|
|
selected_mode=${1#--} |
|
|
|
|
if [[ "$MODE" != normal && "$MODE" != "$selected_mode" ]]; then |
|
|
|
|
@ -47,6 +50,10 @@ while [[ $# -gt 0 ]]; do
|
|
|
|
|
shift |
|
|
|
|
done |
|
|
|
|
[[ "$JOBS" =~ ^[1-9][0-9]*$ ]] || { echo "ERROR: invalid job count: $JOBS" >&2; exit 1; } |
|
|
|
|
if [[ "$BUILD_INSTALLER" = 1 ]]; then |
|
|
|
|
[[ "$BUILD_GUI" = 1 && "$MODE" = normal ]] || { echo "ERROR: --installer requires GUI and normal build mode" >&2; exit 1; } |
|
|
|
|
bash tools/chatgui/package_win.sh --check |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
PLATFORM=$(uname -s) |
|
|
|
|
MAKE_TOOL=${MAKE:-make} |
|
|
|
|
@ -199,11 +206,13 @@ trap 'rm -f "$state_tmp"' EXIT
|
|
|
|
|
printf '%s\n' "$GENERATION_INPUT" "$GENERATION_OUTPUT" "$CONFIG_REQUEST" "$CONFIG_OUTPUT" > "$state_tmp" |
|
|
|
|
mv -f "$state_tmp" "$STATE" |
|
|
|
|
|
|
|
|
|
if [[ "$BUILD_GUI" = 1 && -f tools/chatgui/build/CMakeCache.txt ]]; then |
|
|
|
|
if [[ "$BUILD_GUI" = 1 && ( "$BUILD_INSTALLER" = 1 || -f tools/chatgui/build/CMakeCache.txt ) ]]; then |
|
|
|
|
command -v cmake >/dev/null || { echo "ERROR: ChatGUI exists but cmake is not available" >&2; exit 1; } |
|
|
|
|
echo "INFO: building ChatGUI with its CMake configuration: jobs=$JOBS" |
|
|
|
|
if [[ "${MSYSTEM:-}" = UCRT64 ]]; then |
|
|
|
|
(cd tools/chatgui && bash build.sh "-j$JOBS") || { echo "ERROR: ChatGUI build failed" >&2; exit 1; } |
|
|
|
|
GUI_ARGS=("-j$JOBS") |
|
|
|
|
[[ "$BUILD_INSTALLER" != 1 ]] || GUI_ARGS+=(--installer) |
|
|
|
|
(cd tools/chatgui && bash build.sh "${GUI_ARGS[@]}") || { echo "ERROR: ChatGUI build failed" >&2; exit 1; } |
|
|
|
|
else |
|
|
|
|
cmake --build tools/chatgui/build --parallel "$JOBS" || { echo "ERROR: ChatGUI build failed" >&2; exit 1; } |
|
|
|
|
fi |
|
|
|
|
|