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 print ("*********** Build for android x86 *************")
181 'TARGET_OS':'android',
184 'TARGET_TRANSPORT':'IP',
186 call_scons(build_options, extra_option_str)
188 build_options['TARGET_TRANSPORT'] = 'BT'
189 call_scons(build_options, extra_option_str)
191 build_options['TARGET_TRANSPORT'] = 'BLE'
192 call_scons(build_options, extra_option_str)
194 def build_android_x86_with_rm(flag, extra_option_str):
195 print ("*********** Build for android x86 with Routing Manager *************")
197 'TARGET_OS':'android',
201 'TARGET_TRANSPORT':'IP',
203 call_scons(build_options, extra_option_str)
205 build_options['TARGET_TRANSPORT'] = 'BT'
206 call_scons(build_options, extra_option_str)
208 build_options['TARGET_TRANSPORT'] = 'BLE'
209 call_scons(build_options, extra_option_str)
211 def build_android_armeabi(flag, extra_option_str):
212 print ("*********** Build for android armeabi *************")
214 'TARGET_OS':'android',
215 'TARGET_ARCH':'armeabi',
217 'TARGET_TRANSPORT':'IP',
219 call_scons(build_options, extra_option_str)
221 build_options['TARGET_TRANSPORT'] = 'BT'
222 call_scons(build_options, extra_option_str)
224 build_options['TARGET_TRANSPORT'] = 'BLE'
225 call_scons(build_options, extra_option_str)
227 def build_android_armeabi_with_rm(flag, extra_option_str):
228 print ("*********** Build for android armeabi with Routing Manager*************")
230 'TARGET_OS':'android',
231 'TARGET_ARCH':'armeabi',
234 'TARGET_TRANSPORT':'IP',
236 call_scons(build_options, extra_option_str)
238 build_options['TARGET_TRANSPORT'] = 'BT'
239 call_scons(build_options, extra_option_str)
241 build_options['TARGET_TRANSPORT'] = 'BLE'
242 call_scons(build_options, extra_option_str)
244 def build_arduino(flag, extra_option_str):
245 print ("*********** Build for arduino avr *************")
246 extra_option_str = "resource " + extra_option_str
248 'TARGET_OS':'arduino',
252 'TARGET_TRANSPORT':'IP',
256 call_scons(build_options, extra_option_str)
258 build_options['SHIELD'] = 'WIFI'
259 call_scons(build_options, extra_option_str)
261 build_options['TARGET_TRANSPORT'] = 'BLE'
262 build_options['SHIELD'] = 'RBL_NRF8001'
263 call_scons(build_options, extra_option_str)
265 print ("*********** Build for arduino arm *************")
266 build_options['BOARD'] = 'arduino_due_x'
267 build_options['TARGET_ARCH'] = 'arm'
268 build_options['TARGET_TRANSPORT'] = 'IP'
269 build_options['SHIELD'] = 'ETH'
270 call_scons(build_options, extra_option_str)
272 build_options['SHIELD'] = 'WIFI'
273 call_scons(build_options, extra_option_str)
275 # BLE support for the Arduino Due is currently unavailable.
277 def build_tizen(flag, extra_option_str):
278 print ("*********** Build for Tizen *************")
279 cmd_line = "/bin/sh " + os.getcwd() + "/gbsbuild.sh"
280 print ("Running : " + cmd_line)
281 subprocess.Popen([cmd_line], shell=True).wait()
283 print ("*********** Build for Tizen octbstack lib and sample *************")
284 extra_option_str = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
287 'TARGET_TRANSPORT':'IP',
291 call_scons(build_options, extra_option_str)
293 print ("*********** Build for Tizen octbstack lib and sample with Security*************")
294 build_options['SECURED'] = 1
295 call_scons(build_options, extra_option_str)
297 print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
298 del build_options['SECURED']
299 build_options['ROUTING'] = 'GW'
300 call_scons(build_options, extra_option_str)
303 def build_darwin(flag, extra_option_str):
304 print ("*********** Build for OSX *************")
306 'TARGET_OS':'darwin',
307 'SYS_VERSION':'10.9',
310 call_scons(build_options, extra_option_str)
312 print ("*********** Build for IOS i386 *************")
315 'TARGET_ARCH':'i386',
319 call_scons(build_options, extra_option_str)
321 print ("*********** Build for IOS x86_64 *************")
322 build_options['TARGET_ARCH'] = 'x86_64'
323 call_scons(build_options, extra_option_str)
325 print ("*********** Build for IOS armv7 *************")
326 build_options['TARGET_ARCH'] = 'armv7'
327 call_scons(build_options, extra_option_str)
329 print ("*********** Build for IOS armv7s *************")
330 build_options['TARGET_ARCH'] = 'armv7s'
331 call_scons(build_options, extra_option_str)
333 print ("*********** Build for IOS arm64 *************")
334 build_options['TARGET_ARCH'] = 'arm64'
335 call_scons(build_options, extra_option_str)
338 def build_windows(flag, extra_option_str):
339 print ("*********** Build for Windows *************")
340 os.environ["SCONSFLAGS"] = ""
342 'TARGET_OS':'windows',
343 'TARGET_ARCH':'amd64',
346 'TARGET_TRANSPORT':'IP',
354 call_scons(build_options, extra_option_str)
357 def build_msys(flag, extra_option_str):
358 print ("*********** Build for msys_nt *************")
359 os.environ["SCONSFLAGS"] = ""
361 'TARGET_OS':'msys_nt',
362 'TARGET_ARCH':'x86_64',
365 'TARGET_TRANSPORT':'IP',
373 call_scons(build_options, extra_option_str)
375 def build_simulator(flag, extra_option_str):
376 print ("*********** Build for simulator plugin *************")
381 call_scons(build_options, extra_option_str)
384 print ("*********** Unit test Start *************")
388 extra_option_str = "resource -c"
389 call_scons(build_options, extra_option_str)
395 extra_option_str = "resource"
396 call_scons(build_options, extra_option_str)
402 call_scons(build_options, extra_option_str)
408 call_scons(build_options, extra_option_str)
410 print ("*********** Unit test Stop *************")
412 # Main module starts here
413 if os.getenv("SCONSFLAGS", "") == "":
414 os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
416 arg_num = len(sys.argv)
417 script_name = sys.argv[0]
419 # May be overridden in user's shell
420 VERBOSE = os.getenv("VERBOSE", "1")
423 build_all("true", "")
424 build_all("false", "")
428 if str(sys.argv[1]) == '-c':
429 build_all("true", "-c")
430 build_all("false", "-c")
432 elif str(sys.argv[1]) == "all":
433 build_all("true", "")
434 build_all("false", "")
437 elif str(sys.argv[1]) == "linux":
438 build_linux("true", "")
439 build_linux("false", "")
441 elif str(sys.argv[1]) == "linux_unsecured":
442 build_linux_unsecured("true", "")
443 build_linux_unsecured("false", "")
444 build_linux_unsecured_with_rm("true", "")
445 build_linux_unsecured_with_rm("false", "")
447 elif str(sys.argv[1]) == "linux_secured":
448 build_linux_secured("true", "")
449 build_linux_secured("false", "")
451 elif str(sys.argv[1]) == "linux_unsecured_with_ra":
452 build_linux_unsecured_with_ra("true", "")
453 build_linux_unsecured_with_ra("false", "")
455 elif str(sys.argv[1]) == "linux_secured_with_ra":
456 build_linux_secured_with_ra("true", "")
457 build_linux_secured_with_ra("false", "")
459 elif str(sys.argv[1]) == "linux_unsecured_with_rd":
460 build_linux_unsecured_with_rd("true", "")
461 build_linux_unsecured_with_rd("false", "")
463 elif str(sys.argv[1]) == "linux_secured_with_rd":
464 build_linux_secured_with_rd("true", "")
465 build_linux_secured_with_rd("false", "")
467 elif str(sys.argv[1]) == "linux_unsecured_with_mq":
468 build_linux_unsecured_with_mq("true", "")
469 build_linux_unsecured_with_mq("false", "")
471 elif str(sys.argv[1]) == "linux_unsecured_with_tcp":
472 build_linux_unsecured_with_tcp("true", "")
473 build_linux_unsecured_with_tcp("false", "")
475 elif str(sys.argv[1]) == "linux_secured_with_tcp":
476 build_linux_secured_with_tcp("false", "")
477 build_linux_secured_with_tcp("true", "")
479 elif str(sys.argv[1]) == "android":
480 build_android("true", "")
481 build_android("false", "")
483 elif str(sys.argv[1]) == "android_x86":
484 build_android_x86("true", "")
485 build_android_x86("false", "")
486 build_android_x86_with_rm("true", "")
487 build_android_x86_with_rm("false", "")
489 elif str(sys.argv[1]) == "android_armeabi":
490 build_android_armeabi("true", "")
491 build_android_armeabi("false", "")
492 build_android_armeabi_with_rm("true", "")
493 build_android_armeabi_with_rm("false", "")
495 elif str(sys.argv[1]) == "arduino":
496 build_arduino("true", "")
497 build_arduino("false", "")
499 elif str(sys.argv[1]) == "windows":
500 build_windows("true", "")
501 build_windows("false", "")
503 elif str(sys.argv[1]) == "msys":
504 build_msys("true", "")
505 build_msys("false", "")
507 elif str(sys.argv[1]) == "tizen":
508 build_tizen("true", "")
509 build_tizen("false", "")
511 elif str(sys.argv[1]) == "simulator":
512 build_simulator("true", "")
513 build_simulator("false", "")
515 elif str(sys.argv[1]) == "darwin":
516 build_darwin("true", "")
517 build_darwin("false", "")
519 elif str(sys.argv[1]) == "unit_tests":
527 print ("===================== done =====================")