-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_ios.sh
executable file
·72 lines (61 loc) · 1.74 KB
/
build_ios.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
#!/usr/bin/env bash
set -e
MODULE=demo
ROOT_PATH=$(pwd)
OUTPUT_PATH=$ROOT_PATH/output/ios/
if [ ! -d $OUTPUT_PATH ]; then mkdir -p $OUTPUT_PATH; fi
if [ ! -d $ROOT_PATH/openssl-ios/ ]; then
curl -O https://getseacatiostoracc.blob.core.windows.net/getseacatio/openssl/openssl-dev-1.0.2o-ios.tar.gz
tar xvf openssl-dev-1.0.2o-ios.tar.gz
mv openssl openssl-ios
fi
OPENSSL_PATH="$ROOT_PATH/openssl-ios"
OPENSSL_INCLUDE="$OPENSSL_PATH/include/"
OPENSSL_LIBS="$OPENSSL_PATH/lib/"
export GOARCH=amd64
case "$OSTYPE" in
solaris*) echo "SOLARIS" ;;
darwin*) export GOOS=darwin ;;
linux*) export GOOS=linux ;;
bsd*) echo "BSD" ;;
msys*) echo "WINDOWS" ;;
*) echo "unknown: $OSTYPE" ;;
esac
GOMOBILE=$ROOT_PATH/bin/gomobile
export GOPATH=$ROOT_PATH:$ROOT_PATH/app
PATH=$PATH:$ROOT_PATH/bin
MODULE_PATH=$ROOT_PATH/app/src/$MODULE
echo GOPATH: $GOPATH
echo MODULE_PATH: $MODULE_PATH
echo
cd $MODULE_PATH
# download and init gomobile if doesn't exists
GOMOBILE=$ROOT_PATH/bin/gomobile
if [ ! -e $GOMOBILE ]; then
go get golang.org/x/mobile/cmd/gomobile
$GOMOBILE init
fi
# download packages, but don't to build them
go get -t -d -v ./
gogetRetVal=$?
if [ $gogetRetVal -ne 0 ]; then
cd $ROOT_PATH
exit $gogetRetVal
fi
echo
cd $OUTPUT_PATH
export CGO_ENABLED=1
export GOGCCFLAGS="-I$OPENSSL_INCLUDE"
export CGO_CFLAGS="-I$OPENSSL_INCLUDE"
export CGO_CPPFLAGS="-I$OPENSSL_INCLUDE"
export CGO_CXXFLAGS="-I$OPENSSL_INCLUDE"
export CGO_FFLAGS=""
export CGO_LDFLAGS="-g -O2 -L$OPENSSL_LIBS -lssl -lcrypto"
# $GOMOBILE build -target=ios -ldflags="-L$OPENSSL_LIBS -lssl -lcrypto" -x $MODULE
$GOMOBILE build -target=ios -x $MODULE
goRetVal=$?
if [ $goRetVal -ne 0 ]; then
cd $ROOT_PATH
exit $goRetVal
fi
cd $ROOT_PATH