-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·112 lines (100 loc) · 2.82 KB
/
build
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
#!/bin/bash
# Work in current directory
cd $(dirname "$0")
# Variables
WORKSPACE="$(pwd)/workspace"
SRC="$(pwd)/PDFWriter3_6"
OUT="$(pwd)/out"
LIBS=(PDFWriter FreeType LibJpeg LibTiff ZLib)
TARGETS=(i386 x86_64 arm64 armv7 armv7s)
# Ye olde functionz
function makeWorkspace {
rm -rf "$WORKSPACE"
mkdir "$WORKSPACE" &&
mkdir "$WORKSPACE/build" &&
cp -r "$SRC/." "$WORKSPACE/"
}
function makeOut {
rm -rf "$OUT" &&
mkdir "$OUT" &&
for LIB in "${LIBS[@]}"; do
mkdir "$OUT/$LIB"
for TARGET in "${TARGETS[@]}"; do
mkdir "$OUT/$LIB/$TARGET"
done
done
mkdir "$OUT/PDFWriter/include"
}
function harvestHeaders {
find "$WORKSPACE/PDFWriter" -name \*.h -exec cp {} "$OUT/PDFWriter/include" \;
}
function buildXCodeProj {
cd "$WORKSPACE/build" &&
cmake -GXcode ..
}
# $1 == sdk (iphoneos || iphonesimulator), $2 == ARCHS
function buildStaticLib {
PROJECT="$WORKSPACE/build/PDFHUMMUS.xcodeproj"
# https://stackoverflow.com/a/20516805
xcodebuild \
-project "$PROJECT" \
-configuration 'Release' \
-sdk "$1" \
clean build \
ONLY_ACTIVE_ARCH=NO \
ARCHS="$2" \
IPHONEOS_DEPLOYMENT_TARGET='9.3' \
TARGET_BUILD_DIR='./build-arm' \
BUILT_PRODUCTS_DIR='./build-arm'
}
function harvestStaticLib {
cd "$WORKSPACE/build-arm" &&
cp ./libPDFWriter.a "$OUT/PDFWriter/$1"
cp ./libFreeType.a "$OUT/FreeType/$1"
cp ./libLibJpeg.a "$OUT/LibJpeg/$1"
cp ./libLibTiff.a "$OUT/LibTiff/$1"
cp ./libZlib.a "$OUT/ZLib/$1"
}
function buildAndHarvestStaticLibs {
makeWorkspace &&
buildXCodeProj
for TARGET in "${TARGETS[@]}"; do
SDK="iphoneos"
if [[ "$TARGET" == i386 || "$TARGET" == x86_64 ]]; then
SDK="iphonesimulator"
fi
buildStaticLib "$SDK" "$TARGET" &&
harvestStaticLib "$TARGET"
done
}
function buildUniversalLib {
cd "$OUT" &&
for LIB in "${LIBS[@]}"; do
rm -rf "./$LIB/universal" &&
mkdir "./$LIB/universal" &&
if [[ "$LIB" == ZLib ]]; then
# Have to make the second "L" lowercase...
lipo -create \
"./$LIB/arm64/libZlib.a" \
"./$LIB/armv7/libZlib.a" \
"./$LIB/armv7s/libZlib.a" \
"./$LIB/i386/libZlib.a" \
"./$LIB/x86_64/libZlib.a" \
-output "./$LIB/universal/libZlib.a"
else
lipo -create \
"./$LIB/arm64/lib$LIB.a" \
"./$LIB/armv7/lib$LIB.a" \
"./$LIB/armv7s/lib$LIB.a" \
"./$LIB/i386/lib$LIB.a" \
"./$LIB/x86_64/lib$LIB.a" \
-output "./$LIB/universal/lib$LIB.a"
fi
done
}
# Executable section
makeOut &&
buildAndHarvestStaticLibs &&
buildUniversalLib &&
harvestHeaders
# makeWorkspace && buildXCodeProj && buildStaticLib && harvestStaticLib arm64