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_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_simulator(flag, extra_option_str)
53 build_android(flag, extra_option_str)
54 build_arduino(flag, extra_option_str)
55 build_tizen(flag, extra_option_str)
57 if platform.system() == "Windows":
58 build_windows(flag, extra_option_str)
60 if platform.system() == "Darwin":
61 build_darwin(flag, extra_option_str)
63 def build_linux(flag, extra_option_str):
64 build_linux_unsecured(flag, extra_option_str)
65 build_linux_secured(flag, extra_option_str)
67 def build_linux_unsecured(flag, extra_option_str):
68 print ("*********** Build for linux ************")
72 call_scons(build_options, extra_option_str)
74 def build_linux_unsecured_with_tcp(flag, extra_option_str):
75 print ("*********** Build for linux with TCP ************")
79 'TARGET_TRANSPORT': 'IP',
81 call_scons(build_options, extra_option_str)
83 def build_linux_unsecured_with_rm(flag, extra_option_str):
84 print ("*********** Build for linux with RoutingManager************")
89 call_scons(build_options, extra_option_str)
91 def build_linux_secured(flag, extra_option_str):
92 print ("*********** Build for linux with Security *************")
97 call_scons(build_options, extra_option_str)
99 def build_linux_unsecured_with_ra(flag, extra_option_str):
100 print ("*********** Build for linux With Remote Access *************")
106 call_scons(build_options, extra_option_str)
108 def build_linux_secured_with_ra(flag, extra_option_str):
109 print ("*********** Build for linux With Remote Access & Security ************")
116 call_scons(build_options, extra_option_str)
118 def build_linux_unsecured_with_rd(flag, extra_option_str):
119 print ("*********** Build for linux With Resource Directory *************")
124 call_scons(build_options, extra_option_str)
126 def build_linux_secured_with_rd(flag, extra_option_str):
127 print ("*********** Build for linux With Resource Directory & Security ************")
133 call_scons(build_options, extra_option_str)
135 def build_linux_unsecured_with_mq(flag, extra_option_str):
136 print ("*********** Build for linux With Message Queue ************")
139 'WITH_MQ':'PUB,SUB,BROKER',
141 call_scons(build_options, extra_option_str)
143 def build_android(flag, extra_option_str):
144 # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
145 # it requires gcc-4.9, currently only android-ndk-r10(for linux)
146 # and windows android-ndk-r10(64bit target version) support these features.
148 build_android_x86(flag, extra_option_str)
149 build_android_x86_with_rm(flag, extra_option_str)
150 build_android_armeabi(flag, extra_option_str)
151 build_android_armeabi_with_rm(flag, extra_option_str)
153 def build_android_x86(flag, extra_option_str):
154 print ("*********** Build for android x86 *************")
156 'TARGET_OS':'android',
159 'TARGET_TRANSPORT':'IP',
161 call_scons(build_options, extra_option_str)
163 build_options['TARGET_TRANSPORT'] = 'BT'
164 call_scons(build_options, extra_option_str)
166 build_options['TARGET_TRANSPORT'] = 'BLE'
167 call_scons(build_options, extra_option_str)
169 def build_android_x86_with_rm(flag, extra_option_str):
170 print ("*********** Build for android x86 with Routing Manager *************")
172 'TARGET_OS':'android',
176 'TARGET_TRANSPORT':'IP',
178 call_scons(build_options, extra_option_str)
180 build_options['TARGET_TRANSPORT'] = 'BT'
181 call_scons(build_options, extra_option_str)
183 build_options['TARGET_TRANSPORT'] = 'BLE'
184 call_scons(build_options, extra_option_str)
186 def build_android_armeabi(flag, extra_option_str):
187 print ("*********** Build for android armeabi *************")
189 'TARGET_OS':'android',
190 'TARGET_ARCH':'armeabi',
192 'TARGET_TRANSPORT':'IP',
194 call_scons(build_options, extra_option_str)
196 build_options['TARGET_TRANSPORT'] = 'BT'
197 call_scons(build_options, extra_option_str)
199 build_options['TARGET_TRANSPORT'] = 'BLE'
200 call_scons(build_options, extra_option_str)
202 def build_android_armeabi_with_rm(flag, extra_option_str):
203 print ("*********** Build for android armeabi with Routing Manager*************")
205 'TARGET_OS':'android',
206 'TARGET_ARCH':'armeabi',
209 'TARGET_TRANSPORT':'IP',
211 call_scons(build_options, extra_option_str)
213 build_options['TARGET_TRANSPORT'] = 'BT'
214 call_scons(build_options, extra_option_str)
216 build_options['TARGET_TRANSPORT'] = 'BLE'
217 call_scons(build_options, extra_option_str)
219 def build_arduino(flag, extra_option_str):
220 print ("*********** Build for arduino avr *************")
221 extra_option_str = "resource " + extra_option_str
223 'TARGET_OS':'arduino',
227 'TARGET_TRANSPORT':'IP',
231 call_scons(build_options, extra_option_str)
233 build_options['SHIELD'] = 'WIFI'
234 call_scons(build_options, extra_option_str)
236 build_options['TARGET_TRANSPORT'] = 'BLE'
237 build_options['SHIELD'] = 'RBL_NRF8001'
238 call_scons(build_options, extra_option_str)
240 print ("*********** Build for arduino arm *************")
241 build_options['BOARD'] = 'arduino_due_x'
242 build_options['TARGET_ARCH'] = 'arm'
243 build_options['TARGET_TRANSPORT'] = 'IP'
244 build_options['SHIELD'] = 'ETH'
245 call_scons(build_options, extra_option_str)
247 build_options['SHIELD'] = 'WIFI'
248 call_scons(build_options, extra_option_str)
250 # BLE support for the Arduino Due is currently unavailable.
252 def build_tizen(flag, extra_option_str):
253 print ("*********** Build for Tizen *************")
254 cmd_line = "/bin/sh " + os.getcwd() + "/gbsbuild.sh"
255 print ("Running : " + cmd_line)
256 subprocess.Popen([cmd_line], shell=True).wait()
258 print ("*********** Build for Tizen octbstack lib and sample *************")
259 extra_option_str = "-f resource/csdk/stack/samples/tizen/build/SConscript " + extra_option_str
262 'TARGET_TRANSPORT':'IP',
266 call_scons(build_options, extra_option_str)
268 print ("*********** Build for Tizen octbstack lib and sample with Security*************")
269 build_options['SECURED'] = 1
270 call_scons(build_options, extra_option_str)
272 print ("*********** Build for Tizen octbstack lib and sample with Routing Manager*************")
273 del build_options['SECURED']
274 build_options['ROUTING'] = 'GW'
275 call_scons(build_options, extra_option_str)
278 def build_darwin(flag, extra_option_str):
279 print ("*********** Build for OSX *************")
281 'TARGET_OS':'darwin',
282 'SYS_VERSION':'10.9',
285 call_scons(build_options, extra_option_str)
287 print ("*********** Build for IOS i386 *************")
290 'TARGET_ARCH':'i386',
294 call_scons(build_options, extra_option_str)
296 print ("*********** Build for IOS x86_64 *************")
297 build_options['TARGET_ARCH'] = 'x86_64'
298 call_scons(build_options, extra_option_str)
300 print ("*********** Build for IOS armv7 *************")
301 build_options['TARGET_ARCH'] = 'armv7'
302 call_scons(build_options, extra_option_str)
304 print ("*********** Build for IOS armv7s *************")
305 build_options['TARGET_ARCH'] = 'armv7s'
306 call_scons(build_options, extra_option_str)
308 print ("*********** Build for IOS arm64 *************")
309 build_options['TARGET_ARCH'] = 'arm64'
310 call_scons(build_options, extra_option_str)
313 def build_windows(flag, extra_option_str):
314 print ("*********** Build for Windows *************")
315 os.environ["SCONSFLAGS"] = ""
317 'TARGET_OS':'windows',
318 'TARGET_ARCH':'amd64',
321 'TARGET_TRANSPORT':'IP',
329 call_scons(build_options, extra_option_str)
332 def build_msys(flag, extra_option_str):
333 print ("*********** Build for msys_nt *************")
334 os.environ["SCONSFLAGS"] = ""
336 'TARGET_OS':'msys_nt',
337 'TARGET_ARCH':'x86_64',
340 'TARGET_TRANSPORT':'IP',
348 call_scons(build_options, extra_option_str)
350 def build_simulator(flag, extra_option_str):
351 print ("*********** Build for simulator plugin *************")
356 call_scons(build_options, extra_option_str)
359 print ("*********** Unit test Start *************")
363 extra_option_str = "resource -c"
364 call_scons(build_options, extra_option_str)
370 extra_option_str = "resource"
371 call_scons(build_options, extra_option_str)
377 extra_option_str = "resource"
378 call_scons(build_options, extra_option_str)
380 print ("*********** Unit test Stop *************")
382 # Main module starts here
383 if os.getenv("SCONSFLAGS", "") == "":
384 os.environ["SCONSFLAGS"] = "-Q -j " + str(multiprocessing.cpu_count())
386 arg_num = len(sys.argv)
387 script_name = sys.argv[0]
389 # May be overridden in user's shell
390 VERBOSE = os.getenv("VERBOSE", "1")
393 build_all("true", "")
394 build_all("false", "")
398 if str(sys.argv[1]) == '-c':
399 build_all("true", "-c")
400 build_all("false", "-c")
402 elif str(sys.argv[1]) == "all":
403 build_all("true", "")
404 build_all("false", "")
407 elif str(sys.argv[1]) == "linux":
408 build_all("true", "")
409 build_all("false", "")
411 elif str(sys.argv[1]) == "linux_unsecured":
412 build_linux_unsecured("true", "")
413 build_linux_unsecured("false", "")
414 build_linux_unsecured_with_rm("true", "")
415 build_linux_unsecured_with_rm("false", "")
417 elif str(sys.argv[1]) == "linux_secured":
418 build_linux_secured("true", "")
419 build_linux_secured("false", "")
421 elif str(sys.argv[1]) == "linux_unsecured_with_ra":
422 build_linux_unsecured_with_ra("true", "")
423 build_linux_unsecured_with_ra("false", "")
425 elif str(sys.argv[1]) == "linux_secured_with_ra":
426 build_linux_secured_with_ra("true", "")
427 build_linux_secured_with_ra("false", "")
429 elif str(sys.argv[1]) == "linux_unsecured_with_rd":
430 build_linux_unsecured_with_rd("true", "")
431 build_linux_unsecured_with_rd("false", "")
433 elif str(sys.argv[1]) == "linux_secured_with_rd":
434 build_linux_secured_with_rd("true", "")
435 build_linux_secured_with_rd("false", "")
437 elif str(sys.argv[1]) == "linux_unsecured_with_mq":
438 build_linux_unsecured_with_mq("true", "")
439 build_linux_unsecured_with_mq("false", "")
441 elif str(sys.argv[1]) == "android":
442 build_android("true", "")
443 build_android("false", "")
445 elif str(sys.argv[1]) == "android_x86":
446 build_android_x86("true", "")
447 build_android_x86("false", "")
448 build_android_x86_with_rm("true", "")
449 build_android_x86_with_rm("false", "")
451 elif str(sys.argv[1]) == "android_armeabi":
452 build_android_armeabi("true", "")
453 build_android_armeabi("false", "")
454 build_android_armeabi_with_rm("true", "")
455 build_android_armeabi_with_rm("false", "")
457 elif str(sys.argv[1]) == "arduino":
458 build_arduino("true", "")
459 build_arduino("false", "")
461 elif str(sys.argv[1]) == "windows":
462 build_windows("true", "")
463 build_windows("false", "")
465 elif str(sys.argv[1]) == "msys":
466 build_msys("true", "")
467 build_msys("false", "")
469 elif str(sys.argv[1]) == "tizen":
470 build_tizen("true", "")
471 build_tizen("false", "")
473 elif str(sys.argv[1]) == "simulator":
474 build_simulator("true", "")
475 build_simulator("false", "")
477 elif str(sys.argv[1]) == "darwin":
478 build_darwin("true", "")
479 build_darwin("false", "")
481 elif str(sys.argv[1]) == "unit_tests":
489 print ("===================== done =====================")