forked from open-eid/libdigidocpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-library.sh
executable file
·108 lines (103 loc) · 2.77 KB
/
build-library.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
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
#!/bin/bash
set -e
if [ "$#" -eq 0 ]; then
echo "Usage:"
echo " $0 target [maketask]"
echo " target: osx ios iossimulator ioscatalyst androidarm androidarm64 androidx86_64"
echo "To control iOS, macOS builds set environment variables:"
echo " minimum deployment target"
echo " - MACOSX_DEPLOYMENT_TARGET=11.0"
echo " - IPHONEOS_DEPLOYMENT_TARGET=13.0"
echo " archs to build on macOS/iOS"
echo " - ARCHS=\"arm64 x86_64\" (macOS)"
echo " - ARCHS=\"arm64\" (iOS)"
echo " - ARCHS=\"arm64 x86_64\" (iPhoneSimulator)"
exit
fi
case "$@" in
*android*)
case "$@" in
*x86_64*)
TARGET=androidx86_64
ARCH="x86_64"
;;
*arm64*)
TARGET=androidarm64
ARCH="arm64-v8a"
;;
*)
TARGET=androidarm
ARCH="armeabi-v7a"
;;
esac
: ${ANDROID_NDK_HOME:=$(ls -d /Volumes/android-ndk-r*/AndroidNDK*.app/Contents/NDK)}
TARGET_PATH=/Library/libdigidocpp.${TARGET}
CMAKEARGS="
-DCMAKE_FIND_ROOT_PATH=${TARGET_PATH};/usr/local;/opt/homebrew \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=28 \
-DANDROID_ABI=${ARCH} \
-DBoost_INCLUDE_DIR=NOTFOUND \
-DDOXYGEN_EXECUTABLE=NOTFOUND \
-DBUILD_TOOLS=NO \
-DBUILD_SHARED_LIBS=NO"
;;
*ios*)
case "$@" in
*simulator*)
echo "Building for iOS Simulator"
TARGET=iphonesimulator
SYSROOT=iphonesimulator
: ${ARCHS:="arm64 x86_64"}
;;
*catalyst*)
echo "Building for iOS macOS Catalyst"
TARGET=iphonecatalyst
SYSROOT=macosx
export CFLAGS="-target x86_64-apple-ios-macabi"
export CXXFLAGS="-target x86_64-apple-ios-macabi"
: ${ARCHS:="arm64 x86_64"}
;;
*)
echo "Building for iOS"
TARGET=iphoneos
SYSROOT=iphoneos
: ${ARCHS:="arm64"}
;;
esac
TARGET_PATH=/Library/libdigidocpp.${TARGET}
: ${IPHONEOS_DEPLOYMENT_TARGET:="13.0"}
export IPHONEOS_DEPLOYMENT_TARGET
CMAKEARGS="
-DCMAKE_OSX_SYSROOT=${SYSROOT} \
-DFRAMEWORK=off \
-DSWIG_EXECUTABLE=NOTFOUND \
-DBoost_INCLUDE_DIR=NOTFOUND \
-DDOXYGEN_EXECUTABLE=NOTFOUND \
-DBUILD_TOOLS=NO \
-DBUILD_SHARED_LIBS=NO"
;;
*)
echo "Building for macOS"
TARGET=macOS
TARGET_PATH=/Library/libdigidocpp
: ${ARCHS:="arm64 x86_64"}
: ${MACOSX_DEPLOYMENT_TARGET:="11.0"}
export MACOSX_DEPLOYMENT_TARGET
esac
cmake --fresh -B ${TARGET} -S . \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=${TARGET_PATH} \
-DCMAKE_OSX_ARCHITECTURES="${ARCHS// /;}" \
-DOPENSSL_ROOT_DIR=${TARGET_PATH} \
-DXercesC_ROOT=${TARGET_PATH} \
${CMAKEARGS}
cmake --build ${TARGET}
while test $# -gt 0; do
case "$1" in
android*|*ios*|*mac*|*osx*) ;;
install*) sudo cmake --build ${TARGET} --target $1 ;;
*) cmake --build ${TARGET} --target $1 ;;
esac
shift
done