forked from hailo-ai/hailo-apps-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_postprocess.sh
executable file
·60 lines (48 loc) · 1.37 KB
/
compile_postprocess.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
56
57
58
59
60
#!/bin/bash
# Set the project directory name
PROJECT_DIR="."
# Enable strict error handling
set -e
# Check if Meson and Ninja are installed
if ! command -v meson &> /dev/null; then
echo "Error: Meson is not installed. Please install it and try again."
exit 1
fi
if ! command -v ninja &> /dev/null; then
echo "Error: Ninja is not installed. Please install it and try again."
exit 1
fi
# Get the build mode from the command line (default to release)
if [ "$1" = "debug" ]; then
BUILD_MODE="debug"
elif [ "$1" = "clean" ]; then
BUILD_MODE="release" # Default to release for cleanup
CLEAN=true
else
BUILD_MODE="release"
fi
# Set up the build directory
BUILD_DIR="$PROJECT_DIR/build.$BUILD_MODE"
# Handle cleanup
if [ "$CLEAN" = true ]; then
echo "Cleaning build directory..."
rm -rf "$BUILD_DIR"
exit 0
fi
# Create the build directory
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# Configure the project with Meson if not already configured
if [ ! -f "build.ninja" ]; then
echo "Configuring project with Meson..."
meson setup .. --buildtype="$BUILD_MODE"
else
echo "Build directory already configured. Skipping setup."
fi
# Compile the project using Ninja with parallel jobs
echo "Building project with Ninja..."
ninja -j$(nproc)
# Install the project (optional)
echo "Installing project..."
ninja install
echo "Build completed successfully!"