Rebase remote-access over 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         scons -f resource/csdk/connectivity/build/tizen/SConscript TARGET_OS=tizen -c
12         rm -rf out
13 }
14
15 function build()
16 {
17         if [ $(uname -s) = "Linux" ]
18         then
19                 echo "*********** Build for linux ************"
20                 scons RELEASE=$3
21
22                 echo "*********** Build for linux with Security *************"
23                 scons RELEASE=$3 SECURED=1
24
25                 echo "*********** Build for linux With Remote Access *************"
26                 scons RELEASE=$3 WITH_RA=1
27
28                 echo "*********** Build for linux With Remote Access & Security ************"
29                 scons RELEASE=$3 WITH_RA=1 SECURED=1
30         fi
31
32         # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
33         # it requires gcc-4.9, currently only android-ndk-r10(for linux)
34         # and windows android-ndk-r10(64bit target version) support these features.
35         echo "*********** Build Boost for android ***********"
36         # disable parallel build for android as gradle depends on scons to finish first
37         export SCONSFLAGS="-Q"
38
39         echo "*********** Build for android x86 *************"
40         scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$3 TARGET_TRANSPORT=IP
41
42         echo "*********** Build for android armeabi *************"
43         scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$3 TARGET_TRANSPORT=IP
44
45         # enable parallel build
46         export SCONSFLAGS="-Q -j 4"
47
48         echo "*********** Build for arduino avr *************"
49         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$3
50         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=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=IP SHIELD=ETH RELEASE=$3
54         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$3
55
56         echo "*********** Build for Tizen CA lib and sample *************"
57     #scons -f resource/csdk/connectivity/build/tizen/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP LOGGING=true RELEASE=$3
58
59         echo "*********** Build for Tizen CA lib and sample with Security *************"
60     #scons -f resource/csdk/connectivity/build/tizen/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP LOGGING=true SECURED=1 RELEASE=$3
61
62         if [ $(uname -s) = "Darwin" ]
63         then
64                 echo "*********** Build for OSX *************"
65                 scons TARGET_OS=darwin SYS_VERSION=10.9 RELEASE=$3
66
67                 echo "*********** Build for IOS i386 *************"
68                 scons TARGET_OS=ios TARGET_ARCH=i386 SYS_VERSION=7.0 RELEASE=$3
69
70                 echo "*********** Build for IOS x86_64 *************"
71                 scons TARGET_OS=ios TARGET_ARCH=x86_64 SYS_VERSION=7.0 RELEASE=$3
72
73                 echo "*********** Build for IOS armv7 *************"
74                 scons TARGET_OS=ios TARGET_ARCH=armv7 SYS_VERSION=7.0 RELEASE=$3
75
76                 echo "*********** Build for IOS armv7s *************"
77                 scons TARGET_OS=ios TARGET_ARCH=armv7s SYS_VERSION=7.0 RELEASE=$3
78
79                 echo "*********** Build for IOS arm64 *************"
80                 scons TARGET_OS=ios TARGET_ARCH=arm64 SYS_VERSION=7.0 RELEASE=$3
81         fi
82 }
83
84 function  help()
85 {
86         echo "Usage:"
87         echo "  build:"
88         echo "     `basename $0` <path-to-android-ndk> <path-to-arduino-sdk>"
89         echo "  clean:"
90         echo "     `basename $0` -c"
91 }
92
93 if [ $# -eq 1 ]
94 then
95         if [ $1 = '-c' ]
96         then
97                 clean
98                 exit 0
99         else
100                 help
101                 exit -1
102         fi
103 elif [ $# -ne 2 ]
104 then
105         help
106         exit -1
107 fi
108
109 # Suppress "Reading ..." message and enable parallel build
110 export SCONSFLAGS="-Q -j 4"
111 build $1 $2 true
112 build $1 $2 false
113 scons resource RELEASE=false -c
114 scons resource LOGGING=false RELEASE=false
115 scons resource TEST=1 RELEASE=false
116 echo "===================== done ====================="
117
118