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