forked from Geenz/EntropyCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-cmd.sh
More file actions
executable file
·203 lines (171 loc) · 6.95 KB
/
build-cmd.sh
File metadata and controls
executable file
·203 lines (171 loc) · 6.95 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/env bash
cd "$(dirname "$0")"
# turn on verbose debugging output for parabuild logs.
exec 4>&1; export BASH_XTRACEFD=4; set -x
# make errors fatal
set -e
# complain about unset env variables
set -u
if [ -z "$AUTOBUILD" ] ; then
exit 1
fi
if [ "$OSTYPE" = "cygwin" ] ; then
autobuild="$(cygpath -u $AUTOBUILD)"
else
autobuild="$AUTOBUILD"
fi
top="$(pwd)"
stage="$(pwd)/stage"
# Extract version from vcpkg.json
ENTROPYCORE_VERSION=$(grep -o '"version": "[^"]*"' vcpkg.json | cut -d'"' -f4)
# load autobuild provided shell functions and variables
source_environment_tempfile="$stage/source_environment.sh"
"$autobuild" source_environment > "$source_environment_tempfile"
. "$source_environment_tempfile"
build=${AUTOBUILD_BUILD_ID:=0}
# prepare the staging dirs
mkdir -p "$stage/LICENSES"
mkdir -p "$stage/include/EntropyCore"
mkdir -p "$stage/lib/release"
# Bootstrap vcpkg if not already present
VCPKG_ROOT="${VCPKG_ROOT:-$top/vcpkg}"
if [ ! -d "$VCPKG_ROOT" ]; then
echo "Bootstrapping vcpkg..."
git clone https://github.com/Microsoft/vcpkg.git "$VCPKG_ROOT"
"$VCPKG_ROOT/bootstrap-vcpkg.sh" -disableMetrics
fi
# Set up build directory
BUILD_DIR="$top/build_autobuild"
mkdir -p "$BUILD_DIR"
case "$AUTOBUILD_PLATFORM" in
darwin*)
# Build for x64 architecture
BUILD_DIR_X64="$top/build_autobuild_x64"
mkdir -p "$BUILD_DIR_X64"
echo "Building for x86_64..."
cmake -S "$top" -B "$BUILD_DIR_X64" \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET=x64-osx \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DENTROPY_BUILD_TESTS=OFF \
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.3 \
-DCMAKE_INSTALL_PREFIX="$stage/x64"
cmake --build "$BUILD_DIR_X64" --config Release
cmake --install "$BUILD_DIR_X64" --config Release
# Build for arm64 architecture
BUILD_DIR_ARM64="$top/build_autobuild_arm64"
mkdir -p "$BUILD_DIR_ARM64"
echo "Building for arm64..."
cmake -S "$top" -B "$BUILD_DIR_ARM64" \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET=arm64-osx \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DENTROPY_BUILD_TESTS=OFF \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.3 \
-DCMAKE_INSTALL_PREFIX="$stage/arm64"
cmake --build "$BUILD_DIR_ARM64" --config Release
cmake --install "$BUILD_DIR_ARM64" --config Release
# Create universal binaries using lipo
mkdir -p "$stage/lib/release"
echo "Creating universal binary with lipo..."
if [ -f "$stage/x64/lib/libEntropyCore.a" ] && [ -f "$stage/arm64/lib/libEntropyCore.a" ]; then
lipo -create \
"$stage/x64/lib/libEntropyCore.a" \
"$stage/arm64/lib/libEntropyCore.a" \
-output "$stage/lib/release/libEntropyCore.a"
echo "Universal binary created successfully"
else
echo "Error: Could not find architecture-specific libraries"
exit 1
fi
# Copy headers from x64 build (they should be identical)
mkdir -p "$stage/include"
if [ -d "$stage/x64/include" ]; then
cp -R "$stage/x64/include"/* "$stage/include/"
fi
# Clean up architecture-specific staging directories
rm -rf "$stage/x64" "$stage/arm64"
# Move headers to EntropyCore subdirectory
if [ -d "$stage/include" ]; then
mkdir -p "$stage/include/EntropyCore"
# Move all headers preserving structure
for dir in Core Concurrency Debug Graph Logging TypeSystem; do
if [ -d "$stage/include/$dir" ]; then
mv "$stage/include/$dir" "$stage/include/EntropyCore/"
fi
done
# Move root headers
for header in EntropyCore.h CoreCommon.h ServiceLocator.h; do
if [ -f "$stage/include/$header" ]; then
mv "$stage/include/$header" "$stage/include/EntropyCore/"
fi
done
fi
# Code signing for macOS if configured
if [[ -z "${build_secrets_checkout:-}" ]]; then
echo '$build_secrets_checkout not set; skipping codesign' >&2
else
CONFIG_FILE="$build_secrets_checkout/code-signing-osx/config.sh"
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "No config file found; skipping codesign."
else
source $CONFIG_FILE
pushd "$stage/lib/release"
for lib in *.a; do
if [ -f "$lib" ]; then
codesign --force --timestamp --sign "$APPLE_SIGNATURE" "$lib"
fi
done
popd
fi
fi
;;
linux*)
# Configure with CMake using vcpkg toolchain
cmake -S "$top" -B "$BUILD_DIR" \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET=x64-linux \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DENTROPY_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX="$stage"
# Build the project
cmake --build "$BUILD_DIR" --config Release
# Install to staging directory
cmake --install "$BUILD_DIR" --config Release
# Move installed files to expected locations for autobuild
mkdir -p "$stage/lib/release"
if [ -f "$stage/lib/libEntropyCore.a" ]; then
mv "$stage/lib/libEntropyCore.a" "$stage/lib/release/"
fi
# Move headers to EntropyCore subdirectory
if [ -d "$stage/include" ]; then
mkdir -p "$stage/include/EntropyCore"
# Move all headers preserving structure
for dir in Core Concurrency Debug Graph Logging TypeSystem; do
if [ -d "$stage/include/$dir" ]; then
mv "$stage/include/$dir" "$stage/include/EntropyCore/"
fi
done
# Move root headers
for header in EntropyCore.h CoreCommon.h ServiceLocator.h; do
if [ -f "$stage/include/$header" ]; then
mv "$stage/include/$header" "$stage/include/EntropyCore/"
fi
done
fi
;;
esac
# Clean up any empty cmake directories that might have been created
if [ -d "$stage/lib/cmake" ]; then
rm -rf "$stage/lib/cmake"
fi
# Create VERSION.txt
echo "$ENTROPYCORE_VERSION.$build" > "$stage/VERSION.txt"
# Copy license files - both to LICENSES directory and root for autobuild package
cp "$top/LICENSE.md" "$stage/LICENSES/EntropyCore.txt"
cp "$top/LICENSE.md" "$stage/LICENSE.md"