connectivity: fix warning about missing method declarations
[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 build_all()
8 {
9         if [ $(uname -s) = "Linux" ]
10         then
11                 build_linux_unsecured $1 $2
12                 build_linux_secured $1 $2
13                 build_linux_unsecured_with_ra $1 $2
14                 build_linux_secured_with_ra $1 $2
15                 build_linux_unsecured_with_rm $1 $2
16                 build_linux_unsecured_with_rd $1 $2
17                 build_linux_secured_with_rd $1 $2
18         fi
19
20         build_android $1 $2
21
22         build_arduino $1 $2
23
24         build_tizen $1 $2
25
26         if [ $(uname -s) = "Darwin" ]
27         then
28                 build_darwin $1 $2
29         fi
30 }
31
32 function build_linux()
33 {
34         build_linux_unsecured $1 $2
35
36         build_linux_secured $1 $2
37 }
38
39 function build_linux_unsecured()
40 {
41         echo "*********** Build for linux ************"
42         scons RELEASE=$1 $2
43 }
44
45 function build_linux_unsecured_with_rm()
46 {
47         echo "*********** Build for linux with RoutingManager************"
48         scons ROUTING=GW RELEASE=$1 $2
49 }
50
51 function build_linux_secured()
52 {
53         echo "*********** Build for linux with Security *************"
54         scons RELEASE=$1 SECURED=1 $2
55 }
56
57 function build_linux_unsecured_with_ra()
58 {
59
60         echo "*********** Build for linux With Remote Access *************"
61         scons RELEASE=$1 WITH_RA=1 WITH_RA_IBB=1 $2
62 }
63
64 function build_linux_secured_with_ra()
65 {
66         echo "*********** Build for linux With Remote Access & Security ************"
67         scons RELEASE=$1 WITH_RA=1 WITH_RA_IBB=1 SECURED=1 $2
68 }
69
70 function build_linux_unsecured_with_rd()
71 {
72         echo "*********** Build for linux With Resource Directory *************"
73         scons RELEASE=$1 WITH_RD=1 $2
74 }
75
76 function build_linux_secured_with_rd()
77 {
78         echo "*********** Build for linux With Resource Directory & Security ************"
79         scons RELEASE=$1 WITH_RD=1 SECURED=1 $2
80 }
81
82 function build_android()
83 {
84         # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
85         # it requires gcc-4.9, currently only android-ndk-r10(for linux)
86         # and windows android-ndk-r10(64bit target version) support these features.
87
88         build_android_x86 $1 $2
89         build_android_x86_with_rm $1 $2
90         build_android_armeabi $1 $2
91         build_android_armeabi_with_rm $1 $2
92 }
93
94 function build_android_x86()
95 {
96         echo "*********** Build for android x86 *************"
97         scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=IP $2
98         scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=BT $2
99         scons TARGET_OS=android TARGET_ARCH=x86 RELEASE=$1 TARGET_TRANSPORT=BLE $2
100 }
101
102 function build_android_x86_with_rm()
103 {
104         echo "*********** Build for android x86 with Routing Manager *************"
105         scons TARGET_OS=android TARGET_ARCH=x86 ROUTING=GW RELEASE=$1 TARGET_TRANSPORT=IP $2
106         scons TARGET_OS=android TARGET_ARCH=x86 ROUTING=GW RELEASE=$1 TARGET_TRANSPORT=BT $2
107         scons TARGET_OS=android TARGET_ARCH=x86 ROUTING=GW RELEASE=$1 TARGET_TRANSPORT=BLE $2
108 }
109
110 function build_android_armeabi()
111 {
112         echo "*********** Build for android armeabi *************"
113         scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=IP $2
114         scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=BT $2
115         scons TARGET_OS=android TARGET_ARCH=armeabi RELEASE=$1 TARGET_TRANSPORT=BLE $2
116 }
117
118 function build_android_armeabi_with_rm()
119 {
120         echo "*********** Build for android armeabi with Routing Manager*************"
121         scons TARGET_OS=android TARGET_ARCH=armeabi ROUTING=GW RELEASE=$1 TARGET_TRANSPORT=IP $2
122         scons TARGET_OS=android TARGET_ARCH=armeabi ROUTING=GW RELEASE=$1 TARGET_TRANSPORT=BT $2
123         scons TARGET_OS=android TARGET_ARCH=armeabi ROUTING=GW RELEASE=$1 TARGET_TRANSPORT=BLE $2
124 }
125
126 function build_arduino()
127 {
128         echo "*********** Build for arduino avr *************"
129         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$1 $2
130         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$1 $2
131         scons resource TARGET_OS=arduino UPLOAD=false BOARD=mega TARGET_ARCH=avr TARGET_TRANSPORT=BLE SHIELD=RBL_NRF8001 RELEASE=$1 $2
132
133         echo "*********** Build for arduino arm *************"
134         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=ETH RELEASE=$1 $2
135         scons resource TARGET_OS=arduino UPLOAD=false BOARD=arduino_due_x TARGET_ARCH=arm TARGET_TRANSPORT=IP SHIELD=WIFI RELEASE=$1 $2
136         # BLE support for the Arduino Due is currently unavailable.
137 }
138
139 function build_tizen()
140 {
141         echo "*********** Build for Tizen *************"
142         ./gbsbuild.sh
143
144         echo "*********** Build for Tizen CA lib and sample *************"
145         scons -f resource/csdk/connectivity/build/tizen/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP LOGGING=true RELEASE=$1 $2
146
147         echo "*********** Build for Tizen CA lib and sample with Security *************"
148         scons -f resource/csdk/connectivity/build/tizen/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP LOGGING=true SECURED=1 RELEASE=$1 $2
149
150         echo "*********** Build for Tizen octbstack lib and sample *************"
151         scons -f resource/csdk/stack/samples/tizen/build/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP LOGGING=true RELEASE=$1 $2
152
153         echo "*********** Build for Tizen octbstack lib and sample with Security*************"
154         scons -f resource/csdk/stack/samples/tizen/build/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP LOGGING=true SECURED=1 RELEASE=$1 $2
155
156         echo "*********** Build for Tizen octbstack lib and sample with Routing Manager*************"
157         scons -f resource/csdk/stack/samples/tizen/build/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP LOGGING=true ROUTING=GW RELEASE=$1 $2
158 }
159
160 function build_darwin() # Mac OSx and iOS
161 {
162         echo "*********** Build for OSX *************"
163         scons TARGET_OS=darwin SYS_VERSION=10.9 RELEASE=$1 $2
164
165         echo "*********** Build for IOS i386 *************"
166         scons TARGET_OS=ios TARGET_ARCH=i386 SYS_VERSION=7.0 RELEASE=$1 $2
167
168         echo "*********** Build for IOS x86_64 *************"
169         scons TARGET_OS=ios TARGET_ARCH=x86_64 SYS_VERSION=7.0 RELEASE=$1 $2
170
171         echo "*********** Build for IOS armv7 *************"
172         scons TARGET_OS=ios TARGET_ARCH=armv7 SYS_VERSION=7.0 RELEASE=$1 $2
173
174         echo "*********** Build for IOS armv7s *************"
175         scons TARGET_OS=ios TARGET_ARCH=armv7s SYS_VERSION=7.0 RELEASE=$1 $2
176
177         echo "*********** Build for IOS arm64 *************"
178         scons TARGET_OS=ios TARGET_ARCH=arm64 SYS_VERSION=7.0 RELEASE=$1 $2
179 }
180
181 function unit_tests()
182 {
183         echo "*********** Unit test Start *************"
184         scons resource RELEASE=false -c
185         scons resource LOGGING=false RELEASE=false
186         scons resource TEST=1 RELEASE=false
187         echo "*********** Unit test Stop *************"
188 }
189
190 function  help()
191 {
192         echo "Usage:"
193         echo "  build:"
194         echo "     `basename $0` <target_build>"
195         echo "      Allowed values for <target_build>: all, linux_unsecured, linux_secured, linux_unsecured_with_ra, linux_secured_with_ra, linux_unsecured_with_rd, linux_secured_with_rd, android, arduino, tizen, darwin"
196         echo "      Note: \"linux\" will build \"linux_unsecured\", \"linux_secured\", \"linux_unsecured_with_ra\", \"linux_secured_with_ra\", \"linux_secured_with_rd\" & \"linux_unsecured_with_rd\"."
197         echo "      Any selection will build both debug and release versions of all available targets in the scope you've"
198         echo "      selected. To choose any specific command, please use the SCons commandline directly. Please refer"
199         echo "      to [IOTIVITY_REPO]/Readme.scons.txt."
200         echo "  clean:"
201         echo "     `basename $0` -c"
202 }
203
204 # Suppress "Reading ..." message and enable parallel build
205 export SCONSFLAGS="-Q -j 4"
206
207 if [ $# -eq 1 ]
208 then
209         if [ $1 = '-c' ]
210         then
211                 build_all true $1
212                 build_all false $1
213                 exit 0
214         elif [ $1 = 'all' ]
215         then
216                 build_all true
217                 build_all false
218                 unit_tests
219         elif [ $1 = 'linux' ]
220         then
221                 build_linux true
222                 build_linux false
223         elif [ $1 = 'linux_unsecured' ]
224         then
225                 build_linux_unsecured true
226                 build_linux_unsecured false
227                 build_linux_unsecured_with_rm true
228                 build_linux_unsecured_with_rm false
229         elif [ $1 = 'linux_secured' ]
230         then
231                 build_linux_secured true
232                 build_linux_secured false
233         elif [ $1 = 'linux_unsecured_with_ra' ]
234         then
235                 build_linux_unsecured_with_ra true
236                 build_linux_unsecured_with_ra false
237         elif [ $1 = 'linux_secured_with_ra' ]
238         then
239                 build_linux_secured_with_ra true
240                 build_linux_secured_with_ra false
241         elif [ $1 = 'linux_unsecured_with_rd' ]
242         then
243                 build_linux_unsecured_with_rd true
244                 build_linux_unsecured_with_rd false
245         elif [ $1 = 'linux_secured_with_rd' ]
246         then
247                 build_linux_secured_with_rd true
248                 build_linux_secured_with_rd false
249         elif [ $1 = 'android' ]
250         then
251                 build_android true
252                 build_android false
253         elif [ $1 = 'android_x86' ]
254         then
255         build_android_x86 true
256         build_android_x86 false
257                 build_android_x86_with_rm true
258                 build_android_x86_with_rm false
259         elif [ $1 = 'android_armeabi' ]
260         then
261         build_android_armeabi true
262         build_android_armeabi false
263                 build_android_armeabi_with_rm true
264                 build_android_armeabi_with_rm false
265         elif [ $1 = 'arduino' ]
266         then
267                 build_arduino true
268                 build_arduino false
269         elif [ $1 = 'tizen' ]
270         then
271                 build_tizen true
272                 build_tizen false
273         elif [ $1 = 'darwin' ]
274         then
275                 build_darwin true
276                 build_darwin false
277         elif [ $1 = 'unit_tests' ]
278         then
279                 unit_tests
280         else
281                 help
282                 exit -1
283         fi
284 elif [ $# -eq 0 ]
285 then
286         build_all true
287         build_all false
288         unit_tests
289 else
290         help
291         exit -1
292 fi
293
294 echo "===================== done ====================="