-
Notifications
You must be signed in to change notification settings - Fork 6
/
swift-build.sh
executable file
·52 lines (41 loc) · 1.38 KB
/
swift-build.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
#!/bin/bash
set -e
readonly SCRIPT_ROOT=$(cd $(dirname $0); echo -n $PWD) # path of this file
source "${SCRIPT_ROOT}/setup.sh"
configure() {
echo "Configure ${CMAKE_BUILD_TYPE} for ${ANDROID_ABI}"
cmake \
-G Ninja \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_PLATFORM=android-24 \
-DANDROID_NDK="${ANDROID_NDK_PATH}" \
-DSWIFT_SDK="${SWIFT_SDK_PATH}" \
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake" \
-C "${SCRIPT_ROOT}/cmake_caches.cmake" \
-DCMAKE_Swift_COMPILER="${TOOLCHAIN_PATH}/usr/bin/swiftc" \
-DCMAKE_Swift_COMPILER_FORCED=TRUE \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${LIBRARY_OUTPUT_DIRECTORY} \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-S ${PROJECT_DIRECTORY} \
-B ${BUILD_DIR}
echo "Finished configure ${CMAKE_BUILD_TYPE} for ${ANDROID_ABI}"
}
build() {
# reconfigure when build dir does not exist
[[ -d ${BUILD_DIR} ]] || configure
echo "Compiling ${CMAKE_BUILD_TYPE} for ${ANDROID_ABI}"
cmake --build ${BUILD_DIR} #--verbose
echo finished build ${CMAKE_BUILD_TYPE} for ${ANDROID_ABI}
copySwiftDependencyLibs
echo "Finished compiling ${CMAKE_BUILD_TYPE} for ${ANDROID_ABI}"
}
for arg in "$@"
do
case $arg in
-c|--configure)
configure
exit 0
;;
esac
done
build