build: Support scons install
[iotivity.git] / auto_build.py
1 #!/usr/bin/python
2
3 import os
4 import sys
5 import platform
6 import subprocess
7 import multiprocessing
8
9 # help message
10 def helpmsg(script):
11     helpstr = '''
12 Usage:
13     build:
14         python %s <targetbuild>
15         Allowed values for <target_build>: all, linux_unsecured, linux_secured, linux_full, linux_unsecured_with_rd, linux_secured_with_rd,
16         android, android_unsecured, android_secured, arduino, tizen, tizen_unsecured, tizen_secured, simulator, darwin, windows, msys
17         Note: \"linux\" will build \"linux_unsecured\", \"linux_secured\", \"linux_secured_with_rd\", \"linux_unsecured_with_mq\", \"linux_secured_with_tcp\" & \"linux_unsecured_with_tcp\" & \"linux_unsecured_with_rd\".
18         Any selection will build both debug and release versions of all available targets in the scope you've selected.
19         To choose any specific command, please use the SCons commandline directly. Please refer to [IOTIVITY_REPO]/Readme.scons.txt.
20     clean:
21         python %s -c
22     '''
23     print (helpstr % (script, script))
24     sys.exit(1)
25
26 def call_scons(build_options, extra_option_str):
27     """
28     This function formats and runs a scons command
29     Arguments:
30     build_options    -- {Dictionary} build flags (keys) associated with values;
31     extra_option_str -- {String} extra options to append to scons command
32     """
33     cmd_line = "scons VERBOSE=" + VERBOSE
34     for key in build_options:
35         cmd_line += " " + key + "=" + str(build_options[key])
36
37     cmd_line += " " + str(extra_option_str)
38
39     if not EXEC_MODE:
40         print ("Would run : " + cmd_line)
41     else:
42         print ("Running : " + cmd_line)
43         sys.stdout.flush()
44         exit_code = subprocess.Popen(cmd_line, shell=True).wait()
45         if exit_code != 0:
46             sys.exit(exit_code)
47
48 def build_all(flag, extra_option_str):
49     if platform.system() == "Linux":
50         build_linux_unsecured(flag, extra_option_str)
51         build_linux_secured(flag, extra_option_str)
52         build_linux_unsecured_with_rm(flag, extra_option_str)
53         build_linux_unsecured_with_rd(flag, extra_option_str)
54         build_linux_secured_with_rd(flag, extra_option_str)
55         build_linux_unsecured_with_mq(flag, extra_option_str)
56         build_linux_unsecured_with_tcp(flag, extra_option_str)
57         build_linux_secured_with_tcp(flag, extra_option_str)
58         build_linux_unsecured_with_java(flag, extra_option_str)
59         build_linux_secured_with_java(flag, extra_option_str)
60         build_simulator(flag, extra_option_str)
61
62         build_android_unsecured(flag, extra_option_str)
63         build_android_secured(flag, extra_option_str)
64         build_arduino(flag, extra_option_str)
65         build_tizen(flag, extra_option_str)
66
67     if platform.system() == "Windows":
68         build_windows(flag, extra_option_str)
69
70     if platform.system() == "Darwin":
71         build_darwin(flag, extra_option_str)
72
73 def build_linux(flag, extra_option_str):
74     build_linux_unsecured(flag, extra_option_str)
75     build_linux_secured(flag, extra_option_str)
76
77 def build_linux_unsecured(flag, extra_option_str):
78     print ("*********** Build for linux ************")
79     build_options = {
80                         'RELEASE':flag,
81                         'SECURED':0,
82                     }
83     call_scons(build_options, extra_option_str)
84
85 def build_linux_secured_with_tcp(flag, extra_option_str):
86     print ("*********** Build for linux with Secured TCP ************")
87     build_options = {
88                         'RELEASE':flag,
89                         'WITH_TCP': 1,
90                         'WITH_CLOUD':1,
91                     }
92     call_scons(build_options, extra_option_str)
93
94 def build_linux_unsecured_with_java(flag, extra_option_str):
95     print ("*********** Build for linux with Java support ************")
96     build_options = {
97                         'RELEASE':flag,
98                         'BUILD_JAVA': 1,
99                         'TARGET_TRANSPORT': 'IP',
100                     }
101     call_scons(build_options, extra_option_str)
102
103 def build_linux_secured_with_java(flag, extra_option_str):
104     print ("*********** Build for linux with Java support and secured ************")
105     build_options = {
106                         'RELEASE':flag,
107                         'BUILD_JAVA': 1,
108                         'TARGET_TRANSPORT': 'IP',
109                         'SECURED': 1,
110                     }
111     call_scons(build_options, extra_option_str)
112
113 def build_linux_unsecured_with_tcp(flag, extra_option_str):
114     print ("*********** Build for linux with TCP ************")
115     build_options = {
116                         'RELEASE':flag,
117                         'WITH_TCP': 1,
118                         'TARGET_TRANSPORT': 'IP',
119                         'SECURED':0,
120                     }
121     call_scons(build_options, extra_option_str)
122
123 def build_linux_unsecured_with_rm(flag, extra_option_str):
124     print ("*********** Build for linux with RoutingManager************")
125     build_options = {
126                         'ROUTING':'GW',
127                         'RELEASE':flag,
128                         'SECURED':0,
129                     }
130     call_scons(build_options, extra_option_str)
131
132 def build_linux_secured(flag, extra_option_str):
133     print ("*********** Build for linux with Security *************")
134     build_options = {
135                         'RELEASE':flag,
136                     }
137     call_scons(build_options, extra_option_str)
138
139 def build_linux_full(flag, extra_option_str):
140     print ("*********** Build for linux with full features *************")
141     build_options = {
142                         'MULTIPLE_OWNER':1,
143                         'RELEASE':flag,
144                         'SECURED':1,
145                         'WITH_CLOUD':1,
146                         'WITH_RA':1,
147                         'WITH_RA_IBB':1,
148                         'WITH_TCP':1,
149                     }
150     call_scons(build_options, extra_option_str)
151
152 def build_linux_unsecured_with_rd(flag, extra_option_str):
153     print ("*********** Build for linux With Resource Directory *************")
154     build_options = {
155                         'RELEASE':flag,
156                         'RD_MODE':'all',
157                         'SECURED':0,
158                     }
159     call_scons(build_options, extra_option_str)
160
161 def build_linux_secured_with_rd(flag, extra_option_str):
162     print ("*********** Build for linux With Resource Directory & Security ************")
163     build_options = {
164                         'RELEASE':flag,
165                         'RD_MODE':'all',
166                     }
167     call_scons(build_options, extra_option_str)
168
169 def build_linux_unsecured_with_mq(flag, extra_option_str):
170     print ("*********** Build for linux With Message Queue ************")
171     build_options = {
172                         'RELEASE':flag,
173                         'WITH_MQ':'PUB,SUB,BROKER',
174                         'SECURED':0,
175                     }
176     call_scons(build_options, extra_option_str)
177
178 def build_linux_unsecured_with_tcp(flag, extra_option_str):
179     print ("*********** Build for linux With tcp ************")
180     build_options = {
181                         'RELEASE':flag,
182                         'WITH_TCP':'1',
183                         'SECURED':0,
184                     }
185     call_scons(build_options, extra_option_str)
186
187 def build_android(flag, extra_option_str):
188     # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
189     # it requires gcc-4.9, currently only android-ndk-r10(for linux)
190     # and windows android-ndk-r10(64bit target version) support these features.
191     print ("*********** Build for android armeabi *************")
192     build_options = {
193                         'TARGET_OS':'android',
194                         'TARGET_ARCH':'armeabi',
195                         'RELEASE':flag,
196                     }
197     call_scons(build_options, extra_option_str)
198
199 def build_android_universal(flag, extra_option_str):
200     print('''
201 *******************************************************************************
202     Starting Android Universal build
203     This Will take a very long time to complete. It will build the android
204     build for the following architectures.
205        - armeabi
206        - armeabi-v7a
207        - arm64-v8a
208        - x86
209        - x86_64
210     If you do not need to build a universal APK or you can target a specific
211     architecture we recommend you build android for that specific target. 
212 *******************************************************************************
213 ''')
214     print ("*********** Build for android armeabi *************")
215     build_options = {
216                         'TARGET_OS':'android',
217                         'TARGET_ARCH':'armeabi',
218                         'RELEASE':flag,
219                     }
220     call_scons(build_options, extra_option_str)
221     print ("*********** Build for android x86 *************")
222     build_options = {
223                         'TARGET_OS':'android',
224                         'TARGET_ARCH':'x86',
225                         'RELEASE':flag,
226                     }
227     call_scons(build_options, extra_option_str)
228     print ("*********** Build for android armeabi-v7a *************")
229     build_options = {
230                         'TARGET_OS':'android',
231                         'TARGET_ARCH':'armeabi-v7a',
232                         'RELEASE':flag,
233                     }
234     call_scons(build_options, extra_option_str)
235     print ("*********** Build for android x86_64 *************")
236     build_options = {
237                         'TARGET_OS':'android',
238                         'TARGET_ARCH':'x86_64',
239                         'RELEASE':flag,
240                     }
241     call_scons(build_options, extra_option_str)
242     print ("*********** Build for android arm64-v8a *************")
243     build_options = {
244                         'TARGET_OS':'android',
245                         'TARGET_ARCH':'arm64-v8a',
246                         'RELEASE':flag,
247                     }
248     call_scons(build_options, extra_option_str)
249     print ("*********** Finishing Android universal build *************")
250
251 def build_android_secured(flag, extra_option_str):
252     build_android(flag, extra_option_str + " SECURED=1")
253
254 def build_android_unsecured(flag, extra_option_str):
255     build_android(flag, extra_option_str + " SECURED=0")
256
257 def build_android_x86(flag, extra_option_str):
258     """ Build Android x86 Suite """
259     build_android_x86_with_ip(flag, extra_option_str)
260     build_android_x86_with_bt(flag, extra_option_str)
261     build_android_x86_with_ble(flag, extra_option_str)
262
263 def build_android_x86_with_ip(flag, extra_option_str):
264     print ("*********** Build for android x86 *************")
265     build_options = {
266                         'TARGET_OS':'android',
267                         'TARGET_ARCH':'x86',
268                         'RELEASE':flag,
269                         'TARGET_TRANSPORT':'IP',
270                     }
271     call_scons(build_options, extra_option_str)
272
273 def build_android_x86_with_bt(flag, extra_option_str):
274     print ("*********** Build for android x86 with Bluetooth *************")
275     build_options = {
276                         'TARGET_OS':'android',
277                         'TARGET_ARCH':'x86',
278                         'RELEASE':flag,
279                         'TARGET_TRANSPORT':'BT',
280                     }
281     call_scons(build_options, extra_option_str)
282
283 def build_android_x86_with_ble(flag, extra_option_str):
284     print ("*********** Build for android x86 with Bluetooth Low Energy *************")
285     build_options = {
286                         'TARGET_OS':'android',
287                         'TARGET_ARCH':'x86',
288                         'RELEASE':flag,
289                         'TARGET_TRANSPORT':'BLE',
290                     }
291     call_scons(build_options, extra_option_str)
292
293 def build_android_x86_with_rm(flag, extra_option_str):
294     """ Build Android x86 Routing Manager Suite """
295     build_android_x86_with_rm_and_ip(flag, extra_option_str)
296     build_android_x86_with_rm_and_bt(flag, extra_option_str)
297     build_android_x86_with_rm_and_ble(flag, extra_option_str)
298
299 def build_android_x86_with_rm_and_ip(flag, extra_option_str):
300     print ("*********** Build for android x86 with Routing Manager *************")
301     build_options = {
302                         'TARGET_OS':'android',
303                         'TARGET_ARCH':'x86',
304                         'ROUTING':'GW',
305                         'RELEASE':flag,
306                         'TARGET_TRANSPORT':'IP',
307                     }
308     call_scons(build_options, extra_option_str)
309
310 def build_android_x86_with_rm_and_bt(flag, extra_option_str):
311     print ("*********** Build for android x86 with Routing Manager and Bluetooth *************")
312     build_options = {
313                         'TARGET_OS':'android',
314                         'TARGET_ARCH':'x86',
315                         'ROUTING':'GW',
316                         'RELEASE':flag,
317                         'TARGET_TRANSPORT':'BT',
318                     }
319     call_scons(build_options, extra_option_str)
320
321 def build_android_x86_with_rm_and_ble(flag, extra_option_str):
322     print ("*********** Build for android x86 with Routing Manager and Bluetooth Low Energy *************")
323     build_options = {
324                         'TARGET_OS':'android',
325                         'TARGET_ARCH':'x86',
326                         'ROUTING':'GW',
327                         'RELEASE':flag,
328                         'TARGET_TRANSPORT':'BLE',
329                     }
330     call_scons(build_options, extra_option_str)
331
332 def build_android_armeabi(flag, extra_option_str):
333     """ Build Android Armeabi Suite """
334     build_android_armeabi_with_ip(flag, extra_option_str)
335     build_android_armeabi_with_bt(flag, extra_option_str)
336     build_android_armeabi_with_ble(flag, extra_option_str)
337
338 def build_android_armeabi_with_ip(flag, extra_option_str):
339     print ("*********** Build for android armeabi *************")
340     build_options = {
341                         'TARGET_OS':'android',
342                         'TARGET_ARCH':'armeabi',
343                         'RELEASE':flag,
344                         'TARGET_TRANSPORT':'IP',
345                     }
346     call_scons(build_options, extra_option_str)
347
348 def build_android_armeabi_with_bt(flag, extra_option_str):
349     print ("*********** Build for android armeabi with Bluetooth *************")
350     build_options = {
351                         'TARGET_OS':'android',
352                         'TARGET_ARCH':'armeabi',
353                         'RELEASE':flag,
354                         'TARGET_TRANSPORT':'BT',
355                     }
356     call_scons(build_options, extra_option_str)
357
358 def build_android_armeabi_with_ble(flag, extra_option_str):
359     print ("*********** Build for android armeabi with Bluetooth Low Energy *************")
360     build_options = {
361                         'TARGET_OS':'android',
362                         'TARGET_ARCH':'armeabi',
363                         'RELEASE':flag,
364                         'TARGET_TRANSPORT':'BLE',
365                     }
366     call_scons(build_options, extra_option_str)
367
368 def build_android_armeabi_with_rm(flag, extra_option_str):
369     """ Build Android Armeabi Routing Manager Suite """
370     build_android_armeabi_with_rm_and_ip(flag, extra_option_str)
371     build_android_armeabi_with_rm_and_bt(flag, extra_option_str)
372     build_android_armeabi_with_rm_and_ble(flag, extra_option_str)
373
374 def build_android_armeabi_with_rm_and_ip(flag, extra_option_str):
375     print ("*********** Build for android armeabi with Routing Manager *************")
376     build_options = {
377                         'TARGET_OS':'android',
378                         'TARGET_ARCH':'armeabi',
379                         'ROUTING':'GW',
380                         'RELEASE':flag,
381                         'TARGET_TRANSPORT':'IP',
382                     }
383     call_scons(build_options, extra_option_str)
384
385 def build_android_armeabi_with_rm_and_bt(flag, extra_option_str):
386     print ("*********** Build for android armeabi with Routing Manager and Bluetooth *************")
387     build_options = {
388                         'TARGET_OS':'android',
389                         'TARGET_ARCH':'armeabi',
390                         'ROUTING':'GW',
391                         'RELEASE':flag,
392                         'TARGET_TRANSPORT':'BT',
393                     }
394     call_scons(build_options, extra_option_str)
395
396 def build_android_armeabi_with_rm_and_ble(flag, extra_option_str):
397     print ("*********** Build for android armeabi with Routing Manager and Bluetooth Low Energy *************")
398     build_options = {
399                         'TARGET_OS':'android',
400                         'TARGET_ARCH':'armeabi',
401                         'ROUTING':'GW',
402                         'RELEASE':flag,
403                         'TARGET_TRANSPORT':'BLE',
404                     }
405     call_scons(build_options, extra_option_str)
406
407 def build_arduino(flag, extra_option_str):
408     print ("*********** Build for arduino avr *************")
409     extra_option_str = "resource " + extra_option_str
410     build_options = {
411                         'TARGET_OS':'arduino',
412                         'UPLOAD':'false',
413                         'BOARD':'mega',
414                         'MULTIPLE_OWNER':0,
415                         'TARGET_ARCH':'avr',
416                         'TARGET_TRANSPORT':'IP',
417                         'SHIELD':'ETH',
418                         'RELEASE':flag,
419                     }
420     call_scons(build_options, extra_option_str)
421
422     build_options['SHIELD'] = 'WIFI'
423     call_scons(build_options, extra_option_str)
424
425     build_options['TARGET_TRANSPORT'] = 'BLE'
426     build_options['SHIELD']           = 'RBL_NRF8001'
427     call_scons(build_options, extra_option_str)
428
429     print ("*********** Build for arduino arm *************")
430     build_options['BOARD']            = 'arduino_due_x'
431     build_options['TARGET_ARCH']      = 'arm'
432     build_options['TARGET_TRANSPORT'] = 'IP'
433     build_options['SHIELD']           = 'ETH'
434     call_scons(build_options, extra_option_str)
435
436     build_options['SHIELD'] = 'WIFI'
437     call_scons(build_options, extra_option_str)
438
439     # BLE support for the Arduino Due is currently unavailable.
440
441 def build_tizen(flag, extra_option_str):
442     print ("*********** Build for Tizen with options *************")
443     cmd_line = os.getcwd() + "/gbsbuild.sh" + " " + extra_option_str
444     if not EXEC_MODE:
445         print ("Would run : " + cmd_line)
446     else:
447         print ("Running : " + cmd_line)
448         exit_code = subprocess.Popen([cmd_line], shell=True).wait()
449         if exit_code != 0:
450             sys.exit(exit_code)
451
452     print ("*********** Build for Tizen octbstack lib and sample *************")
453     build_extra_options = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
454     build_options = {
455                         'TARGET_OS':'tizen',
456                         'TARGET_TRANSPORT':'IP',
457                         'LOGGING':'true',
458                         'RELEASE':flag,
459                     }
460     call_scons(build_options, build_extra_options)
461
462     print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
463     build_options['ROUTING'] = 'GW'
464     call_scons(build_options, build_extra_options)
465
466     print ("*********** Build for Tizen Easy-Setup  sample *************")
467     build_options['ROUTING'] = 'EP'
468     build_options['ES_TARGET_ENROLLEE'] = 'tizen'
469     build_extra_options = "-f service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/SConscript " + extra_option_str
470     call_scons(build_options, build_extra_options)
471
472 def build_tizen_secured(flag, extra_option_str):
473     build_tizen(flag, extra_option_str + " SECURED=1")
474
475 def build_tizen_unsecured(flag, extra_option_str):
476     build_tizen(flag, extra_option_str + " SECURED=0")
477
478 # Mac OS and iOS
479 def build_darwin(flag, extra_option_str):
480     print ("*********** Build for OSX *************")
481     build_options = {
482                         'TARGET_OS':'darwin',
483                         'SYS_VERSION':'10.9',
484                         'RELEASE':flag,
485                     }
486     call_scons(build_options, extra_option_str)
487
488     print ("*********** Build for IOS i386 *************")
489     build_options = {
490                         'TARGET_OS':'ios',
491                         'TARGET_ARCH':'i386',
492                         'SYS_VERSION':'7.0',
493                         'RELEASE':flag,
494                     }
495     call_scons(build_options, extra_option_str)
496
497     print ("*********** Build for IOS x86_64 *************")
498     build_options['TARGET_ARCH'] = 'x86_64'
499     call_scons(build_options, extra_option_str)
500
501     print ("*********** Build for IOS armv7 *************")
502     build_options['TARGET_ARCH'] = 'armv7'
503     call_scons(build_options, extra_option_str)
504
505     print ("*********** Build for IOS armv7s *************")
506     build_options['TARGET_ARCH'] = 'armv7s'
507     call_scons(build_options, extra_option_str)
508
509     print ("*********** Build for IOS arm64 *************")
510     build_options['TARGET_ARCH'] = 'arm64'
511     call_scons(build_options, extra_option_str)
512
513 # Windows
514 def build_windows(flag, extra_option_str):
515     print ("*********** Build for Windows *************")
516     os.environ["SCONSFLAGS"] = ""
517     build_options = {
518                         'TARGET_OS':'windows',
519                         'TARGET_ARCH':'amd64',
520                         'RELEASE':flag,
521                         'TARGET_TRANSPORT':'IP',
522                         'WITH_TCP':0,
523                         'BUILD_SAMPLE':'ON',
524                         'LOGGING':'off',
525                         'TEST':1,
526                         'RD_MODE':'all',
527                     }
528     call_scons(build_options, extra_option_str)
529
530 # Windows msys
531 def build_msys(flag, extra_option_str):
532     print ("*********** Build for msys_nt *************")
533     os.environ["SCONSFLAGS"] = ""
534     build_options = {
535                         'TARGET_OS':'msys_nt',
536                         'TARGET_ARCH':'x86_64',
537                         'RELEASE':flag,
538                         'TARGET_TRANSPORT':'IP',
539                         'WITH_TCP':0,
540                         'BUILD_SAMPLE':'ON',
541                         'LOGGING':'off',
542                         'TEST':1,
543                         'RD_MODE':'all',
544                     }
545     call_scons(build_options, extra_option_str)
546
547 def build_simulator(flag, extra_option_str):
548     print ("*********** Build for simulator plugin *************")
549     build_options = {
550                         'SIMULATOR':1,
551                         'RELEASE':flag,
552                         'SECURED':0,
553                         'TARGET_TRANSPORT':'IP',
554                     }
555     call_scons(build_options, extra_option_str)
556
557 def unit_tests():
558     print ("*********** Unit test Start *************")
559     build_options = {
560                         'RELEASE':'false',
561                     }
562     extra_option_str = "-c ."
563     call_scons(build_options, extra_option_str)
564
565     build_options = {
566                         'TEST':1,
567                         'RELEASE':'false',
568                         'SECURED':0,
569                     }
570     extra_option_str = ""
571     call_scons(build_options, extra_option_str)
572
573     build_options = {
574                         'TEST':1,
575                         'SECURED':1,
576                         'RELEASE':'false',
577                     }
578     call_scons(build_options, extra_option_str)
579
580     print ("*********** Unit test Stop *************")
581
582 # Main module starts here
583 if os.getenv("SCONSFLAGS", "") == "":
584     os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
585
586 arg_num     = len(sys.argv)
587 script_name = sys.argv[0]
588
589 # May be overridden in user's shell
590 VERBOSE = os.getenv("VERBOSE", "1")
591 EXEC_MODE = os.getenv("EXEC_MODE", True)
592 if EXEC_MODE in ['false', 'False', '0']:
593     EXEC_MODE = False
594
595 if arg_num == 1:
596     build_all("true", "")
597     build_all("false", "")
598     unit_tests()
599
600 elif arg_num == 2:
601     if str(sys.argv[1]) == '-c':
602         build_all("true", "-c")
603         build_all("false", "-c")
604
605     elif str(sys.argv[1]) == "all":
606         build_all("true", "")
607         build_all("false", "")
608         unit_tests()
609
610     elif str(sys.argv[1]) == "linux":
611         build_linux("true", "")
612         build_linux("false", "")
613
614     elif str(sys.argv[1]) == "linux_unsecured":
615         build_linux_unsecured("true", "")
616         build_linux_unsecured("false", "")
617         build_linux_unsecured_with_rm("true", "")
618         build_linux_unsecured_with_rm("false", "")
619
620     elif str(sys.argv[1]) == "linux_secured":
621         build_linux_secured("true", "")
622         build_linux_secured("false", "")
623
624     elif str(sys.argv[1]) == "linux_full":
625         build_linux_full("true", "")
626         build_linux_full("false", "")
627
628     elif str(sys.argv[1]) == "linux_unsecured_with_rd":
629         build_linux_unsecured_with_rd("true", "")
630         build_linux_unsecured_with_rd("false", "")
631
632     elif str(sys.argv[1]) == "linux_secured_with_rd":
633         build_linux_secured_with_rd("true", "")
634         build_linux_secured_with_rd("false", "")
635
636     elif str(sys.argv[1]) == "linux_unsecured_with_mq":
637         build_linux_unsecured_with_mq("true", "")
638         build_linux_unsecured_with_mq("false", "")
639
640     elif str(sys.argv[1]) == "linux_unsecured_with_tcp":
641         build_linux_unsecured_with_tcp("true", "")
642         build_linux_unsecured_with_tcp("false", "")
643
644     elif str(sys.argv[1]) == "linux_secured_with_tcp":
645         build_linux_secured_with_tcp("false", "")
646         build_linux_secured_with_tcp("true", "")
647
648     elif str(sys.argv[1]) == "linux_unsecured_with_java":
649         build_linux_unsecured_with_java("false", "")
650         build_linux_unsecured_with_java("true", "")
651
652     elif str(sys.argv[1]) == "linux_secured_with_java":
653         build_linux_secured_with_java("false", "")
654         build_linux_secured_with_java("true", "")
655
656     elif str(sys.argv[1]) == "android":
657         build_android("true", "")
658         build_android("false", "")
659
660     elif str(sys.argv[1]) == "android_universal":
661         # only build the release version due to long amount of time to build.
662         build_android_universal("true", "")
663
664     elif str(sys.argv[1]) == "android_universal_unsecured":
665         # only build the release version due to long amount of time to build.
666         build_android_universal("true", "SECURED=0")
667
668     elif str(sys.argv[1]) == "android_unsecured":
669         build_android_unsecured("true", "")
670         build_android_unsecured("false", "")
671
672     elif str(sys.argv[1]) == "android_secured":
673         build_android_secured("true", "")
674         build_android_secured("false", "")
675
676     elif str(sys.argv[1]) == "android_x86":
677         build_android_x86("true", "")
678         build_android_x86("false", "")
679         build_android_x86_with_rm("true", "")
680         build_android_x86_with_rm("false", "")
681
682     elif str(sys.argv[1]) == "android_x86_with_ip":
683         build_android_x86_with_ip("true", "")
684         build_android_x86_with_ip("false", "")
685
686     elif str(sys.argv[1]) == "android_x86_with_bt":
687         build_android_x86_with_bt("true", "")
688         build_android_x86_with_bt("false", "")
689
690     elif str(sys.argv[1]) == "android_x86_with_ble":
691         build_android_x86_with_ble("true", "")
692         build_android_x86_with_ble("false", "")
693
694     elif str(sys.argv[1]) == "android_x86_with_rm_and_ip":
695         build_android_x86_with_rm_and_ip("true", "")
696         build_android_x86_with_rm_and_ip("false", "")
697
698     elif str(sys.argv[1]) == "android_x86_with_rm_and_bt":
699         build_android_x86_with_rm_and_bt("true", "")
700         build_android_x86_with_rm_and_bt("false", "")
701
702     elif str(sys.argv[1]) == "android_x86_with_rm_and_ble":
703         build_android_x86_with_rm_and_ble("true", "")
704         build_android_x86_with_rm_and_ble("false", "")
705
706     elif str(sys.argv[1]) == "android_armeabi":
707         build_android_armeabi("true", "")
708         build_android_armeabi("false", "")
709         build_android_armeabi_with_rm("true", "")
710         build_android_armeabi_with_rm("false", "")
711
712     elif str(sys.argv[1]) == "android_armeabi_with_ip":
713         build_android_armeabi_with_ip("true", "")
714         build_android_armeabi_with_ip("false", "")
715
716     elif str(sys.argv[1]) == "android_armeabi_with_bt":
717         build_android_armeabi_with_bt("true", "")
718         build_android_armeabi_with_bt("false", "")
719
720     elif str(sys.argv[1]) == "android_armeabi_with_ble":
721         build_android_armeabi_with_ble("true", "")
722         build_android_armeabi_with_ble("false", "")
723
724     elif str(sys.argv[1]) == "android_armeabi_with_rm_and_ip":
725         build_android_armeabi_with_rm_and_ip("true", "")
726         build_android_armeabi_with_rm_and_ip("false", "")
727
728     elif str(sys.argv[1]) == "android_armeabi_with_rm_and_bt":
729         build_android_armeabi_with_rm_and_bt("true", "")
730         build_android_armeabi_with_rm_and_bt("false", "")
731
732     elif str(sys.argv[1]) == "android_armeabi_with_rm_and_ble":
733         build_android_armeabi_with_rm_and_ble("true", "")
734         build_android_armeabi_with_rm_and_ble("false", "")
735
736     elif str(sys.argv[1]) == "arduino":
737         build_arduino("true", "")
738         build_arduino("false", "")
739
740     elif str(sys.argv[1]) == "windows":
741         build_windows("true", "")
742         build_windows("false", "")
743
744     elif str(sys.argv[1]) == "msys":
745         build_msys("true", "")
746         build_msys("false", "")
747
748     elif str(sys.argv[1]) == "tizen":
749         build_tizen("true", "")
750         build_tizen("false", "")
751
752     elif str(sys.argv[1]) == "tizen_unsecured":
753         build_tizen_unsecured("true", "")
754         build_tizen_unsecured("false", "")
755
756     elif str(sys.argv[1]) == "tizen_secured":
757         build_tizen_secured("true", "")
758         build_tizen_secured("false", "")
759
760     elif str(sys.argv[1]) == "simulator":
761         build_simulator("true", "")
762         build_simulator("false", "")
763
764     elif str(sys.argv[1]) == "darwin":
765         build_darwin("true", "")
766         build_darwin("false", "")
767
768     elif str(sys.argv[1]) == "unit_tests":
769         unit_tests()
770
771     else:
772         helpmsg(script_name)
773 else:
774         helpmsg(script_name)
775
776 print ("===================== done =====================")