-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·55 lines (44 loc) · 1.01 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
#!/bin/bash
# Exit on error
set -e
# Help message
show_help() {
echo "Usage: ./build.sh [clean] [debug]"
echo " clean Clean build directory before building"
echo " debug Build with debug symbols and flags"
exit 0
}
# Process arguments
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
show_help
fi
# Default build type
BUILD_TYPE="Release"
# Process all arguments
for arg in "$@"; do
case $arg in
clean)
echo "Cleaning build directory..."
rm -rf build
;;
debug)
BUILD_TYPE="Debug"
echo "Setting debug build type..."
;;
esac
done
# Create and enter build directory
mkdir -p build
cd build
# Configure with CMake
echo "Configuring with CMake..."
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
# Build
echo "Building..."
make -j$(sysctl -n hw.ncpu)
# Run tests
echo "Running tests..."
ctest --test-dir tests --output-on-failure
# Return to original directory
cd ..
echo "Build complete! (Build type: $BUILD_TYPE)"