-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.sh
More file actions
executable file
·135 lines (118 loc) · 3.04 KB
/
Copy pathgenerate.sh
File metadata and controls
executable file
·135 lines (118 loc) · 3.04 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# Function to show usage
usage() {
echo "Usage: $0 [options...]"
echo "Options can be provided in any order:"
echo " linux|macos|windows Operating system target (default: linux)"
echo " x64|armv7|arm64 Architecture target (default: x64)"
echo " debug|release Build type (default: debug)"
echo
echo "Example: $0 linux x64 debug"
exit 1
}
# Show usage if help is requested
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
usage
fi
# Set default values
OS="linux"
ARCH="x64"
BUILD_TYPE="debug"
# Process arguments in any order
for arg in "$@"; do
case $arg in
linux|macos|windows)
OS="$arg"
;;
x64|armv7|arm64)
ARCH="$arg"
;;
debug|release)
BUILD_TYPE="$arg"
;;
*)
echo "Error: Unknown option '$arg'"
echo "Valid options are:"
echo " OS: linux, macos, windows"
echo " Architecture: x64, armv7, arm64"
echo " Build type: debug, release"
exit 1
;;
esac
done
# Validate OS
case $OS in
linux|macos|windows)
;;
*)
echo "Error: Invalid OS. Must be linux, macos, or windows"
exit 1
;;
esac
# Validate architecture
case $ARCH in
x64|armv7|arm64)
;;
*)
echo "Error: Invalid architecture. Must be x64, armv7, or arm64"
exit 1
;;
esac
# Validate build type
case $BUILD_TYPE in
debug|release)
;;
*)
echo "Error: Invalid build type. Must be debug or release"
exit 1
;;
esac
# Create build directory name
BUILD_DIR="build/${OS}_${ARCH}_${BUILD_TYPE}"
# Create build directory if it doesn't exist
mkdir -p $BUILD_DIR
# Configure CMake based on OS and architecture
echo "Configuring CMake for $BUILD_TYPE, $OS on $ARCH..."
cd $BUILD_DIR
# Set vcpkg triplet based on OS and architecture
case $OS in
linux)
GENERATOR="Ninja"
VCPKG_TARGET="linux"
;;
windows)
GENERATOR="Visual Studio 17 2022"
VCPKG_TARGET="windows"
;;
macos)
GENERATOR="Ninja"
VCPKG_TARGET="osx"
;;
esac
case $ARCH in
x64)
ARCH_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=x86_64"
VCPKG_ARCH="x64"
;;
arm64)
ARCH_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=armv7"
VCPKG_ARCH="arm64"
;;
armv7)
ARCH_FLAGS="-DCMAKE_SYSTEM_PROCESSOR=aarch64"
VCPKG_ARCH="arm"
;;
esac
VCPKG_TRIPLET="${VCPKG_ARCH}-${VCPKG_TARGET}"
# Convert build type to CMake format (uppercase)
CMAKE_BUILD_TYPE=$(echo $BUILD_TYPE | tr '[:lower:]' '[:upper:]')
# Configure CMake with appropriate options
cmake ../.. \
-G "$GENERATOR" \
-DCMAKE_SYSTEM_NAME=$OS \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
$ARCH_FLAGS \
-DVCPKG_TARGET_TRIPLET=$VCPKG_TRIPLET \
-DCMAKE_TOOLCHAIN_FILE=/opt/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_OVERLAY_PORTS=/app/server/cronus/vcpkg/custom_ports
echo "CMake configuration complete in $BUILD_DIR"