11#! /bin/bash
22set -e
33
4+ # Colors
5+ BOLD=" \033[1m"
6+ RESET=" \033[0m"
7+ RED=" \033[31m"
8+ GREEN=" \033[32m"
9+ YELLOW=" \033[33m"
10+ BLUE=" \033[34m"
11+ CYAN=" \033[36m"
12+ WHITE=" \033[37m"
13+ DIM=" \033[2m"
14+
15+ info () { echo -e " ${BOLD}${BLUE} [atta]${RESET} $* " ; }
16+ success () { echo -e " ${BOLD}${GREEN} [atta]${RESET} $* " ; }
17+ warn () { echo -e " ${BOLD}${YELLOW} [atta]${RESET} $* " ; }
18+ error () { echo -e " ${BOLD}${RED} [atta]${RESET} $* " ; }
19+ section () { echo -e " \n${BOLD}${CYAN} ━━━ $* ${RESET} " ; }
20+
421SCRIPT_PATH=" $( cd -- " $( dirname " $0 " ) " > /dev/null 2>&1 ; pwd -P ) "
522SOURCE_PATH=" $SCRIPT_PATH "
623BUILD_PATH=" $SOURCE_PATH /build"
@@ -19,75 +36,73 @@ CMAKE_VULKAN="-DATTA_VULKAN_SUPPORT=ON"
1936
2037printHelp ()
2138{
22- echo " Atta build script"
39+ echo -e " ${BOLD} Atta build script${RESET} "
2340 echo
24- echo " Usage: ./build.sh [option(s)]"
41+ echo -e " Usage: ${CYAN} ./build.sh${RESET} ${DIM} [option(s)]${RESET} "
2542 echo
26- echo " Options:"
43+ echo -e " ${BOLD} Options:${RESET} "
2744 echo
28- echo " -h or --help"
29- echo " This help menu"
45+ echo -e " ${YELLOW} -h ${RESET} , ${YELLOW} --help${RESET} "
46+ echo -e " This help menu"
3047 echo
31- echo " -t or --type <option>"
32- echo " Which type of build."
33- echo " Valid options are: default, web, web_module, docs"
48+ echo -e " ${YELLOW} -t ${RESET} , ${YELLOW} --type${RESET} ${DIM} <option>${RESET} "
49+ echo -e " Which type of build."
50+ echo -e " Valid options are: ${CYAN} default${RESET} , ${CYAN} web${RESET} , ${CYAN} web_module${RESET} , ${CYAN} docs${RESET} "
3451 echo
35- echo " -d or --debug"
36- echo " Build with debug information."
52+ echo -e " ${YELLOW} -d ${RESET} , ${YELLOW} --debug${RESET} "
53+ echo -e " Build with debug information."
3754 echo
38- echo " -D or --debugger"
39- echo " Run with a debugger (prefers LLDB, falls back to GDB)."
55+ echo -e " ${YELLOW} -D ${RESET} , ${YELLOW} --debugger${RESET} "
56+ echo -e " Run with a debugger (prefers LLDB, falls back to GDB)."
4057 echo
41- echo " -c or --compiler <name>"
42- echo " Select the compiler."
58+ echo -e " ${YELLOW} -c ${RESET} , ${YELLOW} --compiler${RESET} ${DIM} <name>${RESET} "
59+ echo -e " Select the compiler."
4360 echo
44- echo " -j or --jobs <num_jobs>"
45- echo " Set number of jobs to use when building."
61+ echo -e " ${YELLOW} -j ${RESET} , ${YELLOW} --jobs${RESET} ${DIM} <num_jobs>${RESET} "
62+ echo -e " Set number of jobs to use when building."
4663 echo
47- echo " -s or --static <project_file>"
48- echo " Build statically linked to a project."
49- echo " The file should be a valid .atta"
64+ echo -e " ${YELLOW} -s ${RESET} , ${YELLOW} --static${RESET} ${DIM} <project_file>${RESET} "
65+ echo -e " Build statically linked to a project."
66+ echo -e " The file should be a valid ${DIM} .atta${RESET} "
5067 echo
51- echo " -r or --run"
52- echo " Run after build."
68+ echo -e " ${YELLOW} -r ${RESET} , ${YELLOW} --run${RESET} "
69+ echo -e " Run after build."
5370 echo
54- echo " -p or --project <project_file>"
55- echo " Specify project to run."
71+ echo -e " ${YELLOW} -p ${RESET} , ${YELLOW} --project${RESET} ${DIM} <project_file>${RESET} "
72+ echo -e " Specify project to run."
5673 echo
57- echo " -i or --install"
58- echo " Install after build."
74+ echo -e " ${YELLOW} -i ${RESET} , ${YELLOW} --install${RESET} "
75+ echo -e " Install after build."
5976 echo
60- echo " --disable-vulkan"
61- echo " Disable Vulkan support."
77+ echo -e " ${YELLOW} --disable-vulkan${RESET} "
78+ echo -e " Disable Vulkan support."
6279 exit
6380}
6481
6582buildDefault ()
6683{
67- echo " ---------- Building ----------"
68- # Build
84+ section " Building"
6985 cmake $CMAKE_BUILD_TYPE $CMAKE_COMPILER $CMAKE_ATTA_STATIC $CMAKE_VULKAN $SOURCE_PATH
7086 make -j $NUM_JOBS
87+ success " Build complete"
7188
72- # Install
7389 if [[ " $INSTALL_AFTER " == " true" ]]; then
74- echo " ---------- Installing ----------"
75- sudo make install
90+ section " Installing"
91+ sudo make install
92+ success " Install complete"
7693 fi
7794
78- # Run
7995 if [[ " $RUN_AFTER " == " true" ]]; then
80- echo " ---------- Running ---------- "
96+ section " Running"
8197 if [[ " $USE_DEBUGGER " == " true" ]]; then
82- # Detect available debugger (prefer LLDB)
8398 if command -v lldb & > /dev/null; then
84- echo " Using LLDB for debugging..."
99+ info " Using LLDB for debugging..."
85100 lldb --one-line " run" -- bin/atta -- $PROJECT_TO_RUN
86101 elif command -v gdb & > /dev/null; then
87- echo " Using GDB for debugging..."
102+ info " Using GDB for debugging..."
88103 gdb -ex r --args bin/atta $PROJECT_TO_RUN
89104 else
90- echo -e " \033[1m\033[31m[Error] \033[0m\033[31mNo debugger found (LLDB or GDB). Install one to continue."
105+ error " No debugger found (LLDB or GDB). Install one to continue."
91106 exit 1
92107 fi
93108 else
@@ -100,10 +115,9 @@ buildDefault()
100115
101116buildWeb ()
102117{
103- # Check if emscripten is installed
104118 if ! command -v emcmake & > /dev/null
105119 then
106- echo -e " \033[1m\033[31m[Error] \033[0m\033[31mEmscripten is not installed, please follow the instruction here: \033[37mhttps ://emscripten.org/docs/getting_started/downloads.html"
120+ error " Emscripten is not installed, please follow the instructions at: ${WHITE} https ://emscripten.org/docs/getting_started/downloads.html${RESET} "
107121 exit
108122 fi
109123
@@ -112,14 +126,13 @@ buildWeb()
112126 CMAKE_MODULE=" -DATTA_WEB_BUILD_MODULE=ON"
113127 fi
114128
115- # Build
116- echo " ---------- Building web ----------"
129+ section " Building web"
117130 emcmake cmake $CMAKE_MODULE $CMAKE_BUILD_TYPE $CMAKE_ATTA_STATIC $SOURCE_PATH
118131 make -j $NUM_JOBS
132+ success " Web build complete"
119133
120- # Run
121134 if [[ " $RUN_AFTER " == " true" ]]; then
122- echo " ---------- Running web ---------- "
135+ section " Running web"
123136 emrun bin/atta.html
124137 fi
125138
@@ -128,9 +141,10 @@ buildWeb()
128141
129142buildDocs ()
130143{
131- echo " ---------- Building docs ---------- "
144+ section " Building docs"
132145 cmake -ATTA_BUILD_DOCS=ON -DATTA_BUILD_TESTS=OFF $SOURCE_PATH
133146 make -j $NUM_JOBS
147+ success " Docs build complete"
134148 exit
135149}
136150
@@ -192,7 +206,7 @@ while [[ $# -gt 0 ]]; do
192206 shift
193207 ;;
194208 -* |--* )
195- echo " Unknown option $1 "
209+ error " Unknown option $1 "
196210 exit
197211 ;;
198212 esac
@@ -215,7 +229,7 @@ docs)
215229 buildDocs
216230 ;;
217231* )
218- echo " Unknown build type $BUILD_TYPE "
232+ error " Unknown build type ${BOLD} $ BUILD_TYPE${RESET} "
219233 exit
220234 ;;
221235esac
0 commit comments