Updated build Server script to include building Iotivity in secure mode
[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         if [ "$BUILD_FOR_ANDROID" = "true" ]
29                 then
30                 echo "*********** Build Boost for android ***********"
31                 pushd extlibs
32                 .//buildDependencies.sh
33                 popd
34
35                 echo "*********** Build for android x86 *************"
36                 scons TARGET_OS=android TARGET_ARCH=x86 ANDROID_NDK=$1 RELEASE=$3
37
38                 echo "*********** Build for android armeabi *************"
39                 scons TARGET_OS=android TARGET_ARCH=armeabi ANDROID_NDK=$1 RELEASE=$3
40
41                 echo "*********** Build for android armeabi-v7a *************"
42                 scons TARGET_OS=android TARGET_ARCH=armeabi-v7a ANDROID_NDK=$1 RELEASE=$3
43
44                 echo "*********** Build for android armeabi-v7a-hard *************"
45                 scons TARGET_OS=android TARGET_ARCH=armeabi-v7a-hard ANDROID_NDK=$1 RELEASE=$3
46         fi
47
48         echo "*********** Build for arduino avr *************"
49         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=ETHERNET NET=Ethernet RELEASE=$3
50         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=WIFI NET=Wifi RELEASE=$3
51
52         echo "*********** Build for arduino arm *************"
53         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=ETHERNET NET=Ethernet RELEASE=$3
54         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=WIFI NET=Wifi RELEASE=$3
55
56         if [ $(uname -s) = "Darwin" ]
57         then
58                 echo "*********** Build for OSX *************"
59                 scons TARGET_OS=darwin SYS_VERSION=10.9 RELEASE=$3
60
61                 echo "*********** Build for IOS i386 *************"
62                 scons TARGET_OS=ios TARGET_ARCH=i386 SYS_VERSION=7.0 RELEASE=$3
63
64                 echo "*********** Build for IOS x86_64 *************"
65                 scons TARGET_OS=ios TARGET_ARCH=x86_64 SYS_VERSION=7.0 RELEASE=$3
66
67                 echo "*********** Build for IOS armv7 *************"
68                 scons TARGET_OS=ios TARGET_ARCH=armv7 SYS_VERSION=7.0 RELEASE=$3
69
70                 echo "*********** Build for IOS armv7s *************"
71                 scons TARGET_OS=ios TARGET_ARCH=armv7s SYS_VERSION=7.0 RELEASE=$3
72
73                 echo "*********** Build for IOS arm64 *************"
74                 scons TARGET_OS=ios TARGET_ARCH=arm64 SYS_VERSION=7.0 RELEASE=$3
75         fi
76 }
77
78 function  help()
79 {
80         echo "Usage:"
81         echo "  build:"
82         echo "     `basename $0` <path-to-android-ndk>"
83         echo "  clean:"
84         echo "     `basename $0` -c"
85 }
86
87 if [ $# -eq 1 ]
88 then
89         if [ $1 = '-c' ]
90         then
91                 clean
92                 exit 0
93         else
94                 help
95                 exit -1
96         fi
97 elif [ $# -ne 2 ]
98 then
99         help
100         exit -1
101 fi
102
103 # Suppress "Reading ..." message and enable parallel build
104 export SCONSFLAGS="-Q -j 4"
105 build $1 $2 true
106 build $1 $2 false
107 scons resource RELEASE=false -c
108 scons resource LOGGING=false RELEASE=false
109 scons resource TEST=1 RELEASE=false
110 echo "===================== done ====================="
111