Android Base API merge to master
[platform/upstream/iotivity.git] / auto_build.sh
1 #! /bin/bash
2
3 # Ideally we will capture the exit code of each step and try them all before failing
4 # the build script.  For now, use set -e and fail the build at first failure.
5 set -e
6
7 function clean()
8 {
9         echo "*********** Clean build *************"
10         scons -c
11         rm -rf out
12 }
13
14 function build()
15 {
16         if [ $(uname -s) = "Linux" ]
17         then
18                 echo "*********** Build for linux *************"
19                 scons RELEASE=$3
20
21                 echo "*********** Build for linux with Security*************"
22                 scons RELEASE=$3 SECURED=1
23         fi
24
25         # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
26         # it requires gcc-4.9, currently only android-ndk-r10(for linux)
27         # and windows android-ndk-r10(64bit target version) support these features.
28         echo "*********** Build Boost for android ***********"
29         # disable parallel build for android as gradle depends on scons to finish first
30         export SCONSFLAGS="-Q"
31
32         echo "*********** Build for android x86 *************"
33         scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$3 TARGET_TRANSPORT=IP
34
35         echo "*********** Build for android armeabi *************"
36         scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$3 TARGET_TRANSPORT=IP
37
38         # enable parallel build
39         export SCONSFLAGS="-Q -j 4"
40
41         echo "*********** Build for arduino avr *************"
42         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$3
43         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$3
44
45         echo "*********** Build for arduino arm *************"
46         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$3
47         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$3
48
49
50         if [ $(uname -s) = "Darwin" ]
51         then
52                 echo "*********** Build for OSX *************"
53                 scons TARGET_OS=darwin SYS_VERSION=10.9 RELEASE=$3
54
55                 echo "*********** Build for IOS i386 *************"
56                 scons TARGET_OS=ios TARGET_ARCH=i386 SYS_VERSION=7.0 RELEASE=$3
57
58                 echo "*********** Build for IOS x86_64 *************"
59                 scons TARGET_OS=ios TARGET_ARCH=x86_64 SYS_VERSION=7.0 RELEASE=$3
60
61                 echo "*********** Build for IOS armv7 *************"
62                 scons TARGET_OS=ios TARGET_ARCH=armv7 SYS_VERSION=7.0 RELEASE=$3
63
64                 echo "*********** Build for IOS armv7s *************"
65                 scons TARGET_OS=ios TARGET_ARCH=armv7s SYS_VERSION=7.0 RELEASE=$3
66
67                 echo "*********** Build for IOS arm64 *************"
68                 scons TARGET_OS=ios TARGET_ARCH=arm64 SYS_VERSION=7.0 RELEASE=$3
69         fi
70 }
71
72 function  help()
73 {
74         echo "Usage:"
75         echo "  build:"
76         echo "     `basename $0` <path-to-android-ndk>"
77         echo "  clean:"
78         echo "     `basename $0` -c"
79 }
80
81 if [ $# -eq 1 ]
82 then
83         if [ $1 = '-c' ]
84         then
85                 clean
86                 exit 0
87         else
88                 help
89                 exit -1
90         fi
91 elif [ $# -ne 2 ]
92 then
93         help
94         exit -1
95 fi
96
97 # Suppress "Reading ..." message and enable parallel build
98 export SCONSFLAGS="-Q -j 4"
99 build $1 $2 true
100 build $1 $2 false
101 scons resource RELEASE=false -c
102 scons resource LOGGING=false RELEASE=false
103 scons resource TEST=1 RELEASE=false
104 echo "===================== done ====================="
105
106