forked from flowkey/swift-android-toolchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swiftpm.sh
executable file
·50 lines (40 loc) · 1.42 KB
/
swiftpm.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
#!/bin/bash
set -e
readonly SCRIPT_ROOT=$(cd $(dirname $0); echo -n $PWD) # path of this file
source "${SCRIPT_ROOT}/setup.sh"
readonly SCRATCH_PATH="swiftpm-build"
readonly BUILD_TYPE=${BUILD_TYPE:-release}
if [ ${ANDROID_ABI} = "armeabi-v7a" ]; then
TARGET_TRIPLE="armv7-unknown-linux-androideabi24"
elif [ ${ANDROID_ABI} = "x86_64" ]; then
TARGET_TRIPLE="x86_64-unknown-linux-android24"
else # assume arm64
TARGET_TRIPLE="aarch64-unknown-linux-android24"
fi
if [ -f ${SCRATCH_PATH}/${ANDROID_ABI}-${BUILD_TYPE}.yaml ]
then
cp -f ${SCRATCH_PATH}/${ANDROID_ABI}-${BUILD_TYPE}.yaml ${SCRATCH_PATH}/${BUILD_TYPE}.yaml
fi
if [ -f ${SCRATCH_PATH}/${ANDROID_ABI}-${BUILD_TYPE}.db ]
then
cp -f ${SCRATCH_PATH}/${ANDROID_ABI}-${BUILD_TYPE}.db ${SCRATCH_PATH}/build.db
fi
function swiftBuild {
${TOOLCHAIN_PATH}/usr/bin/swift build \
--swift-sdk ${TARGET_TRIPLE} \
--toolchain ${TOOLCHAIN_PATH} \
--scratch-path ${SCRATCH_PATH} \
-c ${BUILD_TYPE} \
-Xcc -fPIC \
$@
}
swiftBuild $@
# Speed up subsequent incremental builds
cp -f ${SCRATCH_PATH}/${BUILD_TYPE}.yaml ${SCRATCH_PATH}/${ANDROID_ABI}-${BUILD_TYPE}.yaml
cp -f ${SCRATCH_PATH}/build.db ${SCRATCH_PATH}/${ANDROID_ABI}-${BUILD_TYPE}.db
if [ "$LIBRARY_OUTPUT_DIRECTORY" ]
then
copySwiftDependencyLibs
mkdir -p ${LIBRARY_OUTPUT_DIRECTORY}
cp -f $(swiftBuild $@ --show-bin-path)/*.so "${LIBRARY_OUTPUT_DIRECTORY}"
fi