Enabled Arduino verification build.
[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         fi
21
22         # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
23         # it requires gcc-4.9, currently only android-ndk-r10(for linux)
24         # and windows android-ndk-r10(64bit target version) support these features.
25         if [ "$BUILD_FOR_ANDROID" = "true" ]
26                 then
27                 echo "*********** Build Boost for android ***********"
28                 pushd extlibs
29                 .//buildDependencies.sh
30                 popd
31
32                 echo "*********** Build for android x86 *************"
33                 scons TARGET_OS=android TARGET_ARCH=x86 ANDROID_NDK=$1 RELEASE=$3
34
35                 echo "*********** Build for android armeabi *************"
36                 scons TARGET_OS=android TARGET_ARCH=armeabi ANDROID_NDK=$1 RELEASE=$3
37
38                 echo "*********** Build for android armeabi-v7a *************"
39                 scons TARGET_OS=android TARGET_ARCH=armeabi-v7a ANDROID_NDK=$1 RELEASE=$3
40
41                 echo "*********** Build for android armeabi-v7a-hard *************"
42                 scons TARGET_OS=android TARGET_ARCH=armeabi-v7a-hard ANDROID_NDK=$1 RELEASE=$3
43         fi
44
45         echo "*********** Build for arduino avr *************"
46         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=ETHERNET NET=Ethernet RELEASE=$3
47         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=WIFI NET=Wifi RELEASE=$3
48
49         echo "*********** Build for arduino arm *************"
50         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=ETHERNET NET=Ethernet RELEASE=$3
51         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=WIFI NET=Wifi RELEASE=$3
52
53         if [ $(uname -s) = "Darwin" ]
54         then
55                 echo "*********** Build for OSX *************"
56                 scons TARGET_OS=darwin SYS_VERSION=10.9 RELEASE=$3
57
58                 echo "*********** Build for IOS i386 *************"
59                 scons TARGET_OS=ios TARGET_ARCH=i386 SYS_VERSION=7.0 RELEASE=$3
60
61                 echo "*********** Build for IOS x86_64 *************"
62                 scons TARGET_OS=ios TARGET_ARCH=x86_64 SYS_VERSION=7.0 RELEASE=$3
63
64                 echo "*********** Build for IOS armv7 *************"
65                 scons TARGET_OS=ios TARGET_ARCH=armv7 SYS_VERSION=7.0 RELEASE=$3
66
67                 echo "*********** Build for IOS armv7s *************"
68                 scons TARGET_OS=ios TARGET_ARCH=armv7s SYS_VERSION=7.0 RELEASE=$3
69
70                 echo "*********** Build for IOS arm64 *************"
71                 scons TARGET_OS=ios TARGET_ARCH=arm64 SYS_VERSION=7.0 RELEASE=$3
72         fi
73 }
74
75 function  help()
76 {
77         echo "Usage:"
78         echo "  build:"
79         echo "     `basename $0` <path-to-android-ndk>"
80         echo "  clean:"
81         echo "     `basename $0` -c"
82 }
83
84 if [ $# -eq 1 ]
85 then
86         if [ $1 = '-c' ]
87         then
88                 clean
89                 exit 0
90         else
91                 help
92                 exit -1
93         fi
94 elif [ $# -ne 2 ]
95 then
96         help
97         exit -1
98 fi
99
100 # Suppress "Reading ..." message and enable parallel build
101 export SCONSFLAGS="-Q -j 4"
102 build $1 $2 true
103 build $1 $2 false
104 scons resource RELEASE=false -c
105 scons resource LOGGING=false RELEASE=false
106 scons resource TEST=1 RELEASE=false
107 echo "===================== done ====================="
108