14 python %s <targetbuild>
15 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, simulator, darwin, windows, msys
16 Note: \"linux\" will build \"linux_unsecured\", \"linux_secured\", \"linux_unsecured_with_ra\", \"linux_secured_with_ra\", \"linux_secured_with_rd\", \"linux_unsecured_with_mq\", \"linux_secured_with_tcp\" & \"linux_unsecured_with_tcp\" & \"linux_unsecured_with_rd\".
17 Any selection will build both debug and release versions of all available targets in the scope you've selected.
18 To choose any specific command, please use the SCons commandline directly. Please refer to [IOTIVITY_REPO]/Readme.scons.txt.
22 print (helpstr % (script, script))
25 def call_scons(build_options, extra_option_str):
27 This function formats and runs a scons command
29 build_options -- {Dictionary} build flags (keys) associated with values;
30 extra_option_str -- {String} extra options to append to scons command
32 cmd_line = "scons VERBOSE=" + VERBOSE
33 for key in build_options:
34 cmd_line += " " + key + "=" + str(build_options[key])
36 cmd_line += " " + str(extra_option_str)
38 print ("Running : " + cmd_line)
40 exit_code = subprocess.Popen(cmd_line, shell=True).wait()
44 def build_all(flag, extra_option_str):
45 if platform.system() == "Linux":
46 build_linux_unsecured(flag, extra_option_str)
47 build_linux_secured(flag, extra_option_str)
48 build_linux_unsecured_with_ra(flag, extra_option_str)
49 build_linux_secured_with_ra(flag, extra_option_str)
50 build_linux_unsecured_with_rm(flag, extra_option_str)
51 build_linux_unsecured_with_rd(flag, extra_option_str)
52 build_linux_secured_with_rd(flag, extra_option_str)
53 build_linux_unsecured_with_mq(flag, extra_option_str)
54 build_linux_unsecured_with_tcp(flag, extra_option_str)
55 build_linux_secured_with_tcp(flag, extra_option_str)
56 build_linux_unsecured_with_java(flag, extra_option_str)
57 build_linux_secured_with_java(flag, extra_option_str)
58 build_simulator(flag, extra_option_str)
60 build_android(flag, extra_option_str)
61 build_arduino(flag, extra_option_str)
62 build_tizen(flag, extra_option_str)
64 if platform.system() == "Windows":
65 build_windows(flag, extra_option_str)
67 if platform.system() == "Darwin":
68 build_darwin(flag, extra_option_str)
70 def build_linux(flag, extra_option_str):
71 build_linux_unsecured(flag, extra_option_str)
72 build_linux_secured(flag, extra_option_str)
74 def build_linux_unsecured(flag, extra_option_str):
75 print ("*********** Build for linux ************")
80 call_scons(build_options, extra_option_str)
82 def build_linux_secured_with_tcp(flag, extra_option_str):
83 print ("*********** Build for linux with Secured TCP ************")
89 call_scons(build_options, extra_option_str)
91 def build_linux_unsecured_with_java(flag, extra_option_str):
92 print ("*********** Build for linux with Java support ************")
96 'TARGET_TRANSPORT': 'IP',
98 call_scons(build_options, extra_option_str)
100 def build_linux_secured_with_java(flag, extra_option_str):
101 print ("*********** Build for linux with Java support and secured ************")
105 'TARGET_TRANSPORT': 'IP',
108 call_scons(build_options, extra_option_str)
110 def build_linux_unsecured_with_tcp(flag, extra_option_str):
111 print ("*********** Build for linux with TCP ************")
115 'TARGET_TRANSPORT': 'IP',
118 call_scons(build_options, extra_option_str)
120 def build_linux_unsecured_with_rm(flag, extra_option_str):
121 print ("*********** Build for linux with RoutingManager************")
127 call_scons(build_options, extra_option_str)
129 def build_linux_secured(flag, extra_option_str):
130 print ("*********** Build for linux with Security *************")
134 call_scons(build_options, extra_option_str)
136 def build_linux_unsecured_with_ra(flag, extra_option_str):
137 print ("*********** Build for linux With Remote Access *************")
144 call_scons(build_options, extra_option_str)
146 def build_linux_secured_with_ra(flag, extra_option_str):
147 print ("*********** Build for linux With Remote Access & Security ************")
153 call_scons(build_options, extra_option_str)
155 def build_linux_unsecured_with_rd(flag, extra_option_str):
156 print ("*********** Build for linux With Resource Directory *************")
162 call_scons(build_options, extra_option_str)
164 def build_linux_secured_with_rd(flag, extra_option_str):
165 print ("*********** Build for linux With Resource Directory & Security ************")
170 call_scons(build_options, extra_option_str)
172 def build_linux_unsecured_with_mq(flag, extra_option_str):
173 print ("*********** Build for linux With Message Queue ************")
176 'WITH_MQ':'PUB,SUB,BROKER',
179 call_scons(build_options, extra_option_str)
181 def build_linux_unsecured_with_tcp(flag, extra_option_str):
182 print ("*********** Build for linux With tcp ************")
188 call_scons(build_options, extra_option_str)
190 def build_android(flag, extra_option_str):
191 # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
192 # it requires gcc-4.9, currently only android-ndk-r10(for linux)
193 # and windows android-ndk-r10(64bit target version) support these features.
194 print ("*********** Build for android armeabi *************")
196 'TARGET_OS':'android',
197 'TARGET_ARCH':'armeabi',
200 call_scons(build_options, extra_option_str)
202 def build_android_x86(flag, extra_option_str):
203 """ Build Android x86 Suite """
204 build_android_x86_with_ip(flag, extra_option_str)
205 build_android_x86_with_bt(flag, extra_option_str)
206 build_android_x86_with_ble(flag, extra_option_str)
208 def build_android_x86_with_ip(flag, extra_option_str):
209 print ("*********** Build for android x86 *************")
211 'TARGET_OS':'android',
214 'TARGET_TRANSPORT':'IP',
216 call_scons(build_options, extra_option_str)
218 def build_android_x86_with_bt(flag, extra_option_str):
219 print ("*********** Build for android x86 with Bluetooth *************")
221 'TARGET_OS':'android',
224 'TARGET_TRANSPORT':'BT',
226 call_scons(build_options, extra_option_str)
228 def build_android_x86_with_ble(flag, extra_option_str):
229 print ("*********** Build for android x86 with Bluetooth Low Energy *************")
231 'TARGET_OS':'android',
234 'TARGET_TRANSPORT':'BLE',
236 call_scons(build_options, extra_option_str)
238 def build_android_x86_with_rm(flag, extra_option_str):
239 """ Build Android x86 Routing Manager Suite """
240 build_android_x86_with_rm_and_ip(flag, extra_option_str)
241 build_android_x86_with_rm_and_bt(flag, extra_option_str)
242 build_android_x86_with_rm_and_ble(flag, extra_option_str)
244 def build_android_x86_with_rm_and_ip(flag, extra_option_str):
245 print ("*********** Build for android x86 with Routing Manager *************")
247 'TARGET_OS':'android',
251 'TARGET_TRANSPORT':'IP',
253 call_scons(build_options, extra_option_str)
255 def build_android_x86_with_rm_and_bt(flag, extra_option_str):
256 print ("*********** Build for android x86 with Routing Manager and Bluetooth *************")
258 'TARGET_OS':'android',
262 'TARGET_TRANSPORT':'BT',
264 call_scons(build_options, extra_option_str)
266 def build_android_x86_with_rm_and_ble(flag, extra_option_str):
267 print ("*********** Build for android x86 with Routing Manager and Bluetooth Low Energy *************")
269 'TARGET_OS':'android',
273 'TARGET_TRANSPORT':'BLE',
275 call_scons(build_options, extra_option_str)
277 def build_android_armeabi(flag, extra_option_str):
278 """ Build Android Armeabi Suite """
279 build_android_armeabi_with_ip(flag, extra_option_str)
280 build_android_armeabi_with_bt(flag, extra_option_str)
281 build_android_armeabi_with_ble(flag, extra_option_str)
283 def build_android_armeabi_with_ip(flag, extra_option_str):
284 print ("*********** Build for android armeabi *************")
286 'TARGET_OS':'android',
287 'TARGET_ARCH':'armeabi',
289 'TARGET_TRANSPORT':'IP',
291 call_scons(build_options, extra_option_str)
293 def build_android_armeabi_with_bt(flag, extra_option_str):
294 print ("*********** Build for android armeabi with Bluetooth *************")
296 'TARGET_OS':'android',
297 'TARGET_ARCH':'armeabi',
299 'TARGET_TRANSPORT':'BT',
301 call_scons(build_options, extra_option_str)
303 def build_android_armeabi_with_ble(flag, extra_option_str):
304 print ("*********** Build for android armeabi with Bluetooth Low Energy *************")
306 'TARGET_OS':'android',
307 'TARGET_ARCH':'armeabi',
309 'TARGET_TRANSPORT':'BLE',
311 call_scons(build_options, extra_option_str)
313 def build_android_armeabi_with_rm(flag, extra_option_str):
314 """ Build Android Armeabi Routing Manager Suite """
315 build_android_armeabi_with_rm_and_ip(flag, extra_option_str)
316 build_android_armeabi_with_rm_and_bt(flag, extra_option_str)
317 build_android_armeabi_with_rm_and_ble(flag, extra_option_str)
319 def build_android_armeabi_with_rm_and_ip(flag, extra_option_str):
320 print ("*********** Build for android armeabi with Routing Manager *************")
322 'TARGET_OS':'android',
323 'TARGET_ARCH':'armeabi',
326 'TARGET_TRANSPORT':'IP',
328 call_scons(build_options, extra_option_str)
330 def build_android_armeabi_with_rm_and_bt(flag, extra_option_str):
331 print ("*********** Build for android armeabi with Routing Manager and Bluetooth *************")
333 'TARGET_OS':'android',
334 'TARGET_ARCH':'armeabi',
337 'TARGET_TRANSPORT':'BT',
339 call_scons(build_options, extra_option_str)
341 def build_android_armeabi_with_rm_and_ble(flag, extra_option_str):
342 print ("*********** Build for android armeabi with Routing Manager and Bluetooth Low Energy *************")
344 'TARGET_OS':'android',
345 'TARGET_ARCH':'armeabi',
348 'TARGET_TRANSPORT':'BLE',
350 call_scons(build_options, extra_option_str)
352 def build_arduino(flag, extra_option_str):
353 print ("*********** Build for arduino avr *************")
354 extra_option_str = "resource " + extra_option_str
356 'TARGET_OS':'arduino',
360 'TARGET_TRANSPORT':'IP',
364 call_scons(build_options, extra_option_str)
366 build_options['SHIELD'] = 'WIFI'
367 call_scons(build_options, extra_option_str)
369 build_options['TARGET_TRANSPORT'] = 'BLE'
370 build_options['SHIELD'] = 'RBL_NRF8001'
371 call_scons(build_options, extra_option_str)
373 print ("*********** Build for arduino arm *************")
374 build_options['BOARD'] = 'arduino_due_x'
375 build_options['TARGET_ARCH'] = 'arm'
376 build_options['TARGET_TRANSPORT'] = 'IP'
377 build_options['SHIELD'] = 'ETH'
378 call_scons(build_options, extra_option_str)
380 build_options['SHIELD'] = 'WIFI'
381 call_scons(build_options, extra_option_str)
383 # BLE support for the Arduino Due is currently unavailable.
385 def build_tizen(flag, extra_option_str):
386 print ("*********** Build for Tizen *************")
387 cmd_line = "/bin/sh " + os.getcwd() + "/gbsbuild.sh"
388 print ("Running : " + cmd_line)
389 exit_code = subprocess.Popen([cmd_line], shell=True).wait()
393 print ("*********** Build for Tizen octbstack lib and sample with security *************")
394 extra_option_str = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
397 'TARGET_TRANSPORT':'IP',
401 call_scons(build_options, extra_option_str)
403 print ("*********** Build for Tizen octbstack lib and sample *************")
404 build_options['SECURED'] = 0
405 call_scons(build_options, extra_option_str)
407 print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
408 build_options['ROUTING'] = 'GW'
409 call_scons(build_options, extra_option_str)
412 def build_darwin(flag, extra_option_str):
413 print ("*********** Build for OSX *************")
415 'TARGET_OS':'darwin',
416 'SYS_VERSION':'10.9',
419 call_scons(build_options, extra_option_str)
421 print ("*********** Build for IOS i386 *************")
424 'TARGET_ARCH':'i386',
428 call_scons(build_options, extra_option_str)
430 print ("*********** Build for IOS x86_64 *************")
431 build_options['TARGET_ARCH'] = 'x86_64'
432 call_scons(build_options, extra_option_str)
434 print ("*********** Build for IOS armv7 *************")
435 build_options['TARGET_ARCH'] = 'armv7'
436 call_scons(build_options, extra_option_str)
438 print ("*********** Build for IOS armv7s *************")
439 build_options['TARGET_ARCH'] = 'armv7s'
440 call_scons(build_options, extra_option_str)
442 print ("*********** Build for IOS arm64 *************")
443 build_options['TARGET_ARCH'] = 'arm64'
444 call_scons(build_options, extra_option_str)
447 def build_windows(flag, extra_option_str):
448 print ("*********** Build for Windows *************")
449 os.environ["SCONSFLAGS"] = ""
451 'TARGET_OS':'windows',
452 'TARGET_ARCH':'amd64',
455 'TARGET_TRANSPORT':'IP',
462 call_scons(build_options, extra_option_str)
465 def build_msys(flag, extra_option_str):
466 print ("*********** Build for msys_nt *************")
467 os.environ["SCONSFLAGS"] = ""
469 'TARGET_OS':'msys_nt',
470 'TARGET_ARCH':'x86_64',
473 'TARGET_TRANSPORT':'IP',
480 call_scons(build_options, extra_option_str)
482 def build_simulator(flag, extra_option_str):
483 print ("*********** Build for simulator plugin *************")
488 call_scons(build_options, extra_option_str)
491 print ("*********** Unit test Start *************")
495 extra_option_str = "-c ."
496 call_scons(build_options, extra_option_str)
503 extra_option_str = ""
504 call_scons(build_options, extra_option_str)
511 call_scons(build_options, extra_option_str)
513 print ("*********** Unit test Stop *************")
515 # Main module starts here
516 if os.getenv("SCONSFLAGS", "") == "":
517 os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
519 arg_num = len(sys.argv)
520 script_name = sys.argv[0]
522 # May be overridden in user's shell
523 VERBOSE = os.getenv("VERBOSE", "1")
526 build_all("true", "")
527 build_all("false", "")
531 if str(sys.argv[1]) == '-c':
532 build_all("true", "-c")
533 build_all("false", "-c")
535 elif str(sys.argv[1]) == "all":
536 build_all("true", "")
537 build_all("false", "")
540 elif str(sys.argv[1]) == "linux":
541 build_linux("true", "")
542 build_linux("false", "")
544 elif str(sys.argv[1]) == "linux_unsecured":
545 build_linux_unsecured("true", "")
546 build_linux_unsecured("false", "")
547 build_linux_unsecured_with_rm("true", "")
548 build_linux_unsecured_with_rm("false", "")
550 elif str(sys.argv[1]) == "linux_secured":
551 build_linux_secured("true", "")
552 build_linux_secured("false", "")
554 elif str(sys.argv[1]) == "linux_unsecured_with_ra":
555 build_linux_unsecured_with_ra("true", "")
556 build_linux_unsecured_with_ra("false", "")
558 elif str(sys.argv[1]) == "linux_secured_with_ra":
559 build_linux_secured_with_ra("true", "")
560 build_linux_secured_with_ra("false", "")
562 elif str(sys.argv[1]) == "linux_unsecured_with_rd":
563 build_linux_unsecured_with_rd("true", "")
564 build_linux_unsecured_with_rd("false", "")
566 elif str(sys.argv[1]) == "linux_secured_with_rd":
567 build_linux_secured_with_rd("true", "")
568 build_linux_secured_with_rd("false", "")
570 elif str(sys.argv[1]) == "linux_unsecured_with_mq":
571 build_linux_unsecured_with_mq("true", "")
572 build_linux_unsecured_with_mq("false", "")
574 elif str(sys.argv[1]) == "linux_unsecured_with_tcp":
575 build_linux_unsecured_with_tcp("true", "")
576 build_linux_unsecured_with_tcp("false", "")
578 elif str(sys.argv[1]) == "linux_secured_with_tcp":
579 build_linux_secured_with_tcp("false", "")
580 build_linux_secured_with_tcp("true", "")
582 elif str(sys.argv[1]) == "linux_unsecured_with_java":
583 build_linux_unsecured_with_java("false", "")
584 build_linux_unsecured_with_java("true", "")
586 elif str(sys.argv[1]) == "linux_secured_with_java":
587 build_linux_secured_with_java("false", "")
588 build_linux_secured_with_java("true", "")
590 elif str(sys.argv[1]) == "android":
591 build_android("true", "")
592 build_android("false", "")
594 elif str(sys.argv[1]) == "android_x86":
595 build_android_x86("true", "")
596 build_android_x86("false", "")
597 build_android_x86_with_rm("true", "")
598 build_android_x86_with_rm("false", "")
600 elif str(sys.argv[1]) == "android_x86_with_ip":
601 build_android_x86_with_ip("true", "")
602 build_android_x86_with_ip("false", "")
604 elif str(sys.argv[1]) == "android_x86_with_bt":
605 build_android_x86_with_bt("true", "")
606 build_android_x86_with_bt("false", "")
608 elif str(sys.argv[1]) == "android_x86_with_ble":
609 build_android_x86_with_ble("true", "")
610 build_android_x86_with_ble("false", "")
612 elif str(sys.argv[1]) == "android_x86_with_rm_and_ip":
613 build_android_x86_with_rm_and_ip("true", "")
614 build_android_x86_with_rm_and_ip("false", "")
616 elif str(sys.argv[1]) == "android_x86_with_rm_and_bt":
617 build_android_x86_with_rm_and_bt("true", "")
618 build_android_x86_with_rm_and_bt("false", "")
620 elif str(sys.argv[1]) == "android_x86_with_rm_and_ble":
621 build_android_x86_with_rm_and_ble("true", "")
622 build_android_x86_with_rm_and_ble("false", "")
624 elif str(sys.argv[1]) == "android_armeabi":
625 build_android_armeabi("true", "")
626 build_android_armeabi("false", "")
627 build_android_armeabi_with_rm("true", "")
628 build_android_armeabi_with_rm("false", "")
630 elif str(sys.argv[1]) == "android_armeabi_with_ip":
631 build_android_armeabi_with_ip("true", "")
632 build_android_armeabi_with_ip("false", "")
634 elif str(sys.argv[1]) == "android_armeabi_with_bt":
635 build_android_armeabi_with_bt("true", "")
636 build_android_armeabi_with_bt("false", "")
638 elif str(sys.argv[1]) == "android_armeabi_with_ble":
639 build_android_armeabi_with_ble("true", "")
640 build_android_armeabi_with_ble("false", "")
642 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_ip":
643 build_android_armeabi_with_rm_and_ip("true", "")
644 build_android_armeabi_with_rm_and_ip("false", "")
646 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_bt":
647 build_android_armeabi_with_rm_and_bt("true", "")
648 build_android_armeabi_with_rm_and_bt("false", "")
650 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_ble":
651 build_android_armeabi_with_rm_and_ble("true", "")
652 build_android_armeabi_with_rm_and_ble("false", "")
654 elif str(sys.argv[1]) == "arduino":
655 build_arduino("true", "")
656 build_arduino("false", "")
658 elif str(sys.argv[1]) == "windows":
659 build_windows("true", "")
660 build_windows("false", "")
662 elif str(sys.argv[1]) == "msys":
663 build_msys("true", "")
664 build_msys("false", "")
666 elif str(sys.argv[1]) == "tizen":
667 build_tizen("true", "")
668 build_tizen("false", "")
670 elif str(sys.argv[1]) == "simulator":
671 build_simulator("true", "")
672 build_simulator("false", "")
674 elif str(sys.argv[1]) == "darwin":
675 build_darwin("true", "")
676 build_darwin("false", "")
678 elif str(sys.argv[1]) == "unit_tests":
686 print ("===================== done =====================")