-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
55 lines (49 loc) · 1.42 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
rebuild=$1
test=$2
num_cores=$(nproc)
# Color codes for styling
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
BLUE="\033[0;34m"
BOLD="\033[1m"
RESET="\033[0m"
# Function to echo colored text
echo_color() {
local color=$1
local message=$2
echo -e "${color}${message}${RESET}"
}
# Function to check if a file exists
check_file_exists() {
if [ ! -f "$1" ]; then
echo_color "$RED" "${BOLD}Error: File '$1' not found.${RESET}"
exit 1
fi
}
echo "------------------------------------------------------------------------------------------------------"
# Build the project
echo_color "$BLUE" "${BOLD}Building from CMake${RESET}"
if [ "$test" == "1" ]; then
echo_color "$BLUE" "${BOLD}Testing software${RESET}"
if ! make unit_test; then
echo_color "$RED" "${BOLD}Error: Build failed.${RESET}"
exit 1
fi
else
echo_color "$BLUE" "${BOLD}Building software${RESET}"
if [ "$rebuild" == "1" ]; then
echo_color "$BLUE" "${BOLD}Rebuilding is True${RESET}"
if ! make build rebuild=1; then
echo_color "$RED" "${BOLD}Error: Build failed.${RESET}"
exit 1
fi
else
if ! make build; then
echo_color "$RED" "${BOLD}Error: Build failed.${RESET}"
exit 1
fi
fi
fi
echo "------------------------------------------------------------------------------------------------------"