-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·236 lines (176 loc) · 7.01 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·236 lines (176 loc) · 7.01 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/usr/bin/env zsh
# Make build script work from anywhere:
PARENT_PATH=${0:a:h}
pushd $PARENT_PATH
# helpers for color
normal=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 2)
blue=$(tput setaf 4)
# disables commands outputs:
set +x
BUILD_TYPE=Release
MAC_CLANG=`xcrun --sdk macosx --find clang++`
MAC_SDK_PATH=`xcrun --sdk macosx --show-sdk-path`
MAC_BUILD_TARGET=arm64
MAC_TARGET=arm64-apple-darwin22.1.0
IOS_CLANG=`xcrun --sdk iphoneos --find clang++`
IOS_SDK_PATH=`xcrun --sdk iphoneos --show-sdk-path`
BUILD_FLAGS=(-O3 -ffast-math -flto)
LINKING_FLAGS=(-flto)
LINKING_FLAGS+=(-Wl -rpath @executable_path/.)
LINKING_FLAGS+=(-Wl -rpath @executable_path/../Frameworks/.)
# Dependencies:
printf ":: Checking out submodules... "
didUpdate=`git submodule update --init --recursive`
printf "${green}DONE!${normal}\n"
# Might want to grab jemallopc
printf ":: Building oneTBB... "
pushd 3rd_party/oneTBB
if [ ! -e mac/lib/libtbb.a ]; then
mkdir -p build_mac
pushd build_mac
cmake -S .. -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DTBB_STRICT=OFF -DTBB_ENABLE_IPO=OFF \
-DCMAKE_CXX_EXTENSIONS=OFF -DTBB_TEST=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=../mac &> /dev/null
cmake --build . -j12 --config Release &> /dev/null
cmake --install . &> /dev/null
if [[ ! $? -eq 0 ]]; then
printf "${red}MAC FAILED!${normal}\n";
exit 1
fi
popd
fi
printf "${green}[MAC]${normal}";
if [ ! -e ios/lib/libtbb.a ]; then
mkdir -p build_ios
pushd build_ios
cmake -S .. -GXcode -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DTBB_STRICT=OFF -DTBB_ENABLE_IPO=OFF \
-DCMAKE_CXX_EXTENSIONS=OFF -DTBB_TEST=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=../ios &> /dev/null
xcodebuild -project TBB.xcodeproj -sdk iphoneos -arch arm64 -target tbb -target tbbmalloc -configuration Release -quiet &> /dev/null
cmake --install . &> /dev/null
if [[ ! $? -eq 0 ]]; then
printf "${red}IOS FAILED!${normal}\n";
exit 1
fi
popd
fi
printf "${green}[IOS]${normal}";
popd
printf "${green} DONE!${normal}\n";
printf ":: Building Boost... "
pushd 3rd_party/boost
if [ ! -e b2 ]; then
./bootstrap.sh &> /dev/null
fi
printf "${green}[B2]${normal}"
if [ ! -e mac/lib/libboost_iostreams.dylib ]; then
./b2 --clean-all &> /dev/null
./b2 --stagedir=stage/mac-device --prefix=./mac --with-iostreams stage install &> /dev/null
if [[ ! $? -eq 0 ]]; then
printf "${red}MAC FAILED!${normal}\n"
exit 1
fi
fi
printf "${green}[MAC]${normal}"
if [ ! -e ios/lib/libboost_iostreams.a ]; then
./b2 --clean-all &> /dev/null
./b2 -j8 -build-dir=build-ios-device toolset=clang architecture=arm address-model=64 \
target-os=iphone binary-format=mach-o abi=aapcs \
link=static runtime-link=static threading=multi variant=release \
cxxflags="-stdlib=libc++ -std=c++20 -fvisibility=hidden -miphoneos-version-min=15.0" \
--stagedir=stage/ios-device --prefix=./ios \
--with-iostreams stage install &> /dev/null
if [[ ! $? -eq 0 ]]; then
printf "${red}IOS FAILED!${normal}\n"
exit 1
fi
fi
printf "${green}[IOS]${normal}"
popd
printf "${green} DONE!${normal}\n"
# TODO(jhenriques): Next is openvdb:
printf ":: Building openvdb... "
pushd 3rd_party/openvdb
if [ ! -e mac/lib/libopenvdb.a ]; then
mkdir -p build_mac
pushd build_mac
cmake -S .. -DTBB_INCLUDEDIR=$PARENT_PATH/3rd_party/oneTBB/mac/include -DTBB_LIBRARYDIR=$PARENT_PATH/3rd_party/oneTBB/mac/lib \
-DBoost_DIR=$PARENT_PATH/3rd_party/boost/mac/lib/cmake/Boost-1.91.0 \
-DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF -DOPENVDB_BUILD_UNITTESTS=OFF \
-DUSE_BLOSC=OFF -DOPENVDB_BUILD_BINARIES=OFF -DOPENVDB_ENABLE_UNINSTALL=OFF -DCMAKE_INSTALL_PREFIX=../mac \
-DUSE_STATIC_DEPENDENCIES=ON -DBUILD_SHARED_LIBS=ON -DUSE_BLOSC=OFF -DUSE_ZLIB=OFF &> /dev/null
cmake --build . -j12 --config Release &> /dev/null
cmake --install . &> /dev/null
if [[ ! $? -eq 0 ]]; then
printf "${red}MAC FAILED!${normal}\n"
exit 1
fi
popd
fi
printf "${green}[MAC]${normal}"
if [ ! -e ios/lib/libopenvdb.a ]; then
mkdir -p build_ios
pushd build_ios
# same as mac:
cmake -S .. -GXcode -DTBB_INCLUDEDIR=$PARENT_PATH/3rd_party/oneTBB/ios/include -DTBB_LIBRARYDIR=$PARENT_PATH/3rd_party/oneTBB/ios/lib \
-DBoost_DIR=$PARENT_PATH/3rd_party/boost/ios/lib/cmake/Boost-1.91.0 \
-DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF -DOPENVDB_BUILD_UNITTESTS=OFF \
-DUSE_BLOSC=OFF -DOPENVDB_BUILD_BINARIES=OFF -DOPENVDB_ENABLE_UNINSTALL=OFF -DCMAKE_INSTALL_PREFIX=../ios \
-DUSE_STATIC_DEPENDENCIES=ON -DBUILD_SHARED_LIBS=OFF -DUSE_BLOSC=OFF -DUSE_ZLIB=OFF -DBoost_USE_STATIC_RUNTIME=ON &> /dev/null
xcodebuild -project openVDB.xcodeproj -sdk iphoneos -arch arm64 -target install \
CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_STYLE=Manual -configuration Release -quiet &> /dev/null
cmake --install . &> /dev/null
popd
fi
printf "${green}[IOS]${normal}"
popd
printf "${green} DONE!${normal}\n"
# FINALLY, THE MAIN TARGETS:
BUILD_FOLDER="build"
SRC_FOLDER="../src"
if [ ! -d "$BUILD_FOLDER" ]; then
mkdir -p $BUILD_FOLDER
fi
pushd $BUILD_FOLDER
printf ":: Building Server..."
$MAC_CLANG ${=BUILD_FLAGS} -std=c++20 -fPIC -fobjc-arc -isysroot $MAC_SDK_PATH --target=$MAC_TARGET \
-I../3rd_party/asio/include/ -I../3rd_party/oneTBB/include -I../3rd_party/openvdb/include \
-Wno-format-security -c $SRC_FOLDER/server.cpp -o macOS_server.o
if [[ ! $? -eq 0 ]]; then
printf "${red}MAC FAILED COMPILATION!${normal}\n"
exit 1
fi
$MAC_CLANG ${=BUILD_FLAGS} ${=LINKING_FLAGS} -std=c++20 -fPIC -fobjc-arc -isysroot $MAC_SDK_PATH --target=$MAC_TARGET \
-L../3rd_party/openvdb/lib \
-lopenvdb \
macOS_server.o -o server
if [[ ! $? -eq 0 ]]; then
printf "${red}MAC FAILED LINKING!${normal}\n"
exit 1
fi
printf "${green}[MAC]${normal}"
printf "${green} DONE!${normal}\n"
printf ":: Building Client..."
$MAC_CLANG ${=BUILD_FLAGS} -std=c++20 -fPIC -fobjc-arc -isysroot $MAC_SDK_PATH --target=$MAC_TARGET \
-I../3rd_party/asio/include/ -I../3rd_party/oneTBB/include -I../3rd_party/openvdb/include \
-Wno-format-security -c $SRC_FOLDER/client.cpp -o macOS_client.o
if [[ ! $? -eq 0 ]]; then
printf "${red}MAC FAILED COMPILATION!${normal}\n"
exit 1
fi
$MAC_CLANG ${=BUILD_FLAGS} ${=LINKING_FLAGS} -std=c++20 -fPIC -fobjc-arc -isysroot $MAC_SDK_PATH --target=$MAC_TARGET \
-L../3rd_party/openvdb/lib \
-lopenvdb \
macOS_client.o -o client
if [[ ! $? -eq 0 ]]; then
printf "${red}MAC FAILED LINKING!${normal}\n"
exit 1
fi
printf "${green}[MAC]${normal}"
printf "${green} DONE!${normal}\n"
popd
mkdir -p binaries
cp $BUILD_FOLDER/server binaries
cp $BUILD_FOLDER/client binaries
cp 3rd_party/openvdb/lib/libopenvdb.13.0.dylib binaries
popd #$PARENT_PATH