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 ************")
79 call_scons(build_options, extra_option_str)
81 def build_linux_secured_with_tcp(flag, extra_option_str):
82 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',
117 call_scons(build_options, extra_option_str)
119 def build_linux_unsecured_with_rm(flag, extra_option_str):
120 print ("*********** Build for linux with RoutingManager************")
125 call_scons(build_options, extra_option_str)
127 def build_linux_secured(flag, extra_option_str):
128 print ("*********** Build for linux with Security *************")
133 call_scons(build_options, extra_option_str)
135 def build_linux_unsecured_with_ra(flag, extra_option_str):
136 print ("*********** Build for linux With Remote Access *************")
142 call_scons(build_options, extra_option_str)
144 def build_linux_secured_with_ra(flag, extra_option_str):
145 print ("*********** Build for linux With Remote Access & Security ************")
152 call_scons(build_options, extra_option_str)
154 def build_linux_unsecured_with_rd(flag, extra_option_str):
155 print ("*********** Build for linux With Resource Directory *************")
160 call_scons(build_options, extra_option_str)
162 def build_linux_secured_with_rd(flag, extra_option_str):
163 print ("*********** Build for linux With Resource Directory & Security ************")
169 call_scons(build_options, extra_option_str)
171 def build_linux_unsecured_with_mq(flag, extra_option_str):
172 print ("*********** Build for linux With Message Queue ************")
175 'WITH_MQ':'PUB,SUB,BROKER',
177 call_scons(build_options, extra_option_str)
179 def build_linux_unsecured_with_tcp(flag, extra_option_str):
180 print ("*********** Build for linux With tcp ************")
185 call_scons(build_options, extra_option_str)
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 *************")
193 'TARGET_OS':'android',
194 'TARGET_ARCH':'armeabi',
197 call_scons(build_options, extra_option_str)
199 def build_android_x86(flag, extra_option_str):
200 """ Build Android x86 Suite """
201 build_android_x86_with_ip(flag, extra_option_str)
202 build_android_x86_with_bt(flag, extra_option_str)
203 build_android_x86_with_ble(flag, extra_option_str)
205 def build_android_x86_with_ip(flag, extra_option_str):
206 print ("*********** Build for android x86 *************")
208 'TARGET_OS':'android',
211 'TARGET_TRANSPORT':'IP',
213 call_scons(build_options, extra_option_str)
215 def build_android_x86_with_bt(flag, extra_option_str):
216 print ("*********** Build for android x86 with Bluetooth *************")
218 'TARGET_OS':'android',
221 'TARGET_TRANSPORT':'BT',
223 call_scons(build_options, extra_option_str)
225 def build_android_x86_with_ble(flag, extra_option_str):
226 print ("*********** Build for android x86 with Bluetooth Low Energy *************")
228 'TARGET_OS':'android',
231 'TARGET_TRANSPORT':'BLE',
233 call_scons(build_options, extra_option_str)
235 def build_android_x86_with_rm(flag, extra_option_str):
236 """ Build Android x86 Routing Manager Suite """
237 build_android_x86_with_rm_and_ip(flag, extra_option_str)
238 build_android_x86_with_rm_and_bt(flag, extra_option_str)
239 build_android_x86_with_rm_and_ble(flag, extra_option_str)
241 def build_android_x86_with_rm_and_ip(flag, extra_option_str):
242 print ("*********** Build for android x86 with Routing Manager *************")
244 'TARGET_OS':'android',
248 'TARGET_TRANSPORT':'IP',
250 call_scons(build_options, extra_option_str)
252 def build_android_x86_with_rm_and_bt(flag, extra_option_str):
253 print ("*********** Build for android x86 with Routing Manager and Bluetooth *************")
255 'TARGET_OS':'android',
259 'TARGET_TRANSPORT':'BT',
261 call_scons(build_options, extra_option_str)
263 def build_android_x86_with_rm_and_ble(flag, extra_option_str):
264 print ("*********** Build for android x86 with Routing Manager and Bluetooth Low Energy *************")
266 'TARGET_OS':'android',
270 'TARGET_TRANSPORT':'BLE',
272 call_scons(build_options, extra_option_str)
274 def build_android_armeabi(flag, extra_option_str):
275 """ Build Android Armeabi Suite """
276 build_android_armeabi_with_ip(flag, extra_option_str)
277 build_android_armeabi_with_bt(flag, extra_option_str)
278 build_android_armeabi_with_ble(flag, extra_option_str)
280 def build_android_armeabi_with_ip(flag, extra_option_str):
281 print ("*********** Build for android armeabi *************")
283 'TARGET_OS':'android',
284 'TARGET_ARCH':'armeabi',
286 'TARGET_TRANSPORT':'IP',
288 call_scons(build_options, extra_option_str)
290 def build_android_armeabi_with_bt(flag, extra_option_str):
291 print ("*********** Build for android armeabi with Bluetooth *************")
293 'TARGET_OS':'android',
294 'TARGET_ARCH':'armeabi',
296 'TARGET_TRANSPORT':'BT',
298 call_scons(build_options, extra_option_str)
300 def build_android_armeabi_with_ble(flag, extra_option_str):
301 print ("*********** Build for android armeabi with Bluetooth Low Energy *************")
303 'TARGET_OS':'android',
304 'TARGET_ARCH':'armeabi',
306 'TARGET_TRANSPORT':'BLE',
308 call_scons(build_options, extra_option_str)
310 def build_android_armeabi_with_rm(flag, extra_option_str):
311 """ Build Android Armeabi Routing Manager Suite """
312 build_android_armeabi_with_rm_and_ip(flag, extra_option_str)
313 build_android_armeabi_with_rm_and_bt(flag, extra_option_str)
314 build_android_armeabi_with_rm_and_ble(flag, extra_option_str)
316 def build_android_armeabi_with_rm_and_ip(flag, extra_option_str):
317 print ("*********** Build for android armeabi with Routing Manager *************")
319 'TARGET_OS':'android',
320 'TARGET_ARCH':'armeabi',
323 'TARGET_TRANSPORT':'IP',
325 call_scons(build_options, extra_option_str)
327 def build_android_armeabi_with_rm_and_bt(flag, extra_option_str):
328 print ("*********** Build for android armeabi with Routing Manager and Bluetooth *************")
330 'TARGET_OS':'android',
331 'TARGET_ARCH':'armeabi',
334 'TARGET_TRANSPORT':'BT',
336 call_scons(build_options, extra_option_str)
338 def build_android_armeabi_with_rm_and_ble(flag, extra_option_str):
339 print ("*********** Build for android armeabi with Routing Manager and Bluetooth Low Energy *************")
341 'TARGET_OS':'android',
342 'TARGET_ARCH':'armeabi',
345 'TARGET_TRANSPORT':'BLE',
347 call_scons(build_options, extra_option_str)
349 def build_arduino(flag, extra_option_str):
350 print ("*********** Build for arduino avr *************")
351 extra_option_str = "resource " + extra_option_str
353 'TARGET_OS':'arduino',
357 'TARGET_TRANSPORT':'IP',
361 call_scons(build_options, extra_option_str)
363 build_options['SHIELD'] = 'WIFI'
364 call_scons(build_options, extra_option_str)
366 build_options['TARGET_TRANSPORT'] = 'BLE'
367 build_options['SHIELD'] = 'RBL_NRF8001'
368 call_scons(build_options, extra_option_str)
370 print ("*********** Build for arduino arm *************")
371 build_options['BOARD'] = 'arduino_due_x'
372 build_options['TARGET_ARCH'] = 'arm'
373 build_options['TARGET_TRANSPORT'] = 'IP'
374 build_options['SHIELD'] = 'ETH'
375 call_scons(build_options, extra_option_str)
377 build_options['SHIELD'] = 'WIFI'
378 call_scons(build_options, extra_option_str)
380 # BLE support for the Arduino Due is currently unavailable.
382 def build_tizen(flag, extra_option_str):
383 print ("*********** Build for Tizen *************")
384 cmd_line = "/bin/sh " + os.getcwd() + "/gbsbuild.sh"
385 print ("Running : " + cmd_line)
386 subprocess.Popen([cmd_line], shell=True).wait()
388 print ("*********** Build for Tizen octbstack lib and sample *************")
389 extra_option_str = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
392 'TARGET_TRANSPORT':'IP',
396 call_scons(build_options, extra_option_str)
398 print ("*********** Build for Tizen octbstack lib and sample with Security*************")
399 build_options['SECURED'] = 1
400 call_scons(build_options, extra_option_str)
402 print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
403 del build_options['SECURED']
404 build_options['ROUTING'] = 'GW'
405 call_scons(build_options, extra_option_str)
408 def build_darwin(flag, extra_option_str):
409 print ("*********** Build for OSX *************")
411 'TARGET_OS':'darwin',
412 'SYS_VERSION':'10.9',
415 call_scons(build_options, extra_option_str)
417 print ("*********** Build for IOS i386 *************")
420 'TARGET_ARCH':'i386',
424 call_scons(build_options, extra_option_str)
426 print ("*********** Build for IOS x86_64 *************")
427 build_options['TARGET_ARCH'] = 'x86_64'
428 call_scons(build_options, extra_option_str)
430 print ("*********** Build for IOS armv7 *************")
431 build_options['TARGET_ARCH'] = 'armv7'
432 call_scons(build_options, extra_option_str)
434 print ("*********** Build for IOS armv7s *************")
435 build_options['TARGET_ARCH'] = 'armv7s'
436 call_scons(build_options, extra_option_str)
438 print ("*********** Build for IOS arm64 *************")
439 build_options['TARGET_ARCH'] = 'arm64'
440 call_scons(build_options, extra_option_str)
443 def build_windows(flag, extra_option_str):
444 print ("*********** Build for Windows *************")
445 os.environ["SCONSFLAGS"] = ""
447 'TARGET_OS':'windows',
448 'TARGET_ARCH':'amd64',
451 'TARGET_TRANSPORT':'IP',
459 call_scons(build_options, extra_option_str)
462 def build_msys(flag, extra_option_str):
463 print ("*********** Build for msys_nt *************")
464 os.environ["SCONSFLAGS"] = ""
466 'TARGET_OS':'msys_nt',
467 'TARGET_ARCH':'x86_64',
470 'TARGET_TRANSPORT':'IP',
478 call_scons(build_options, extra_option_str)
480 def build_simulator(flag, extra_option_str):
481 print ("*********** Build for simulator plugin *************")
486 call_scons(build_options, extra_option_str)
489 print ("*********** Unit test Start *************")
493 extra_option_str = "-c ."
494 call_scons(build_options, extra_option_str)
500 extra_option_str = ""
501 call_scons(build_options, extra_option_str)
508 call_scons(build_options, extra_option_str)
510 print ("*********** Unit test Stop *************")
512 # Main module starts here
513 if os.getenv("SCONSFLAGS", "") == "":
514 os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
516 arg_num = len(sys.argv)
517 script_name = sys.argv[0]
519 # May be overridden in user's shell
520 VERBOSE = os.getenv("VERBOSE", "1")
523 build_all("true", "")
524 build_all("false", "")
528 if str(sys.argv[1]) == '-c':
529 build_all("true", "-c")
530 build_all("false", "-c")
532 elif str(sys.argv[1]) == "all":
533 build_all("true", "")
534 build_all("false", "")
537 elif str(sys.argv[1]) == "linux":
538 build_linux("true", "")
539 build_linux("false", "")
541 elif str(sys.argv[1]) == "linux_unsecured":
542 build_linux_unsecured("true", "")
543 build_linux_unsecured("false", "")
544 build_linux_unsecured_with_rm("true", "")
545 build_linux_unsecured_with_rm("false", "")
547 elif str(sys.argv[1]) == "linux_secured":
548 build_linux_secured("true", "")
549 build_linux_secured("false", "")
551 elif str(sys.argv[1]) == "linux_unsecured_with_ra":
552 build_linux_unsecured_with_ra("true", "")
553 build_linux_unsecured_with_ra("false", "")
555 elif str(sys.argv[1]) == "linux_secured_with_ra":
556 build_linux_secured_with_ra("true", "")
557 build_linux_secured_with_ra("false", "")
559 elif str(sys.argv[1]) == "linux_unsecured_with_rd":
560 build_linux_unsecured_with_rd("true", "")
561 build_linux_unsecured_with_rd("false", "")
563 elif str(sys.argv[1]) == "linux_secured_with_rd":
564 build_linux_secured_with_rd("true", "")
565 build_linux_secured_with_rd("false", "")
567 elif str(sys.argv[1]) == "linux_unsecured_with_mq":
568 build_linux_unsecured_with_mq("true", "")
569 build_linux_unsecured_with_mq("false", "")
571 elif str(sys.argv[1]) == "linux_unsecured_with_tcp":
572 build_linux_unsecured_with_tcp("true", "")
573 build_linux_unsecured_with_tcp("false", "")
575 elif str(sys.argv[1]) == "linux_secured_with_tcp":
576 build_linux_secured_with_tcp("false", "")
577 build_linux_secured_with_tcp("true", "")
579 elif str(sys.argv[1]) == "linux_unsecured_with_java":
580 build_linux_unsecured_with_java("false", "")
581 build_linux_unsecured_with_java("true", "")
583 elif str(sys.argv[1]) == "linux_secured_with_java":
584 build_linux_secured_with_java("false", "")
585 build_linux_secured_with_java("true", "")
587 elif str(sys.argv[1]) == "android":
588 build_android("true", "")
589 build_android("false", "")
591 elif str(sys.argv[1]) == "android_x86":
592 build_android_x86("true", "")
593 build_android_x86("false", "")
594 build_android_x86_with_rm("true", "")
595 build_android_x86_with_rm("false", "")
597 elif str(sys.argv[1]) == "android_x86_with_ip":
598 build_android_x86_with_ip("true", "")
599 build_android_x86_with_ip("false", "")
601 elif str(sys.argv[1]) == "android_x86_with_bt":
602 build_android_x86_with_bt("true", "")
603 build_android_x86_with_bt("false", "")
605 elif str(sys.argv[1]) == "android_x86_with_ble":
606 build_android_x86_with_ble("true", "")
607 build_android_x86_with_ble("false", "")
609 elif str(sys.argv[1]) == "android_x86_with_rm_and_ip":
610 build_android_x86_with_rm_and_ip("true", "")
611 build_android_x86_with_rm_and_ip("false", "")
613 elif str(sys.argv[1]) == "android_x86_with_rm_and_bt":
614 build_android_x86_with_rm_and_bt("true", "")
615 build_android_x86_with_rm_and_bt("false", "")
617 elif str(sys.argv[1]) == "android_x86_with_rm_and_ble":
618 build_android_x86_with_rm_and_ble("true", "")
619 build_android_x86_with_rm_and_ble("false", "")
621 elif str(sys.argv[1]) == "android_armeabi":
622 build_android_armeabi("true", "")
623 build_android_armeabi("false", "")
624 build_android_armeabi_with_rm("true", "")
625 build_android_armeabi_with_rm("false", "")
627 elif str(sys.argv[1]) == "android_armeabi_with_ip":
628 build_android_armeabi_with_ip("true", "")
629 build_android_armeabi_with_ip("false", "")
631 elif str(sys.argv[1]) == "android_armeabi_with_bt":
632 build_android_armeabi_with_bt("true", "")
633 build_android_armeabi_with_bt("false", "")
635 elif str(sys.argv[1]) == "android_armeabi_with_ble":
636 build_android_armeabi_with_ble("true", "")
637 build_android_armeabi_with_ble("false", "")
639 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_ip":
640 build_android_armeabi_with_rm_and_ip("true", "")
641 build_android_armeabi_with_rm_and_ip("false", "")
643 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_bt":
644 build_android_armeabi_with_rm_and_bt("true", "")
645 build_android_armeabi_with_rm_and_bt("false", "")
647 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_ble":
648 build_android_armeabi_with_rm_and_ble("true", "")
649 build_android_armeabi_with_rm_and_ble("false", "")
651 elif str(sys.argv[1]) == "arduino":
652 build_arduino("true", "")
653 build_arduino("false", "")
655 elif str(sys.argv[1]) == "windows":
656 build_windows("true", "")
657 build_windows("false", "")
659 elif str(sys.argv[1]) == "msys":
660 build_msys("true", "")
661 build_msys("false", "")
663 elif str(sys.argv[1]) == "tizen":
664 build_tizen("true", "")
665 build_tizen("false", "")
667 elif str(sys.argv[1]) == "simulator":
668 build_simulator("true", "")
669 build_simulator("false", "")
671 elif str(sys.argv[1]) == "darwin":
672 build_darwin("true", "")
673 build_darwin("false", "")
675 elif str(sys.argv[1]) == "unit_tests":
683 print ("===================== done =====================")