This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
build_framework.sh
executable file
·99 lines (75 loc) · 3.43 KB
/
build_framework.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
#!/usr/bin/env bash
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function build_static_framework() {
cp -r "Release-iphoneos/cronet/Static/Cronet.framework" Cronet.framework
cp "Release-iphoneos/cronet/Cronet.framework/Info.plist" Cronet.framework
cp -r "Release-iphoneos/cronet/Cronet.framework/Modules" Cronet.framework
lipo -create -output Cronet.framework/Cronet Release-iphoneos/cronet/Static/Cronet.framework/Cronet Release-iphonesimulator/cronet/Static/Cronet.framework/Cronet
rm -f "$__dir/Cronet-Static.framework.tar.bz2" || true
tar cjf Cronet-Static.framework.tar.bz2 Cronet.framework
mv Cronet-Static.framework.tar.bz2 "$__dir"
rm -rf Cronet.framework
}
function build_dynamic_framework() {
cp -r "Release-iphoneos/cronet/Cronet.framework" Cronet.framework
lipo -create -output Cronet.framework/Cronet Release-iphoneos/cronet/Cronet.framework/Cronet Release-iphonesimulator/cronet/Cronet.framework/Cronet
rm -rf "$__dir/Frameworks/Cronet.framework" || true
cp -r Cronet.framework "$__dir/Frameworks"
rm -f "$__dir/Cronet-Dynamic.framework.tar.bz2" || true
tar cjf Cronet-Dynamic.framework.tar.bz2 Cronet.framework
mv Cronet-Dynamic.framework.tar.bz2 "$__dir"
rm -rf Cronet.framework
}
function build_dsym() {
cp "Release-iphoneos/cronet/Cronet.dSYM.tar.bz2" .
tar xf Cronet.dSYM.tar.bz2
mv Cronet.dSYM Cronet-iphoneos.dSYM
cp "Release-iphonesimulator/cronet/Cronet.dSYM.tar.bz2" .
tar xf Cronet.dSYM.tar.bz2
mv Cronet.dSYM Cronet-iphonesimulator.dSYM
cp -r Cronet-iphoneos.dSYM Cronet.framework.dSYM
lipo -create -output Cronet.framework.dSYM/Contents/Resources/DWARF/Cronet Cronet-iphoneos.dSYM/Contents/Resources/DWARF/Cronet Cronet-iphonesimulator.dSYM/Contents/Resources/DWARF/Cronet
rm -f "$__dir/Cronet.framework.dSYM.tar.bz2" || true
tar cjf Cronet.framework.dSYM.tar.bz2 Cronet.framework.dSYM
cp Cronet.framework.dSYM.tar.bz2 "$__dir"
}
function build_framework() {
local CRONET_VERSION=$1
if [ -z "$CRONET_VERSION" ]; then
echo "Empty framework version. Check passed in argument"
return 1
fi
if ! gsutil -q stat "gs://chromium-cronet/ios/${CRONET_VERSION}/Release-iphoneos/VERSION" ; then
echo "Invalid framework version $CRONET_VERSION. Build Release-iphoneos build does not exist on gs://chromium-cronet"
return 2
fi
if ! gsutil -q stat "gs://chromium-cronet/ios/${CRONET_VERSION}/Release-iphonesimulator/VERSION" ; then
echo "Invalid framework version $CRONET_VERSION. Release-iphonesimulator build does not exist on gs://chromium-cronet"
return 3
fi
local OLD_PWD=$PWD
rm -rf "$__dir/tmp" || true
mkdir -p "$__dir/tmp"
cd "$__dir/tmp"
gsutil -q -m cp -r "gs://chromium-cronet/ios/${CRONET_VERSION}/Release-*" .
build_static_framework
build_dynamic_framework
build_dsym
cd "$OLD_PWD"
}
if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
export -f build_framework
else
# Exit on error. Append "|| true" if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
set -o pipefail
# Turn on traces, useful while debugging but commented out by default
# set -o xtrace
build_framework "${@}"
exit $?
fi