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 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_simulator(flag, extra_option_str)
56 build_android(flag, extra_option_str)
57 build_arduino(flag, extra_option_str)
58 build_tizen(flag, extra_option_str)
60 if platform.system() == "Windows":
61 build_windows(flag, extra_option_str)
63 if platform.system() == "Darwin":
64 build_darwin(flag, extra_option_str)
66 def build_linux(flag, extra_option_str):
67 build_linux_unsecured(flag, extra_option_str)
68 build_linux_secured(flag, extra_option_str)
70 def build_linux_unsecured(flag, extra_option_str):
71 print ("*********** Build for linux ************")
75 call_scons(build_options, extra_option_str)
77 def build_linux_unsecured_with_tcp(flag, extra_option_str):
78 print ("*********** Build for linux with TCP ************")
82 'TARGET_TRANSPORT': 'IP',
84 call_scons(build_options, extra_option_str)
86 def build_linux_unsecured_with_rm(flag, extra_option_str):
87 print ("*********** Build for linux with RoutingManager************")
92 call_scons(build_options, extra_option_str)
94 def build_linux_secured(flag, extra_option_str):
95 print ("*********** Build for linux with Security *************")
100 call_scons(build_options, extra_option_str)
102 def build_linux_unsecured_with_ra(flag, extra_option_str):
103 print ("*********** Build for linux With Remote Access *************")
109 call_scons(build_options, extra_option_str)
111 def build_linux_secured_with_ra(flag, extra_option_str):
112 print ("*********** Build for linux With Remote Access & Security ************")
119 call_scons(build_options, extra_option_str)
121 def build_linux_unsecured_with_rd(flag, extra_option_str):
122 print ("*********** Build for linux With Resource Directory *************")
127 call_scons(build_options, extra_option_str)
129 def build_linux_secured_with_rd(flag, extra_option_str):
130 print ("*********** Build for linux With Resource Directory & Security ************")
136 call_scons(build_options, extra_option_str)
138 def build_linux_unsecured_with_mq(flag, extra_option_str):
139 print ("*********** Build for linux With Message Queue ************")
142 'WITH_MQ':'PUB,SUB,BROKER',
144 call_scons(build_options, extra_option_str)
146 def build_linux_unsecured_with_tcp(flag, extra_option_str):
147 print ("*********** Build for linux With tcp ************")
152 call_scons(build_options, extra_option_str)
154 def build_android(flag, extra_option_str):
155 # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
156 # it requires gcc-4.9, currently only android-ndk-r10(for linux)
157 # and windows android-ndk-r10(64bit target version) support these features.
159 build_android_x86(flag, extra_option_str)
160 build_android_x86_with_rm(flag, extra_option_str)
161 build_android_armeabi(flag, extra_option_str)
162 build_android_armeabi_with_rm(flag, extra_option_str)
164 def build_android_x86(flag, extra_option_str):
165 print ("*********** Build for android x86 *************")
167 'TARGET_OS':'android',
170 'TARGET_TRANSPORT':'IP',
172 call_scons(build_options, extra_option_str)
174 build_options['TARGET_TRANSPORT'] = 'BT'
175 call_scons(build_options, extra_option_str)
177 build_options['TARGET_TRANSPORT'] = 'BLE'
178 call_scons(build_options, extra_option_str)
180 def build_android_x86_with_rm(flag, extra_option_str):
181 print ("*********** Build for android x86 with Routing Manager *************")
183 'TARGET_OS':'android',
187 'TARGET_TRANSPORT':'IP',
189 call_scons(build_options, extra_option_str)
191 build_options['TARGET_TRANSPORT'] = 'BT'
192 call_scons(build_options, extra_option_str)
194 build_options['TARGET_TRANSPORT'] = 'BLE'
195 call_scons(build_options, extra_option_str)
197 def build_android_armeabi(flag, extra_option_str):
198 print ("*********** Build for android armeabi *************")
200 'TARGET_OS':'android',
201 'TARGET_ARCH':'armeabi',
203 'TARGET_TRANSPORT':'IP',
205 call_scons(build_options, extra_option_str)
207 build_options['TARGET_TRANSPORT'] = 'BT'
208 call_scons(build_options, extra_option_str)
210 build_options['TARGET_TRANSPORT'] = 'BLE'
211 call_scons(build_options, extra_option_str)
213 def build_android_armeabi_with_rm(flag, extra_option_str):
214 print ("*********** Build for android armeabi with Routing Manager*************")
216 'TARGET_OS':'android',
217 'TARGET_ARCH':'armeabi',
220 'TARGET_TRANSPORT':'IP',
222 call_scons(build_options, extra_option_str)
224 build_options['TARGET_TRANSPORT'] = 'BT'
225 call_scons(build_options, extra_option_str)
227 build_options['TARGET_TRANSPORT'] = 'BLE'
228 call_scons(build_options, extra_option_str)
230 def build_arduino(flag, extra_option_str):
231 print ("*********** Build for arduino avr *************")
232 extra_option_str = "resource " + extra_option_str
234 'TARGET_OS':'arduino',
238 'TARGET_TRANSPORT':'IP',
242 call_scons(build_options, extra_option_str)
244 build_options['SHIELD'] = 'WIFI'
245 call_scons(build_options, extra_option_str)
247 build_options['TARGET_TRANSPORT'] = 'BLE'
248 build_options['SHIELD'] = 'RBL_NRF8001'
249 call_scons(build_options, extra_option_str)
251 print ("*********** Build for arduino arm *************")
252 build_options['BOARD'] = 'arduino_due_x'
253 build_options['TARGET_ARCH'] = 'arm'
254 build_options['TARGET_TRANSPORT'] = 'IP'
255 build_options['SHIELD'] = 'ETH'
256 call_scons(build_options, extra_option_str)
258 build_options['SHIELD'] = 'WIFI'
259 call_scons(build_options, extra_option_str)
261 # BLE support for the Arduino Due is currently unavailable.
263 def build_tizen(flag, extra_option_str):
264 print ("*********** Build for Tizen *************")
265 cmd_line = "/bin/sh " + os.getcwd() + "/gbsbuild.sh"
266 print ("Running : " + cmd_line)
267 subprocess.Popen([cmd_line], shell=True).wait()
269 print ("*********** Build for Tizen octbstack lib and sample *************")
270 extra_option_str = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
273 'TARGET_TRANSPORT':'IP',
277 call_scons(build_options, extra_option_str)
279 print ("*********** Build for Tizen octbstack lib and sample with Security*************")
280 build_options['SECURED'] = 1
281 call_scons(build_options, extra_option_str)
283 print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
284 del build_options['SECURED']
285 build_options['ROUTING'] = 'GW'
286 call_scons(build_options, extra_option_str)
289 def build_darwin(flag, extra_option_str):
290 print ("*********** Build for OSX *************")
292 'TARGET_OS':'darwin',
293 'SYS_VERSION':'10.9',
296 call_scons(build_options, extra_option_str)
298 print ("*********** Build for IOS i386 *************")
301 'TARGET_ARCH':'i386',
305 call_scons(build_options, extra_option_str)
307 print ("*********** Build for IOS x86_64 *************")
308 build_options['TARGET_ARCH'] = 'x86_64'
309 call_scons(build_options, extra_option_str)
311 print ("*********** Build for IOS armv7 *************")
312 build_options['TARGET_ARCH'] = 'armv7'
313 call_scons(build_options, extra_option_str)
315 print ("*********** Build for IOS armv7s *************")
316 build_options['TARGET_ARCH'] = 'armv7s'
317 call_scons(build_options, extra_option_str)
319 print ("*********** Build for IOS arm64 *************")
320 build_options['TARGET_ARCH'] = 'arm64'
321 call_scons(build_options, extra_option_str)
324 def build_windows(flag, extra_option_str):
325 print ("*********** Build for Windows *************")
326 os.environ["SCONSFLAGS"] = ""
328 'TARGET_OS':'windows',
329 'TARGET_ARCH':'amd64',
332 'TARGET_TRANSPORT':'IP',
340 call_scons(build_options, extra_option_str)
343 def build_msys(flag, extra_option_str):
344 print ("*********** Build for msys_nt *************")
345 os.environ["SCONSFLAGS"] = ""
347 'TARGET_OS':'msys_nt',
348 'TARGET_ARCH':'x86_64',
351 'TARGET_TRANSPORT':'IP',
359 call_scons(build_options, extra_option_str)
361 def build_simulator(flag, extra_option_str):
362 print ("*********** Build for simulator plugin *************")
367 call_scons(build_options, extra_option_str)
370 print ("*********** Unit test Start *************")
374 extra_option_str = "resource -c"
375 call_scons(build_options, extra_option_str)
381 extra_option_str = "resource"
382 call_scons(build_options, extra_option_str)
388 extra_option_str = "resource"
389 call_scons(build_options, extra_option_str)
391 print ("*********** Unit test Stop *************")
393 # Main module starts here
394 if os.getenv("SCONSFLAGS", "") == "":
395 os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
397 arg_num = len(sys.argv)
398 script_name = sys.argv[0]
400 # May be overridden in user's shell
401 VERBOSE = os.getenv("VERBOSE", "1")
404 build_all("true", "")
405 build_all("false", "")
409 if str(sys.argv[1]) == '-c':
410 build_all("true", "-c")
411 build_all("false", "-c")
413 elif str(sys.argv[1]) == "all":
414 build_all("true", "")
415 build_all("false", "")
418 elif str(sys.argv[1]) == "linux":
419 build_linux("true", "")
420 build_linux("false", "")
422 elif str(sys.argv[1]) == "linux_unsecured":
423 build_linux_unsecured("true", "")
424 build_linux_unsecured("false", "")
425 build_linux_unsecured_with_rm("true", "")
426 build_linux_unsecured_with_rm("false", "")
428 elif str(sys.argv[1]) == "linux_secured":
429 build_linux_secured("true", "")
430 build_linux_secured("false", "")
432 elif str(sys.argv[1]) == "linux_unsecured_with_ra":
433 build_linux_unsecured_with_ra("true", "")
434 build_linux_unsecured_with_ra("false", "")
436 elif str(sys.argv[1]) == "linux_secured_with_ra":
437 build_linux_secured_with_ra("true", "")
438 build_linux_secured_with_ra("false", "")
440 elif str(sys.argv[1]) == "linux_unsecured_with_rd":
441 build_linux_unsecured_with_rd("true", "")
442 build_linux_unsecured_with_rd("false", "")
444 elif str(sys.argv[1]) == "linux_secured_with_rd":
445 build_linux_secured_with_rd("true", "")
446 build_linux_secured_with_rd("false", "")
448 elif str(sys.argv[1]) == "linux_unsecured_with_mq":
449 build_linux_unsecured_with_mq("true", "")
450 build_linux_unsecured_with_mq("false", "")
452 elif str(sys.argv[1]) == "linux_unsecured_with_tcp":
453 build_linux_unsecured_with_tcp("true", "")
454 build_linux_unsecured_with_tcp("false", "")
456 elif str(sys.argv[1]) == "android":
457 build_android("true", "")
458 build_android("false", "")
460 elif str(sys.argv[1]) == "android_x86":
461 build_android_x86("true", "")
462 build_android_x86("false", "")
463 build_android_x86_with_rm("true", "")
464 build_android_x86_with_rm("false", "")
466 elif str(sys.argv[1]) == "android_armeabi":
467 build_android_armeabi("true", "")
468 build_android_armeabi("false", "")
469 build_android_armeabi_with_rm("true", "")
470 build_android_armeabi_with_rm("false", "")
472 elif str(sys.argv[1]) == "arduino":
473 build_arduino("true", "")
474 build_arduino("false", "")
476 elif str(sys.argv[1]) == "windows":
477 build_windows("true", "")
478 build_windows("false", "")
480 elif str(sys.argv[1]) == "msys":
481 build_msys("true", "")
482 build_msys("false", "")
484 elif str(sys.argv[1]) == "tizen":
485 build_tizen("true", "")
486 build_tizen("false", "")
488 elif str(sys.argv[1]) == "simulator":
489 build_simulator("true", "")
490 build_simulator("false", "")
492 elif str(sys.argv[1]) == "darwin":
493 build_darwin("true", "")
494 build_darwin("false", "")
496 elif str(sys.argv[1]) == "unit_tests":
504 print ("===================== done =====================")