forked from jasonacox/Build-OpenSSL-cURL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage.sh
executable file
·119 lines (109 loc) · 3.67 KB
/
stage.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
116
#!/bin/bash
#
# Sync Builds to S3 for next stage
#
# Set AWS credentials in envrionment settings
#
# export AWS_ACCESS_KEY_ID=""
# export AWS_SECRET_ACCESS_KEY=""
# Formatting
default="\033[39m"
wihte="\033[97m"
green="\033[32m"
red="\033[91m"
yellow="\033[33m"
bold="\033[0m${green}\033[1m"
subbold="\033[0m${green}"
archbold="\033[0m${yellow}\033[1m"
normal="${white}\033[0m"
dim="\033[0m${white}\033[2m"
alert="\033[0m${red}\033[1m"
alertdim="\033[0m${red}\033[2m"
OPENSSL_PHASE="1"
EXAMPLE="example/iOS Test App"
usage ()
{
echo
echo -e "${bold}Usage:${normal}"
echo
echo -e " ${subbold}$0${normal} [-o ${dim}<openssl phase>${normal}] [-n] [-c] [-d] [-t] [-h]"
echo
echo " -o Upload openssl for phase (1 or 2)"
echo " -n Upload nghttp2"
echo " -c Upload libcurl"
echo " -d Download openssl and nghttp2"
echo " -u Upload everything"
echo " -t Download everything and build iOS Test App"
echo " -h show usage"
echo
trap - INT TERM EXIT
exit 127
}
engine=0
while getopts "o:ncduth\?" o; do
case "${o}" in
o)
# archive openssl binaries
tar -zcvf "openssl-$OPTARG.tgz" openssl/Mac openssl/Catalyst openssl/iOS* openssl/tvOS
aws s3 cp "openssl-$OPTARG.tgz" s3://jasonacox.com.travis-build-stage-storage/
aws s3 ls jasonacox.com.travis-build-stage-storage
;;
n)
# archive nghttp2 binaries
tar -zcvf "nghttp2.tgz" nghttp2/Catalyst nghttp2/iOS* nghttp2/tvOS nghttp2/lib
aws s3 cp "nghttp2.tgz" s3://jasonacox.com.travis-build-stage-storage/
aws s3 ls jasonacox.com.travis-build-stage-storage
;;
c)
# archive libcurl binaries
tar -zcvf "curl.tgz" curl/lib curl/include
aws s3 cp "curl.tgz" s3://jasonacox.com.travis-build-stage-storage/
aws s3 ls jasonacox.com.travis-build-stage-storage
;;
d)
# download openssl and nghttp2 binaries
aws s3 cp s3://jasonacox.com.travis-build-stage-storage/openssl-1.tgz .
aws s3 cp s3://jasonacox.com.travis-build-stage-storage/openssl-2.tgz .
aws s3 cp s3://jasonacox.com.travis-build-stage-storage/nghttp2.tgz .
tar -zxf openssl-1.tgz
tar -zxf openssl-2.tgz
tar -zxf nghttp2.tgz
;;
u)
# upload libcurl
echo "Uploading libcurl libraries..."
tar -zcf "curl.tgz" curl/lib curl/include
aws s3 cp "curl.tgz" s3://jasonacox.com.travis-build-stage-storage/
aws s3 ls jasonacox.com.travis-build-stage-storage
;;
t)
# download and test binaries with a iOS Test App
echo "Fetching libcurl, openssl and nghttp2 libraries..."
aws s3 cp s3://jasonacox.com.travis-build-stage-storage/curl.tgz .
aws s3 cp s3://jasonacox.com.travis-build-stage-storage/openssl-1.tgz .
aws s3 cp s3://jasonacox.com.travis-build-stage-storage/openssl-2.tgz .
aws s3 cp s3://jasonacox.com.travis-build-stage-storage/nghttp2.tgz .
tar -zxf openssl-1.tgz
tar -zxf openssl-2.tgz
tar -zxf nghttp2.tgz
tar -zxf curl.tgz
echo "Fetching root certs..."
curl -s https://curl.haxx.se/ca/cacert.pem > "$EXAMPLE/cacert.pem"
echo "Copying libraries to Test App ..."
mkdir -p "$EXAMPLE/libs"
cp openssl/iOS-fat/lib/libcrypto.a "$EXAMPLE/libs/libcrypto.a"
cp openssl/iOS-fat/lib/libssl.a "$EXAMPLE/libs/libssl.a"
cp openssl/iOS-fat/include/openssl/* "$EXAMPLE/include/openssl/"
cp curl/include/curl/* "$EXAMPLE/include/curl/"
cp curl/lib/libcurl_iOS-fat.a "$EXAMPLE/libs/libcurl.a"
cp nghttp2/lib/libnghttp2_iOS-fat.a "$EXAMPLE/libs/libnghttp2.a"
echo "Building iOS Test App..."
xcodebuild clean -project "$EXAMPLE/iOS Test App.xcodeproj"
xcodebuild build -project "$EXAMPLE/iOS Test App.xcodeproj" -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))