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_simulator(flag, extra_option_str)
58 build_android(flag, extra_option_str)
59 build_arduino(flag, extra_option_str)
60 build_tizen(flag, extra_option_str)
62 if platform.system() == "Windows":
63 build_windows(flag, extra_option_str)
65 if platform.system() == "Darwin":
66 build_darwin(flag, extra_option_str)
68 def build_linux(flag, extra_option_str):
69 build_linux_unsecured(flag, extra_option_str)
70 build_linux_secured(flag, extra_option_str)
72 def build_linux_unsecured(flag, extra_option_str):
73 print ("*********** Build for linux ************")
77 call_scons(build_options, extra_option_str)
79 def build_linux_secured_with_tcp(flag, extra_option_str):
80 print ("*********** Build for linux with Secured TCP ************")
87 call_scons(build_options, extra_option_str)
89 def build_linux_unsecured_with_tcp(flag, extra_option_str):
90 print ("*********** Build for linux with TCP ************")
94 'TARGET_TRANSPORT': 'IP',
96 call_scons(build_options, extra_option_str)
98 def build_linux_unsecured_with_rm(flag, extra_option_str):
99 print ("*********** Build for linux with RoutingManager************")
104 call_scons(build_options, extra_option_str)
106 def build_linux_secured(flag, extra_option_str):
107 print ("*********** Build for linux with Security *************")
112 call_scons(build_options, extra_option_str)
114 def build_linux_unsecured_with_ra(flag, extra_option_str):
115 print ("*********** Build for linux With Remote Access *************")
121 call_scons(build_options, extra_option_str)
123 def build_linux_secured_with_ra(flag, extra_option_str):
124 print ("*********** Build for linux With Remote Access & Security ************")
131 call_scons(build_options, extra_option_str)
133 def build_linux_unsecured_with_rd(flag, extra_option_str):
134 print ("*********** Build for linux With Resource Directory *************")
139 call_scons(build_options, extra_option_str)
141 def build_linux_secured_with_rd(flag, extra_option_str):
142 print ("*********** Build for linux With Resource Directory & Security ************")
148 call_scons(build_options, extra_option_str)
150 def build_linux_unsecured_with_mq(flag, extra_option_str):
151 print ("*********** Build for linux With Message Queue ************")
154 'WITH_MQ':'PUB,SUB,BROKER',
156 call_scons(build_options, extra_option_str)
158 def build_linux_unsecured_with_tcp(flag, extra_option_str):
159 print ("*********** Build for linux With tcp ************")
164 call_scons(build_options, extra_option_str)
166 def build_android(flag, extra_option_str):
167 # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
168 # it requires gcc-4.9, currently only android-ndk-r10(for linux)
169 # and windows android-ndk-r10(64bit target version) support these features.
170 print ("*********** Build for android armeabi *************")
172 'TARGET_OS':'android',
173 'TARGET_ARCH':'armeabi',
176 call_scons(build_options, extra_option_str)
178 def build_android_x86(flag, extra_option_str):
179 """ Build Android x86 Suite """
180 build_android_x86_with_ip(flag, extra_option_str)
181 build_android_x86_with_bt(flag, extra_option_str)
182 build_android_x86_with_ble(flag, extra_option_str)
184 def build_android_x86_with_ip(flag, extra_option_str):
185 print ("*********** Build for android x86 *************")
187 'TARGET_OS':'android',
190 'TARGET_TRANSPORT':'IP',
192 call_scons(build_options, extra_option_str)
194 def build_android_x86_with_bt(flag, extra_option_str):
195 print ("*********** Build for android x86 with Bluetooth *************")
197 'TARGET_OS':'android',
200 'TARGET_TRANSPORT':'BT',
202 call_scons(build_options, extra_option_str)
204 def build_android_x86_with_ble(flag, extra_option_str):
205 print ("*********** Build for android x86 with Bluetooth Low Energy *************")
207 'TARGET_OS':'android',
210 'TARGET_TRANSPORT':'BLE',
212 call_scons(build_options, extra_option_str)
214 def build_android_x86_with_rm(flag, extra_option_str):
215 """ Build Android x86 Routing Manager Suite """
216 build_android_x86_with_rm_and_ip(flag, extra_option_str)
217 build_android_x86_with_rm_and_bt(flag, extra_option_str)
218 build_android_x86_with_rm_and_ble(flag, extra_option_str)
220 def build_android_x86_with_rm_and_ip(flag, extra_option_str):
221 print ("*********** Build for android x86 with Routing Manager *************")
223 'TARGET_OS':'android',
227 'TARGET_TRANSPORT':'IP',
229 call_scons(build_options, extra_option_str)
231 def build_android_x86_with_rm_and_bt(flag, extra_option_str):
232 print ("*********** Build for android x86 with Routing Manager and Bluetooth *************")
234 'TARGET_OS':'android',
238 'TARGET_TRANSPORT':'BT',
240 call_scons(build_options, extra_option_str)
242 def build_android_x86_with_rm_and_ble(flag, extra_option_str):
243 print ("*********** Build for android x86 with Routing Manager and Bluetooth Low Energy *************")
245 'TARGET_OS':'android',
249 'TARGET_TRANSPORT':'BLE',
251 call_scons(build_options, extra_option_str)
253 def build_android_armeabi(flag, extra_option_str):
254 """ Build Android Armeabi Suite """
255 build_android_armeabi_with_ip(flag, extra_option_str)
256 build_android_armeabi_with_bt(flag, extra_option_str)
257 build_android_armeabi_with_ble(flag, extra_option_str)
259 def build_android_armeabi_with_ip(flag, extra_option_str):
260 print ("*********** Build for android armeabi *************")
262 'TARGET_OS':'android',
263 'TARGET_ARCH':'armeabi',
265 'TARGET_TRANSPORT':'IP',
267 call_scons(build_options, extra_option_str)
269 def build_android_armeabi_with_bt(flag, extra_option_str):
270 print ("*********** Build for android armeabi with Bluetooth *************")
272 'TARGET_OS':'android',
273 'TARGET_ARCH':'armeabi',
275 'TARGET_TRANSPORT':'BT',
277 call_scons(build_options, extra_option_str)
279 def build_android_armeabi_with_ble(flag, extra_option_str):
280 print ("*********** Build for android armeabi with Bluetooth Low Energy *************")
282 'TARGET_OS':'android',
283 'TARGET_ARCH':'armeabi',
285 'TARGET_TRANSPORT':'BLE',
287 call_scons(build_options, extra_option_str)
289 def build_android_armeabi_with_rm(flag, extra_option_str):
290 """ Build Android Armeabi Routing Manager Suite """
291 build_android_armeabi_with_rm_and_ip(flag, extra_option_str)
292 build_android_armeabi_with_rm_and_bt(flag, extra_option_str)
293 build_android_armeabi_with_rm_and_ble(flag, extra_option_str)
295 def build_android_armeabi_with_rm_and_ip(flag, extra_option_str):
296 print ("*********** Build for android armeabi with Routing Manager *************")
298 'TARGET_OS':'android',
299 'TARGET_ARCH':'armeabi',
302 'TARGET_TRANSPORT':'IP',
304 call_scons(build_options, extra_option_str)
306 def build_android_armeabi_with_rm_and_bt(flag, extra_option_str):
307 print ("*********** Build for android armeabi with Routing Manager and Bluetooth *************")
309 'TARGET_OS':'android',
310 'TARGET_ARCH':'armeabi',
313 'TARGET_TRANSPORT':'BT',
315 call_scons(build_options, extra_option_str)
317 def build_android_armeabi_with_rm_and_ble(flag, extra_option_str):
318 print ("*********** Build for android armeabi with Routing Manager and Bluetooth Low Energy *************")
320 'TARGET_OS':'android',
321 'TARGET_ARCH':'armeabi',
324 'TARGET_TRANSPORT':'BLE',
326 call_scons(build_options, extra_option_str)
328 def build_arduino(flag, extra_option_str):
329 print ("*********** Build for arduino avr *************")
330 extra_option_str = "resource " + extra_option_str
332 'TARGET_OS':'arduino',
336 'TARGET_TRANSPORT':'IP',
340 call_scons(build_options, extra_option_str)
342 build_options['SHIELD'] = 'WIFI'
343 call_scons(build_options, extra_option_str)
345 build_options['TARGET_TRANSPORT'] = 'BLE'
346 build_options['SHIELD'] = 'RBL_NRF8001'
347 call_scons(build_options, extra_option_str)
349 print ("*********** Build for arduino arm *************")
350 build_options['BOARD'] = 'arduino_due_x'
351 build_options['TARGET_ARCH'] = 'arm'
352 build_options['TARGET_TRANSPORT'] = 'IP'
353 build_options['SHIELD'] = 'ETH'
354 call_scons(build_options, extra_option_str)
356 build_options['SHIELD'] = 'WIFI'
357 call_scons(build_options, extra_option_str)
359 # BLE support for the Arduino Due is currently unavailable.
361 def build_tizen(flag, extra_option_str):
362 print ("*********** Build for Tizen *************")
363 cmd_line = "/bin/sh " + os.getcwd() + "/gbsbuild.sh"
364 print ("Running : " + cmd_line)
365 subprocess.Popen([cmd_line], shell=True).wait()
367 print ("*********** Build for Tizen octbstack lib and sample *************")
368 extra_option_str = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
371 'TARGET_TRANSPORT':'IP',
375 call_scons(build_options, extra_option_str)
377 print ("*********** Build for Tizen octbstack lib and sample with Security*************")
378 build_options['SECURED'] = 1
379 call_scons(build_options, extra_option_str)
381 print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
382 del build_options['SECURED']
383 build_options['ROUTING'] = 'GW'
384 call_scons(build_options, extra_option_str)
387 def build_darwin(flag, extra_option_str):
388 print ("*********** Build for OSX *************")
390 'TARGET_OS':'darwin',
391 'SYS_VERSION':'10.9',
394 call_scons(build_options, extra_option_str)
396 print ("*********** Build for IOS i386 *************")
399 'TARGET_ARCH':'i386',
403 call_scons(build_options, extra_option_str)
405 print ("*********** Build for IOS x86_64 *************")
406 build_options['TARGET_ARCH'] = 'x86_64'
407 call_scons(build_options, extra_option_str)
409 print ("*********** Build for IOS armv7 *************")
410 build_options['TARGET_ARCH'] = 'armv7'
411 call_scons(build_options, extra_option_str)
413 print ("*********** Build for IOS armv7s *************")
414 build_options['TARGET_ARCH'] = 'armv7s'
415 call_scons(build_options, extra_option_str)
417 print ("*********** Build for IOS arm64 *************")
418 build_options['TARGET_ARCH'] = 'arm64'
419 call_scons(build_options, extra_option_str)
422 def build_windows(flag, extra_option_str):
423 print ("*********** Build for Windows *************")
424 os.environ["SCONSFLAGS"] = ""
426 'TARGET_OS':'windows',
427 'TARGET_ARCH':'amd64',
430 'TARGET_TRANSPORT':'IP',
438 call_scons(build_options, extra_option_str)
441 def build_msys(flag, extra_option_str):
442 print ("*********** Build for msys_nt *************")
443 os.environ["SCONSFLAGS"] = ""
445 'TARGET_OS':'msys_nt',
446 'TARGET_ARCH':'x86_64',
449 'TARGET_TRANSPORT':'IP',
457 call_scons(build_options, extra_option_str)
459 def build_simulator(flag, extra_option_str):
460 print ("*********** Build for simulator plugin *************")
465 call_scons(build_options, extra_option_str)
468 print ("*********** Unit test Start *************")
472 extra_option_str = "resource -c"
473 call_scons(build_options, extra_option_str)
479 extra_option_str = "resource"
480 call_scons(build_options, extra_option_str)
486 extra_option_str = "resource"
487 call_scons(build_options, extra_option_str)
489 print ("*********** Unit test Stop *************")
491 # Main module starts here
492 if os.getenv("SCONSFLAGS", "") == "":
493 os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
495 arg_num = len(sys.argv)
496 script_name = sys.argv[0]
498 # May be overridden in user's shell
499 VERBOSE = os.getenv("VERBOSE", "1")
502 build_all("true", "")
503 build_all("false", "")
507 if str(sys.argv[1]) == '-c':
508 build_all("true", "-c")
509 build_all("false", "-c")
511 elif str(sys.argv[1]) == "all":
512 build_all("true", "")
513 build_all("false", "")
516 elif str(sys.argv[1]) == "linux":
517 build_linux("true", "")
518 build_linux("false", "")
520 elif str(sys.argv[1]) == "linux_unsecured":
521 build_linux_unsecured("true", "")
522 build_linux_unsecured("false", "")
523 build_linux_unsecured_with_rm("true", "")
524 build_linux_unsecured_with_rm("false", "")
526 elif str(sys.argv[1]) == "linux_secured":
527 build_linux_secured("true", "")
528 build_linux_secured("false", "")
530 elif str(sys.argv[1]) == "linux_unsecured_with_ra":
531 build_linux_unsecured_with_ra("true", "")
532 build_linux_unsecured_with_ra("false", "")
534 elif str(sys.argv[1]) == "linux_secured_with_ra":
535 build_linux_secured_with_ra("true", "")
536 build_linux_secured_with_ra("false", "")
538 elif str(sys.argv[1]) == "linux_unsecured_with_rd":
539 build_linux_unsecured_with_rd("true", "")
540 build_linux_unsecured_with_rd("false", "")
542 elif str(sys.argv[1]) == "linux_secured_with_rd":
543 build_linux_secured_with_rd("true", "")
544 build_linux_secured_with_rd("false", "")
546 elif str(sys.argv[1]) == "linux_unsecured_with_mq":
547 build_linux_unsecured_with_mq("true", "")
548 build_linux_unsecured_with_mq("false", "")
550 elif str(sys.argv[1]) == "linux_unsecured_with_tcp":
551 build_linux_unsecured_with_tcp("true", "")
552 build_linux_unsecured_with_tcp("false", "")
554 elif str(sys.argv[1]) == "linux_secured_with_tcp":
555 build_linux_secured_with_tcp("false", "")
556 build_linux_secured_with_tcp("true", "")
558 elif str(sys.argv[1]) == "android":
559 build_android("true", "")
560 build_android("false", "")
562 elif str(sys.argv[1]) == "android_x86":
563 build_android_x86("true", "")
564 build_android_x86("false", "")
565 build_android_x86_with_rm("true", "")
566 build_android_x86_with_rm("false", "")
568 elif str(sys.argv[1]) == "android_x86_with_ip":
569 build_android_x86_with_ip("true", "")
570 build_android_x86_with_ip("false", "")
572 elif str(sys.argv[1]) == "android_x86_with_bt":
573 build_android_x86_with_bt("true", "")
574 build_android_x86_with_bt("false", "")
576 elif str(sys.argv[1]) == "android_x86_with_ble":
577 build_android_x86_with_ble("true", "")
578 build_android_x86_with_ble("false", "")
580 elif str(sys.argv[1]) == "android_x86_with_rm_and_ip":
581 build_android_x86_with_rm_and_ip("true", "")
582 build_android_x86_with_rm_and_ip("false", "")
584 elif str(sys.argv[1]) == "android_x86_with_rm_and_bt":
585 build_android_x86_with_rm_and_bt("true", "")
586 build_android_x86_with_rm_and_bt("false", "")
588 elif str(sys.argv[1]) == "android_x86_with_rm_and_ble":
589 build_android_x86_with_rm_and_ble("true", "")
590 build_android_x86_with_rm_and_ble("false", "")
592 elif str(sys.argv[1]) == "android_armeabi":
593 build_android_armeabi("true", "")
594 build_android_armeabi("false", "")
595 build_android_armeabi_with_rm("true", "")
596 build_android_armeabi_with_rm("false", "")
598 elif str(sys.argv[1]) == "android_armeabi_with_ip":
599 build_android_armeabi_with_ip("true", "")
600 build_android_armeabi_with_ip("false", "")
602 elif str(sys.argv[1]) == "android_armeabi_with_bt":
603 build_android_armeabi_with_bt("true", "")
604 build_android_armeabi_with_bt("false", "")
606 elif str(sys.argv[1]) == "android_armeabi_with_ble":
607 build_android_armeabi_with_ble("true", "")
608 build_android_armeabi_with_ble("false", "")
610 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_ip":
611 build_android_armeabi_with_rm_and_ip("true", "")
612 build_android_armeabi_with_rm_and_ip("false", "")
614 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_bt":
615 build_android_armeabi_with_rm_and_bt("true", "")
616 build_android_armeabi_with_rm_and_bt("false", "")
618 elif str(sys.argv[1]) == "android_armeabi_with_rm_and_ble":
619 build_android_armeabi_with_rm_and_ble("true", "")
620 build_android_armeabi_with_rm_and_ble("false", "")
622 elif str(sys.argv[1]) == "arduino":
623 build_arduino("true", "")
624 build_arduino("false", "")
626 elif str(sys.argv[1]) == "windows":
627 build_windows("true", "")
628 build_windows("false", "")
630 elif str(sys.argv[1]) == "msys":
631 build_msys("true", "")
632 build_msys("false", "")
634 elif str(sys.argv[1]) == "tizen":
635 build_tizen("true", "")
636 build_tizen("false", "")
638 elif str(sys.argv[1]) == "simulator":
639 build_simulator("true", "")
640 build_simulator("false", "")
642 elif str(sys.argv[1]) == "darwin":
643 build_darwin("true", "")
644 build_darwin("false", "")
646 elif str(sys.argv[1]) == "unit_tests":
654 print ("===================== done =====================")