Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·118 lines (96 loc) · 2.73 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·118 lines (96 loc) · 2.73 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Richkware Build Script for Unix-like systems
# Interactive build configuration
set -e
echo "=== Richkware Build Script ==="
echo
# Function to prompt user for input
prompt_user() {
local prompt="$1"
local default="$2"
local response
read -p "$prompt [$default]: " response
echo "${response:-$default}"
}
# Detect current platform
CURRENT_PLATFORM=$(uname -s)
echo "Current platform: $CURRENT_PLATFORM"
# Platform selection
echo
echo "Select target platform:"
echo "1) Current platform ($CURRENT_PLATFORM)"
echo "2) Linux"
echo "3) Windows (Cross-compilation)"
echo "4) macOS"
read -p "Enter choice [1]: " platform_choice
platform_choice=${platform_choice:-1}
case $platform_choice in
1)
TARGET_PLATFORM="$CURRENT_PLATFORM"
;;
2)
TARGET_PLATFORM="Linux"
;;
3)
TARGET_PLATFORM="Windows"
;;
4)
TARGET_PLATFORM="macOS"
;;
*)
echo "Invalid choice. Using current platform."
TARGET_PLATFORM="$CURRENT_PLATFORM"
;;
esac
echo "Target platform: $TARGET_PLATFORM"
# Build type
echo
BUILD_TYPE=$(prompt_user "Build type (Release/Debug)" "Release")
# Build options
echo
echo "Build options:"
ENABLE_TESTS=$(prompt_user "Enable unit tests (ON/OFF)" "ON")
ENABLE_EXAMPLES=$(prompt_user "Enable examples (ON/OFF)" "OFF")
ENABLE_ASAN=$(prompt_user "Enable AddressSanitizer (ON/OFF)" "OFF")
ENABLE_TSAN=$(prompt_user "Enable ThreadSanitizer (ON/OFF)" "OFF")
ENABLE_COVERAGE=$(prompt_user "Enable code coverage (ON/OFF)" "OFF")
# Output directory
BUILD_DIR="build"
if [ "$TARGET_PLATFORM" = "Windows" ]; then
BUILD_DIR="build_windows"
fi
echo
echo "Build directory: $BUILD_DIR"
# Create build directory
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# Configure CMake
echo
echo "Configuring CMake..."
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=$BUILD_TYPE"
CMAKE_ARGS="$CMAKE_ARGS -DRICHKWARE_BUILD_TESTS=$ENABLE_TESTS"
CMAKE_ARGS="$CMAKE_ARGS -DRICHKWARE_BUILD_EXAMPLES=$ENABLE_EXAMPLES"
CMAKE_ARGS="$CMAKE_ARGS -DRICHKWARE_ENABLE_ASAN=$ENABLE_ASAN"
CMAKE_ARGS="$CMAKE_ARGS -DRICHKWARE_ENABLE_TSAN=$ENABLE_TSAN"
CMAKE_ARGS="$CMAKE_ARGS -DRICHKWARE_ENABLE_COVERAGE=$ENABLE_COVERAGE"
# Platform-specific options
if [ "$TARGET_PLATFORM" = "Windows" ]; then
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64.cmake"
echo "Cross-compiling for Windows using MinGW-w64"
fi
echo "CMake command: cmake .. $CMAKE_ARGS"
cmake .. $CMAKE_ARGS
# Build
echo
echo "Building project..."
make -j$(nproc)
echo
echo "Build completed successfully!"
echo "Executables are in: $BUILD_DIR/bin/"
echo "Libraries are in: $BUILD_DIR/lib/"
# Run tests if enabled
if [ "$ENABLE_TESTS" = "ON" ]; then
echo
echo "Running tests..."
ctest --output-on-failure
fi