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)
39 exit_code = subprocess.Popen([cmd_line], shell=True).wait()
43 def build_all(flag, extra_option_str):
44 if platform.system() == "Linux":
45 build_linux_unsecured(flag, extra_option_str)
46 build_linux_secured(flag, extra_option_str)
47 build_linux_unsecured_with_ra(flag, extra_option_str)
48 build_linux_secured_with_ra(flag, extra_option_str)
49 build_linux_unsecured_with_rm(flag, extra_option_str)
50 build_linux_unsecured_with_rd(flag, extra_option_str)
51 build_linux_secured_with_rd(flag, extra_option_str)
52 build_linux_unsecured_with_mq(flag, extra_option_str)
53 build_linux_unsecured_with_tcp(flag, extra_option_str)
54 build_linux_secured_with_tcp(flag, extra_option_str)
55 build_simulator(flag, extra_option_str)
57 build_android(flag, extra_option_str)
58 build_arduino(flag, extra_option_str)
59 build_tizen(flag, extra_option_str)
61 if platform.system() == "Windows":
62 build_windows(flag, extra_option_str)
64 if platform.system() == "Darwin":
65 build_darwin(flag, extra_option_str)
67 def build_linux(flag, extra_option_str):
68 build_linux_unsecured(flag, extra_option_str)
69 build_linux_secured(flag, extra_option_str)
71 def build_linux_unsecured(flag, extra_option_str):
72 print ("*********** Build for linux ************")
76 call_scons(build_options, extra_option_str)
78 def build_linux_secured_with_tcp(flag, extra_option_str):
79 print ("*********** Build for linux with Secured TCP ************")
86 call_scons(build_options, extra_option_str)
88 def build_linux_unsecured_with_tcp(flag, extra_option_str):
89 print ("*********** Build for linux with TCP ************")
93 'TARGET_TRANSPORT': 'IP',
95 call_scons(build_options, extra_option_str)
97 def build_linux_unsecured_with_rm(flag, extra_option_str):
98 print ("*********** Build for linux with RoutingManager************")
103 call_scons(build_options, extra_option_str)
105 def build_linux_secured(flag, extra_option_str):
106 print ("*********** Build for linux with Security *************")
111 call_scons(build_options, extra_option_str)
113 def build_linux_unsecured_with_ra(flag, extra_option_str):
114 print ("*********** Build for linux With Remote Access *************")
120 call_scons(build_options, extra_option_str)
122 def build_linux_secured_with_ra(flag, extra_option_str):
123 print ("*********** Build for linux With Remote Access & Security ************")
130 call_scons(build_options, extra_option_str)
132 def build_linux_unsecured_with_rd(flag, extra_option_str):
133 print ("*********** Build for linux With Resource Directory *************")
138 call_scons(build_options, extra_option_str)
140 def build_linux_secured_with_rd(flag, extra_option_str):
141 print ("*********** Build for linux With Resource Directory & Security ************")
147 call_scons(build_options, extra_option_str)
149 def build_linux_unsecured_with_mq(flag, extra_option_str):
150 print ("*********** Build for linux With Message Queue ************")
153 'WITH_MQ':'PUB,SUB,BROKER',
155 call_scons(build_options, extra_option_str)
157 def build_linux_unsecured_with_tcp(flag, extra_option_str):
158 print ("*********** Build for linux With tcp ************")
163 call_scons(build_options, extra_option_str)
165 def build_android(flag, extra_option_str):
166 # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
167 # it requires gcc-4.9, currently only android-ndk-r10(for linux)
168 # and windows android-ndk-r10(64bit target version) support these features.
169 print ("*********** Build for android armeabi *************")
171 'TARGET_OS':'android',
172 'TARGET_ARCH':'armeabi',
175 call_scons(build_options, extra_option_str)
177 def build_android_x86(flag, extra_option_str):
178 print ("*********** Build for android x86 *************")
180 'TARGET_OS':'android',
183 'TARGET_TRANSPORT':'IP',
185 call_scons(build_options, extra_option_str)
187 build_options['TARGET_TRANSPORT'] = 'BT'
188 call_scons(build_options, extra_option_str)
190 build_options['TARGET_TRANSPORT'] = 'BLE'
191 call_scons(build_options, extra_option_str)
193 def build_android_x86_with_rm(flag, extra_option_str):
194 print ("*********** Build for android x86 with Routing Manager *************")
196 'TARGET_OS':'android',
200 'TARGET_TRANSPORT':'IP',
202 call_scons(build_options, extra_option_str)
204 build_options['TARGET_TRANSPORT'] = 'BT'
205 call_scons(build_options, extra_option_str)
207 build_options['TARGET_TRANSPORT'] = 'BLE'
208 call_scons(build_options, extra_option_str)
210 def build_android_armeabi(flag, extra_option_str):
211 print ("*********** Build for android armeabi *************")
213 'TARGET_OS':'android',
214 'TARGET_ARCH':'armeabi',
216 'TARGET_TRANSPORT':'IP',
218 call_scons(build_options, extra_option_str)
220 build_options['TARGET_TRANSPORT'] = 'BT'
221 call_scons(build_options, extra_option_str)
223 build_options['TARGET_TRANSPORT'] = 'BLE'
224 call_scons(build_options, extra_option_str)
226 def build_android_armeabi_with_rm(flag, extra_option_str):
227 print ("*********** Build for android armeabi with Routing Manager*************")
229 'TARGET_OS':'android',
230 'TARGET_ARCH':'armeabi',
233 'TARGET_TRANSPORT':'IP',
235 call_scons(build_options, extra_option_str)
237 build_options['TARGET_TRANSPORT'] = 'BT'
238 call_scons(build_options, extra_option_str)
240 build_options['TARGET_TRANSPORT'] = 'BLE'
241 call_scons(build_options, extra_option_str)
243 def build_arduino(flag, extra_option_str):
244 print ("*********** Build for arduino avr *************")
245 extra_option_str = "resource " + extra_option_str
247 'TARGET_OS':'arduino',
251 'TARGET_TRANSPORT':'IP',
255 call_scons(build_options, extra_option_str)
257 build_options['SHIELD'] = 'WIFI'
258 call_scons(build_options, extra_option_str)
260 build_options['TARGET_TRANSPORT'] = 'BLE'
261 build_options['SHIELD'] = 'RBL_NRF8001'
262 call_scons(build_options, extra_option_str)
264 print ("*********** Build for arduino arm *************")
265 build_options['BOARD'] = 'arduino_due_x'
266 build_options['TARGET_ARCH'] = 'arm'
267 build_options['TARGET_TRANSPORT'] = 'IP'
268 build_options['SHIELD'] = 'ETH'
269 call_scons(build_options, extra_option_str)
271 build_options['SHIELD'] = 'WIFI'
272 call_scons(build_options, extra_option_str)
274 # BLE support for the Arduino Due is currently unavailable.
276 def build_tizen(flag, extra_option_str):
277 print ("*********** Build for Tizen *************")
278 cmd_line = "/bin/sh " + os.getcwd() + "/gbsbuild.sh"
279 print ("Running : " + cmd_line)
280 subprocess.Popen([cmd_line], shell=True).wait()
282 print ("*********** Build for Tizen octbstack lib and sample *************")
283 extra_option_str = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
286 'TARGET_TRANSPORT':'IP',
290 call_scons(build_options, extra_option_str)
292 print ("*********** Build for Tizen octbstack lib and sample with Security*************")
293 build_options['SECURED'] = 1
294 call_scons(build_options, extra_option_str)
296 print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
297 del build_options['SECURED']
298 build_options['ROUTING'] = 'GW'
299 call_scons(build_options, extra_option_str)
302 def build_darwin(flag, extra_option_str):
303 print ("*********** Build for OSX *************")
305 'TARGET_OS':'darwin',
306 'SYS_VERSION':'10.9',
309 call_scons(build_options, extra_option_str)
311 print ("*********** Build for IOS i386 *************")
314 'TARGET_ARCH':'i386',
318 call_scons(build_options, extra_option_str)
320 print ("*********** Build for IOS x86_64 *************")
321 build_options['TARGET_ARCH'] = 'x86_64'
322 call_scons(build_options, extra_option_str)
324 print ("*********** Build for IOS armv7 *************")
325 build_options['TARGET_ARCH'] = 'armv7'
326 call_scons(build_options, extra_option_str)
328 print ("*********** Build for IOS armv7s *************")
329 build_options['TARGET_ARCH'] = 'armv7s'
330 call_scons(build_options, extra_option_str)
332 print ("*********** Build for IOS arm64 *************")
333 build_options['TARGET_ARCH'] = 'arm64'
334 call_scons(build_options, extra_option_str)
337 def build_windows(flag, extra_option_str):
338 print ("*********** Build for Windows *************")
339 os.environ["SCONSFLAGS"] = ""
341 'TARGET_OS':'windows',
342 'TARGET_ARCH':'amd64',
345 'TARGET_TRANSPORT':'IP',
353 call_scons(build_options, extra_option_str)
356 def build_msys(flag, extra_option_str):
357 print ("*********** Build for msys_nt *************")
358 os.environ["SCONSFLAGS"] = ""
360 'TARGET_OS':'msys_nt',
361 'TARGET_ARCH':'x86_64',
364 'TARGET_TRANSPORT':'IP',
372 call_scons(build_options, extra_option_str)
374 def build_simulator(flag, extra_option_str):
375 print ("*********** Build for simulator plugin *************")
380 call_scons(build_options, extra_option_str)
383 print ("*********** Unit test Start *************")
387 extra_option_str = "resource -c"
388 call_scons(build_options, extra_option_str)
394 extra_option_str = "resource"
395 call_scons(build_options, extra_option_str)
401 extra_option_str = "resource"
402 call_scons(build_options, extra_option_str)
404 print ("*********** Unit test Stop *************")
406 # Main module starts here
407 if os.getenv("SCONSFLAGS", "") == "":
408 os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
410 arg_num = len(sys.argv)
411 script_name = sys.argv[0]
413 # May be overridden in user's shell
414 VERBOSE = os.getenv("VERBOSE", "1")
417 build_all("true", "")
418 build_all("false", "")
422 if str(sys.argv[1]) == '-c':
423 build_all("true", "-c")
424 build_all("false", "-c")
426 elif str(sys.argv[1]) == "all":
427 build_all("true", "")
428 build_all("false", "")
431 elif str(sys.argv[1]) == "linux":
432 build_linux("true", "")
433 build_linux("false", "")
435 elif str(sys.argv[1]) == "linux_unsecured":
436 build_linux_unsecured("true", "")
437 build_linux_unsecured("false", "")
438 build_linux_unsecured_with_rm("true", "")
439 build_linux_unsecured_with_rm("false", "")
441 elif str(sys.argv[1]) == "linux_secured":
442 build_linux_secured("true", "")
443 build_linux_secured("false", "")
445 elif str(sys.argv[1]) == "linux_unsecured_with_ra":
446 build_linux_unsecured_with_ra("true", "")
447 build_linux_unsecured_with_ra("false", "")
449 elif str(sys.argv[1]) == "linux_secured_with_ra":
450 build_linux_secured_with_ra("true", "")
451 build_linux_secured_with_ra("false", "")
453 elif str(sys.argv[1]) == "linux_unsecured_with_rd":
454 build_linux_unsecured_with_rd("true", "")
455 build_linux_unsecured_with_rd("false", "")
457 elif str(sys.argv[1]) == "linux_secured_with_rd":
458 build_linux_secured_with_rd("true", "")
459 build_linux_secured_with_rd("false", "")
461 elif str(sys.argv[1]) == "linux_unsecured_with_mq":
462 build_linux_unsecured_with_mq("true", "")
463 build_linux_unsecured_with_mq("false", "")
465 elif str(sys.argv[1]) == "linux_unsecured_with_tcp":
466 build_linux_unsecured_with_tcp("true", "")
467 build_linux_unsecured_with_tcp("false", "")
469 elif str(sys.argv[1]) == "linux_secured_with_tcp":
470 build_linux_secured_with_tcp("false", "")
471 build_linux_secured_with_tcp("true", "")
473 elif str(sys.argv[1]) == "android":
474 build_android("true", "")
475 build_android("false", "")
477 elif str(sys.argv[1]) == "android_x86":
478 build_android_x86("true", "")
479 build_android_x86("false", "")
480 build_android_x86_with_rm("true", "")
481 build_android_x86_with_rm("false", "")
483 elif str(sys.argv[1]) == "android_armeabi":
484 build_android_armeabi("true", "")
485 build_android_armeabi("false", "")
486 build_android_armeabi_with_rm("true", "")
487 build_android_armeabi_with_rm("false", "")
489 elif str(sys.argv[1]) == "arduino":
490 build_arduino("true", "")
491 build_arduino("false", "")
493 elif str(sys.argv[1]) == "windows":
494 build_windows("true", "")
495 build_windows("false", "")
497 elif str(sys.argv[1]) == "msys":
498 build_msys("true", "")
499 build_msys("false", "")
501 elif str(sys.argv[1]) == "tizen":
502 build_tizen("true", "")
503 build_tizen("false", "")
505 elif str(sys.argv[1]) == "simulator":
506 build_simulator("true", "")
507 build_simulator("false", "")
509 elif str(sys.argv[1]) == "darwin":
510 build_darwin("true", "")
511 build_darwin("false", "")
513 elif str(sys.argv[1]) == "unit_tests":
521 print ("===================== done =====================")