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_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 subprocess.Popen([cmd_line], shell=True).wait()
41 def build_all(flag, extra_option_str):
42 if platform.system() == "Linux":
43 build_linux_unsecured(flag, extra_option_str)
44 build_linux_secured(flag, extra_option_str)
45 build_linux_unsecured_with_ra(flag, extra_option_str)
46 build_linux_secured_with_ra(flag, extra_option_str)
47 build_linux_unsecured_with_rm(flag, extra_option_str)
48 build_linux_unsecured_with_rd(flag, extra_option_str)
49 build_linux_secured_with_rd(flag, extra_option_str)
50 build_linux_unsecured_with_mq(flag, extra_option_str)
51 build_linux_unsecured_with_tcp(flag, extra_option_str)
52 build_simulator(flag, extra_option_str)
54 build_android(flag, extra_option_str)
55 build_arduino(flag, extra_option_str)
56 build_tizen(flag, extra_option_str)
58 if platform.system() == "Windows":
59 build_windows(flag, extra_option_str)
61 if platform.system() == "Darwin":
62 build_darwin(flag, extra_option_str)
64 def build_linux(flag, extra_option_str):
65 build_linux_unsecured(flag, extra_option_str)
66 build_linux_secured(flag, extra_option_str)
68 def build_linux_unsecured(flag, extra_option_str):
69 print ("*********** Build for linux ************")
73 call_scons(build_options, extra_option_str)
75 def build_linux_unsecured_with_tcp(flag, extra_option_str):
76 print ("*********** Build for linux with TCP ************")
80 'TARGET_TRANSPORT': 'IP',
82 call_scons(build_options, extra_option_str)
84 def build_linux_unsecured_with_rm(flag, extra_option_str):
85 print ("*********** Build for linux with RoutingManager************")
90 call_scons(build_options, extra_option_str)
92 def build_linux_secured(flag, extra_option_str):
93 print ("*********** Build for linux with Security *************")
98 call_scons(build_options, extra_option_str)
100 def build_linux_unsecured_with_ra(flag, extra_option_str):
101 print ("*********** Build for linux With Remote Access *************")
107 call_scons(build_options, extra_option_str)
109 def build_linux_secured_with_ra(flag, extra_option_str):
110 print ("*********** Build for linux With Remote Access & Security ************")
117 call_scons(build_options, extra_option_str)
119 def build_linux_unsecured_with_rd(flag, extra_option_str):
120 print ("*********** Build for linux With Resource Directory *************")
125 call_scons(build_options, extra_option_str)
127 def build_linux_secured_with_rd(flag, extra_option_str):
128 print ("*********** Build for linux With Resource Directory & Security ************")
134 call_scons(build_options, extra_option_str)
136 def build_linux_unsecured_with_mq(flag, extra_option_str):
137 print ("*********** Build for linux With Message Queue ************")
140 'WITH_MQ':'PUB,SUB,BROKER',
142 call_scons(build_options, extra_option_str)
144 def build_linux_unsecured_with_tcp(flag, extra_option_str):
145 print ("*********** Build for linux With tcp ************")
150 call_scons(build_options, extra_option_str)
152 def build_android(flag, extra_option_str):
153 # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
154 # it requires gcc-4.9, currently only android-ndk-r10(for linux)
155 # and windows android-ndk-r10(64bit target version) support these features.
157 build_android_x86(flag, extra_option_str)
158 build_android_x86_with_rm(flag, extra_option_str)
159 build_android_armeabi(flag, extra_option_str)
160 build_android_armeabi_with_rm(flag, extra_option_str)
162 def build_android_x86(flag, extra_option_str):
163 print ("*********** Build for android x86 *************")
165 'TARGET_OS':'android',
168 'TARGET_TRANSPORT':'IP',
170 call_scons(build_options, extra_option_str)
172 build_options['TARGET_TRANSPORT'] = 'BT'
173 call_scons(build_options, extra_option_str)
175 build_options['TARGET_TRANSPORT'] = 'BLE'
176 call_scons(build_options, extra_option_str)
178 def build_android_x86_with_rm(flag, extra_option_str):
179 print ("*********** Build for android x86 with Routing Manager *************")
181 'TARGET_OS':'android',
185 'TARGET_TRANSPORT':'IP',
187 call_scons(build_options, extra_option_str)
189 build_options['TARGET_TRANSPORT'] = 'BT'
190 call_scons(build_options, extra_option_str)
192 build_options['TARGET_TRANSPORT'] = 'BLE'
193 call_scons(build_options, extra_option_str)
195 def build_android_armeabi(flag, extra_option_str):
196 print ("*********** Build for android armeabi *************")
198 'TARGET_OS':'android',
199 'TARGET_ARCH':'armeabi',
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_with_rm(flag, extra_option_str):
212 print ("*********** Build for android armeabi with Routing Manager*************")
214 'TARGET_OS':'android',
215 'TARGET_ARCH':'armeabi',
218 'TARGET_TRANSPORT':'IP',
220 call_scons(build_options, extra_option_str)
222 build_options['TARGET_TRANSPORT'] = 'BT'
223 call_scons(build_options, extra_option_str)
225 build_options['TARGET_TRANSPORT'] = 'BLE'
226 call_scons(build_options, extra_option_str)
228 def build_arduino(flag, extra_option_str):
229 print ("*********** Build for arduino avr *************")
230 extra_option_str = "resource " + extra_option_str
232 'TARGET_OS':'arduino',
236 'TARGET_TRANSPORT':'IP',
240 call_scons(build_options, extra_option_str)
242 build_options['SHIELD'] = 'WIFI'
243 call_scons(build_options, extra_option_str)
245 build_options['TARGET_TRANSPORT'] = 'BLE'
246 build_options['SHIELD'] = 'RBL_NRF8001'
247 call_scons(build_options, extra_option_str)
249 print ("*********** Build for arduino arm *************")
250 build_options['BOARD'] = 'arduino_due_x'
251 build_options['TARGET_ARCH'] = 'arm'
252 build_options['TARGET_TRANSPORT'] = 'IP'
253 build_options['SHIELD'] = 'ETH'
254 call_scons(build_options, extra_option_str)
256 build_options['SHIELD'] = 'WIFI'
257 call_scons(build_options, extra_option_str)
259 # BLE support for the Arduino Due is currently unavailable.
261 def build_tizen(flag, extra_option_str):
262 print ("*********** Build for Tizen *************")
263 cmd_line = "/bin/sh " + os.getcwd() + "/gbsbuild.sh"
264 print ("Running : " + cmd_line)
265 subprocess.Popen([cmd_line], shell=True).wait()
267 print ("*********** Build for Tizen octbstack lib and sample *************")
268 extra_option_str = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
271 'TARGET_TRANSPORT':'IP',
275 call_scons(build_options, extra_option_str)
277 print ("*********** Build for Tizen octbstack lib and sample with Security*************")
278 build_options['SECURED'] = 1
279 call_scons(build_options, extra_option_str)
281 print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
282 del build_options['SECURED']
283 build_options['ROUTING'] = 'GW'
284 call_scons(build_options, extra_option_str)
287 def build_darwin(flag, extra_option_str):
288 print ("*********** Build for OSX *************")
290 'TARGET_OS':'darwin',
291 'SYS_VERSION':'10.9',
294 call_scons(build_options, extra_option_str)
296 print ("*********** Build for IOS i386 *************")
299 'TARGET_ARCH':'i386',
303 call_scons(build_options, extra_option_str)
305 print ("*********** Build for IOS x86_64 *************")
306 build_options['TARGET_ARCH'] = 'x86_64'
307 call_scons(build_options, extra_option_str)
309 print ("*********** Build for IOS armv7 *************")
310 build_options['TARGET_ARCH'] = 'armv7'
311 call_scons(build_options, extra_option_str)
313 print ("*********** Build for IOS armv7s *************")
314 build_options['TARGET_ARCH'] = 'armv7s'
315 call_scons(build_options, extra_option_str)
317 print ("*********** Build for IOS arm64 *************")
318 build_options['TARGET_ARCH'] = 'arm64'
319 call_scons(build_options, extra_option_str)
322 def build_windows(flag, extra_option_str):
323 print ("*********** Build for Windows *************")
324 os.environ["SCONSFLAGS"] = ""
326 'TARGET_OS':'windows',
327 'TARGET_ARCH':'amd64',
330 'TARGET_TRANSPORT':'IP',
338 call_scons(build_options, extra_option_str)
341 def build_msys(flag, extra_option_str):
342 print ("*********** Build for msys_nt *************")
343 os.environ["SCONSFLAGS"] = ""
345 'TARGET_OS':'msys_nt',
346 'TARGET_ARCH':'x86_64',
349 'TARGET_TRANSPORT':'IP',
357 call_scons(build_options, extra_option_str)
359 def build_simulator(flag, extra_option_str):
360 print ("*********** Build for simulator plugin *************")
365 call_scons(build_options, extra_option_str)
368 print ("*********** Unit test Start *************")
372 extra_option_str = "resource -c"
373 call_scons(build_options, extra_option_str)
379 extra_option_str = "resource"
380 call_scons(build_options, extra_option_str)
386 extra_option_str = "resource"
387 call_scons(build_options, extra_option_str)
389 print ("*********** Unit test Stop *************")
391 # Main module starts here
392 if os.getenv("SCONSFLAGS", "") == "":
393 os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
395 arg_num = len(sys.argv)
396 script_name = sys.argv[0]
398 # May be overridden in user's shell
399 VERBOSE = os.getenv("VERBOSE", "1")
402 build_all("true", "")
403 build_all("false", "")
407 if str(sys.argv[1]) == '-c':
408 build_all("true", "-c")
409 build_all("false", "-c")
411 elif str(sys.argv[1]) == "all":
412 build_all("true", "")
413 build_all("false", "")
416 elif str(sys.argv[1]) == "linux":
417 build_linux("true", "")
418 build_linux("false", "")
420 elif str(sys.argv[1]) == "linux_unsecured":
421 build_linux_unsecured("true", "")
422 build_linux_unsecured("false", "")
423 build_linux_unsecured_with_rm("true", "")
424 build_linux_unsecured_with_rm("false", "")
426 elif str(sys.argv[1]) == "linux_secured":
427 build_linux_secured("true", "")
428 build_linux_secured("false", "")
430 elif str(sys.argv[1]) == "linux_unsecured_with_ra":
431 build_linux_unsecured_with_ra("true", "")
432 build_linux_unsecured_with_ra("false", "")
434 elif str(sys.argv[1]) == "linux_secured_with_ra":
435 build_linux_secured_with_ra("true", "")
436 build_linux_secured_with_ra("false", "")
438 elif str(sys.argv[1]) == "linux_unsecured_with_rd":
439 build_linux_unsecured_with_rd("true", "")
440 build_linux_unsecured_with_rd("false", "")
442 elif str(sys.argv[1]) == "linux_secured_with_rd":
443 build_linux_secured_with_rd("true", "")
444 build_linux_secured_with_rd("false", "")
446 elif str(sys.argv[1]) == "linux_unsecured_with_mq":
447 build_linux_unsecured_with_mq("true", "")
448 build_linux_unsecured_with_mq("false", "")
450 elif str(sys.argv[1]) == "linux_unsecured_with_tcp":
451 build_linux_unsecured_with_tcp("true", "")
452 build_linux_unsecured_with_tcp("false", "")
454 elif str(sys.argv[1]) == "android":
455 build_android("true", "")
456 build_android("false", "")
458 elif str(sys.argv[1]) == "android_x86":
459 build_android_x86("true", "")
460 build_android_x86("false", "")
461 build_android_x86_with_rm("true", "")
462 build_android_x86_with_rm("false", "")
464 elif str(sys.argv[1]) == "android_armeabi":
465 build_android_armeabi("true", "")
466 build_android_armeabi("false", "")
467 build_android_armeabi_with_rm("true", "")
468 build_android_armeabi_with_rm("false", "")
470 elif str(sys.argv[1]) == "arduino":
471 build_arduino("true", "")
472 build_arduino("false", "")
474 elif str(sys.argv[1]) == "windows":
475 build_windows("true", "")
476 build_windows("false", "")
478 elif str(sys.argv[1]) == "msys":
479 build_msys("true", "")
480 build_msys("false", "")
482 elif str(sys.argv[1]) == "tizen":
483 build_tizen("true", "")
484 build_tizen("false", "")
486 elif str(sys.argv[1]) == "simulator":
487 build_simulator("true", "")
488 build_simulator("false", "")
490 elif str(sys.argv[1]) == "darwin":
491 build_darwin("true", "")
492 build_darwin("false", "")
494 elif str(sys.argv[1]) == "unit_tests":
502 print ("===================== done =====================")