-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.sh
executable file
·47 lines (38 loc) · 1.07 KB
/
dev.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
#!/bin/bash
# Exit script if any command fails
set -e
# Set default build directory if not specified
BUILD_DIR="build"
# Detect the operating system
OS=$(uname)
# Create the build directory if it doesn't exist
if [ ! -d "$BUILD_DIR" ]; then
echo "Build directory $BUILD_DIR does not exist. Creating it now..."
mkdir "$BUILD_DIR"
fi
# Change to the build directory
cd "$BUILD_DIR"
# Run CMake to configure the build system if necessary
if [ ! -f "../CMakeLists.txt" ]; then
echo "CMakeLists.txt not found. Please ensure you're in the correct project directory."
exit 1
fi
# Platform-specific behavior (if needed)
if [[ "$OS" == "Darwin" ]]; then
echo "Running on macOS"
elif [[ "$OS" == "Linux" ]]; then
echo "Running on Linux"
else
echo "Unsupported operating system: $OS"
exit 1
fi
# Run CMake to configure and build the project using Ninja
cmake -G Ninja ..
ninja -v # Verbose build process
# Run the compiled binary
if [[ "$OS" == "Darwin" || "$OS" == "Linux" ]]; then
./main
else
echo "Unsupported platform for running the binary."
exit 1
fi