forked from bblanchon/pdfium-binaries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
08-test.sh
executable file
·115 lines (105 loc) · 2.13 KB
/
08-test.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
109
110
111
112
113
114
115
#!/bin/bash -eux
OS=${PDFium_TARGET_OS:?}
CPU="${PDFium_TARGET_CPU:?}"
SOURCE_DIR="$PWD/example"
ANDROID_TOOLCHAIN="${PDFium_SOURCE_DIR:?}/third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/"
CMAKE_ARGS=()
export PDFium_DIR="$PWD/staging"
case "$OS" in
android)
case "$CPU" in
arm)
ARCH="armv7a-linux-androideabi16"
;;
arm64)
ARCH="aarch64-linux-android21"
;;
x64)
ARCH="x86_64-linux-android21"
;;
x86)
ARCH="i686-linux-android16"
;;
esac
export PATH="$ANDROID_TOOLCHAIN:$PATH"
CMAKE_ARGS+=(
-D CMAKE_C_COMPILER="$ARCH-clang"
-D CMAKE_CXX_COMPILER="$ARCH-clang++"
)
;;
ios)
case "$CPU" in
arm64)
ARCH="arm64"
SDK="iphoneos"
;;
x64)
ARCH="x86_64"
SDK="iphonesimulator"
;;
esac
CMAKE_ARGS+=(
-D CMAKE_SYSTEM_NAME="iOS"
-D CMAKE_OSX_SYSROOT="$SDK"
-D CMAKE_OSX_ARCHITECTURES="$ARCH"
# https://discourse.cmake.org/t/find-package-stops-working-when-cmake-system-name-ios/4609/7
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE="BOTH"
-D CMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH"
-D CMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH"
)
;;
linux)
case "$CPU" in
arm)
ARCH="arm-linux-gnueabihf"
;;
arm64)
ARCH="aarch64-linux-gnu"
;;
esac
[ -n "${ARCH:-}" ] && CMAKE_ARGS+=(
-D CMAKE_C_COMPILER="$ARCH-gcc"
-D CMAKE_CXX_COMPILER="$ARCH-g++"
)
;;
mac)
case "$CPU" in
arm64)
ARCH="arm64"
;;
x64)
ARCH="x86_64"
;;
esac
CMAKE_ARGS+=(
-D CMAKE_OSX_ARCHITECTURES="$ARCH"
)
;;
win)
case "$CPU" in
arm64)
ARCH="ARM64"
;;
x86)
ARCH="Win32"
;;
x64)
ARCH="x64"
;;
esac
CMAKE_ARGS+=(
-G "Visual Studio 16 2019"
-A "$ARCH"
)
;;
esac
CMAKE_ARGS+=("$SOURCE_DIR")
mkdir -p build
cd build
cmake "${CMAKE_ARGS[@]}"
cmake --build .
if [ "$OS" == "win" ]; then
file Debug/example.exe
else
file example
fi