1 # -*- mode: python; python-indent-offset: 4; indent-tabs-mode: nil -*-
3 # This script includes generic build options:
4 # release/debug, target os, target arch, cross toolchain, build environment etc
9 project_version = '1.3.0'
11 # Map of host os and allowed target os (host: allowed target os)
13 'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
14 'windows': ['windows', 'android', 'arduino'],
15 'darwin': ['darwin', 'ios', 'android', 'arduino'],
16 'msys_nt' :['msys_nt'],
19 # Map of os and allowed archs (os: allowed archs)
21 'linux': ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64', 'mips', 'mipsel', 'mips64', 'mips64el', 'i386', 'powerpc', 'sparc', 'aarch64'],
22 'tizen': ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64'],
23 'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
24 'windows': ['x86', 'amd64', 'arm'],
25 'msys_nt':['x86', 'x86_64'],
26 'darwin': ['i386', 'x86_64'],
27 'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
28 'arduino': ['avr', 'arm'],
29 'yocto': ['i586', 'i686', 'x86_64', 'arm', 'aarch64', 'powerpc', 'powerpc64', 'mips', 'mipsel'],
32 host = platform.system().lower()
34 # the host string contains version of windows. 6.3, 6.4, 10.0 which is 8.0, 8.1, and 10 respectively.
35 # Let's canonicalize the msys_nt-XX.X system name by stripping version off.
39 if host not in host_target_map:
40 print "\nError: Current system (%s) isn't supported\n" % host
43 ######################################################################
44 # Get build options (the optins from command line)
45 ######################################################################
46 target_os = ARGUMENTS.get('TARGET_OS', host).lower() # target os
48 if target_os not in host_target_map[host]:
49 print "\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])
52 if target_os == 'android':
55 default_arch = platform.machine()
56 if target_os == 'windows':
57 default_arch = default_arch.lower()
59 target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
61 # True if binary needs to be installed on board. (Might need root permissions)
62 # set to 'no', 'false' or 0 for only compilation
63 require_upload = ARGUMENTS.get('UPLOAD', False)
65 # Get the device name. This name can be used as network display name wherever possible
66 device_name = ARGUMENTS.get('DEVICE_NAME', "OIC-DEVICE")
68 default_with_upstream_libcoap = 0
70 if ARGUMENTS.get('TEST'):
71 logging_default = False
74 if ARGUMENTS.get('RELEASE', True) in ['y', 'yes', 'true', 't', '1', 'on', 'all', True]:
76 logging_default = (release_mode == False)
78 # targets that do not support the DTLS build (SECURED=1 build option)
79 targets_without_dtls_support = ['arduino'];
80 if ARGUMENTS.get('SECURED') == '1' and target_os in targets_without_dtls_support:
81 print "\nError: DTLS not supported on target os: %s MUST build with SECURED=0\n" % (target_os)
84 ######################################################################
85 # Common build options (release, target os, target arch)
86 ######################################################################
87 targets_disallow_multitransport = ['arduino']
89 help_vars = Variables()
91 help_vars.Add('PROJECT_VERSION', 'The version of IoTivity', project_version)
93 help_vars.Add(BoolVariable('VERBOSE', 'Show compilation', False))
94 help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
95 help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
98 help_vars.Add(BoolVariable('WITH_RA', 'Build with Remote Access module', False))
99 help_vars.Add(BoolVariable('WITH_TCP', 'Build with TCP adapter', False))
100 help_vars.Add(BoolVariable('WITH_PROXY', 'Build with CoAP-HTTP Proxy', False))
101 help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER']))
102 help_vars.Add(BoolVariable('WITH_CLOUD', 'Build including AccountManager class and Cloud Client sample', False))
103 help_vars.Add(ListVariable('RD_MODE', 'Resource Directory build mode', 'CLIENT', ['CLIENT', 'SERVER']))
105 help_vars.Add(BoolVariable('SIMULATOR', 'Build with simulator module', False))
107 help_vars.Add(BoolVariable('WITH_RA_IBB', 'Build with Remote Access module(workssys)', False))
110 if target_os in targets_disallow_multitransport:
111 help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'IP', ['BT', 'BLE', 'IP', 'NFC']))
113 help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'BT', 'BLE', 'IP', 'NFC']))
115 help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
116 if target_os in targets_without_dtls_support:
117 help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
119 help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '1', allowed_values=('0', '1')))
120 help_vars.Add(EnumVariable('MULTIPLE_OWNER', 'Enable multiple owner', '0', allowed_values=('0', '1')))
121 help_vars.Add(EnumVariable('EXC_PROV_SUPPORT', 'Except OCPMAPI library(libocpmapi.so)', '0', allowed_values=('0', '1')))
122 help_vars.Add(EnumVariable('TEST', 'Run unit tests', '0', allowed_values=('0', '1')))
123 help_vars.Add(BoolVariable('LOGGING', 'Enable stack logging', logging_default))
124 help_vars.Add(EnumVariable('LOG_LEVEL', 'Enable stack logging level', 'DEBUG', allowed_values=('DEBUG', 'INFO', 'ERROR', 'WARNING', 'FATAL')))
125 help_vars.Add(BoolVariable('UPLOAD', 'Upload binary ? (For Arduino)', require_upload))
126 help_vars.Add(EnumVariable('ROUTING', 'Enable routing', 'EP', allowed_values=('GW', 'EP')))
127 help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
128 help_vars.AddVariables(('DEVICE_NAME', 'Network display name for device (For Arduino)', device_name, None, None),)
129 help_vars.Add(PathVariable('ANDROID_NDK', 'Android NDK path', None, PathVariable.PathAccept))
130 help_vars.Add(PathVariable('ANDROID_HOME', 'Android SDK path', None, PathVariable.PathAccept))
131 help_vars.Add(PathVariable('ANDROID_GRADLE', 'Gradle binary file', None, PathVariable.PathIsFile))
132 help_vars.Add(EnumVariable('WITH_UPSTREAM_LIBCOAP', 'Use latest stable version of LibCoAP downloaded from github', default_with_upstream_libcoap, allowed_values=('0','1')))
133 help_vars.Add(BoolVariable('WITH_ENV', 'Use compiler options from environment', False))
134 help_vars.Add(BoolVariable('AUTOMATIC_UPDATE', 'Makes libcoap update automatically to the required versions if needed.', False))
136 if target_os == 'windows':
137 # For VS2013, MSVC_VERSION is '12.0'. For VS2015, MSVC_VERSION is '14.0'.
138 # Default value is None, meaning that SCons has to choose automatically a VS version.
139 help_vars.Add(EnumVariable('MSVC_VERSION', 'MSVC compiler version - Windows', None, allowed_values=('12.0', '14.0')))
140 help_vars.Add(EnumVariable('UWP_APP', 'Build for a Universal Windows Platform (UWP) Application', '0', allowed_values=('0', '1')))
142 help_vars.Add(BoolVariable('BUILD_JAVA', 'Build Java bindings', False))
143 help_vars.Add(PathVariable('JAVA_HOME', 'JDK directory', os.environ.get('JAVA_HOME'), PathVariable.PathAccept))
144 help_vars.Add(EnumVariable('OIC_SUPPORT_TIZEN_TRACE', 'Tizen Trace(T-trace) api availability', 'False', allowed_values=('True', 'False')))
146 AddOption('--prefix',
152 help='installation prefix')
154 ######################################################################
155 # Platform(build target) specific options: SDK/NDK & toolchain
156 ######################################################################
157 targets_support_cc = ['linux', 'arduino', 'tizen']
159 if target_os in targets_support_cc:
160 # Set cross compile toolchain
161 help_vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
162 help_vars.Add(PathVariable('TC_PATH',
163 'Toolchain path (Generally only be required for cross-compiling)',
164 os.environ.get('TC_PATH')))
166 if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compiler regardless of the host
167 env = Environment(variables = help_vars,
168 tools = ['gnulink', 'gcc', 'g++', 'ar', 'as', 'textfile']
171 env = Environment(variables = help_vars, tools = ['default', 'textfile'],
172 TARGET_ARCH = target_arch, TARGET_OS = target_os,
173 PREFIX = GetOption('prefix'),
174 LIB_INSTALL_DIR = ARGUMENTS.get('LIB_INSTALL_DIR') #for 64bit build
177 Help(help_vars.GenerateHelpText(env))
179 if env.get('WITH_ENV'):
180 env['ENV'] = os.environ
181 if 'CC' in os.environ:
182 env['CC'] = Split(os.environ['CC'])
183 print "using CC from environment: %s" % env['CC']
184 if 'CXX' in os.environ:
185 env['CXX'] = Split(os.environ['CXX'])
186 print "using CXX from environment: %s" % env['CXX']
187 if 'CFLAGS' in os.environ:
188 env['CFLAGS'] = Split(os.environ['CFLAGS'])
189 print "using CFLAGS from environment: %s" % env['CFLAGS']
190 if 'CXXFLAGS' in os.environ:
191 env['CXXFLAGS'] = Split(os.environ['CXXFLAGS'])
192 print "using CXXFLAGS from environment: %s" % env['CXXFLAGS']
193 if 'CCFLAGS' in os.environ:
194 env['CCFLAGS'] = Split(os.environ['CCFLAGS'])
195 print "using CCFLAGS from environment: %s" % env['CCFLAGS']
196 if 'CPPFLAGS' in os.environ:
197 env['CPPFLAGS'] = Split(os.environ['CPPFLAGS'])
198 print "using CPPFLAGS from environment: %s" % env['CPPFLAGS']
199 if 'LDFLAGS' in os.environ:
200 env['LINKFLAGS'] = Split(os.environ['LDFLAGS'])
201 print "using LDFLAGS/LINKFLAGS from environment: %s" % env['LINKFLAGS']
204 ************************************ Warning **********************************
205 * Environment variable TC_PREFIX/TC_PATH is set. It will change the default *
206 * toolchain, if it isn't what you expect you should unset it, otherwise it may*
207 * cause inexplicable errors. *
208 *******************************************************************************
210 if env.get('VERBOSE') == False:
211 env['CCCOMSTR'] = "Compiling $TARGET"
212 env['SHCCCOMSTR'] = "Compiling $TARGET"
213 env['CXXCOMSTR'] = "Compiling $TARGET"
214 env['SHCXXCOMSTR'] = "Compiling $TARGET"
215 env['LINKCOMSTR'] = "Linking $TARGET"
216 env['SHLINKCOMSTR'] = "Linking $TARGET"
217 env['ARCOMSTR'] = "Archiving $TARGET"
218 env['RANLIBCOMSTR'] = "Indexing Archive $TARGET"
220 if target_os in targets_support_cc:
221 prefix = env.get('TC_PREFIX')
222 tc_path = env.get('TC_PATH')
224 env.Replace(CC = prefix + env.get('CC', 'gcc'))
225 env.Replace(CXX = prefix + env.get('CXX', 'g++'))
226 env.Replace(AR = prefix + env.get('AR', 'ar'))
227 env.Replace(AS = prefix + env.get('AS', 'as'))
228 env.Replace(RANLIB = prefix + env.get('RANLIB', 'ranlib'))
231 env.PrependENVPath('PATH', tc_path)
232 sys_root = os.path.abspath(tc_path + '/../')
233 env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
234 env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
236 if prefix or tc_path:
239 # Import env variables only if reproductibility is ensured
240 if target_os in ['yocto']:
241 env['CONFIG_ENVIRONMENT_IMPORT'] = True
243 env['CONFIG_ENVIRONMENT_IMPORT'] = False
245 if env['CONFIG_ENVIRONMENT_IMPORT'] == True:
246 print "warning: importing some environment variables for OS: %s" % target_os
247 for ev in ['PATH', 'PKG_CONFIG', 'PKG_CONFIG_PATH', 'PKG_CONFIG_SYSROOT_DIR']:
248 if os.environ.get(ev) != None:
249 env['ENV'][ev] = os.environ.get(ev)
250 if os.environ['LDFLAGS'] != None:
251 env.AppendUnique(LINKFLAGS = Split(os.environ['LDFLAGS']))
253 # Ensure scons be able to change its working directory
254 env.SConscriptChdir(1)
256 # Set the source directory and build directory
257 # Source directory: 'dir'
258 # Build directory: 'dir'/out/<target_os>/<target_arch>/<release or debug>/
259 # On windows, the build directory will be:
260 # 'dir'/out/windows/<win32 or uwp>/<target_arch>/<release or debug>/
262 # You can get the directory as following:
264 # env.get('BUILD_DIR')
266 def __set_dir(env, dir):
267 if not os.path.exists(dir + '/SConstruct'):
269 *************************************** Error *********************************
270 * The directory(%s) seems isn't a source code directory, no SConstruct file is
272 *******************************************************************************
276 build_dir = dir + '/out/' + target_os + '/'
278 if target_os == 'windows':
279 if env.get('UWP_APP') == '1':
280 build_dir = build_dir + 'uwp/'
282 build_dir = build_dir + 'win32/'
284 build_dir = build_dir + target_arch
286 if env.get('RELEASE'):
287 build_dir = build_dir + '/release/'
289 build_dir = build_dir + '/debug/'
291 env.VariantDir(build_dir, dir, duplicate=0)
293 env.Replace(BUILD_DIR = build_dir)
294 env.Replace(SRC_DIR = dir)
296 def __src_to_obj(env, src, home = ''):
297 obj = env.get('BUILD_DIR') + src.replace(home, '')
298 if env.get('OBJSUFFIX'):
299 obj += env.get('OBJSUFFIX')
300 return env.Object(obj, src)
302 def __install(ienv, targets, name):
303 i_n = ienv.Install(env.get('BUILD_DIR'), targets)
305 env.AppendUnique(TS = [name])
307 def __installlib(ienv, targets, name):
308 user_prefix = env.get('PREFIX')
310 user_lib = env.get('LIB_INSTALL_DIR')
312 i_n = ienv.Install(user_lib, targets)
314 i_n = ienv.Install(user_prefix + '/lib', targets)
315 ienv.Alias("install", i_n)
317 i_n = ienv.Install(env.get('BUILD_DIR'), targets)
318 ienv.Alias("install", i_n)
320 def __installbin(ienv, targets, name):
321 user_prefix = env.get('PREFIX')
323 i_n = ienv.Install(user_prefix + '/bin', targets)
324 ienv.Alias("install", i_n)
326 def __installheader(ienv, targets, dir, name):
327 user_prefix = env.get('PREFIX')
329 i_n = ienv.Install(user_prefix + '/include/' + dir ,targets)
331 i_n = ienv.Install(os.path.join(env.get('BUILD_DIR'), 'include', dir), targets)
332 ienv.Alias("install", i_n)
334 def __installpcfile(ienv, targets, name):
335 user_prefix = env.get('PREFIX')
337 user_lib = env.get('LIB_INSTALL_DIR')
339 i_n = ienv.Install(user_lib + '/pkgconfig', targets)
341 i_n = ienv.Install(user_prefix + '/lib/pkgconfig', targets)
343 i_n = ienv.Install(env.get('BUILD_DIR') + 'lib/pkgconfig', targets)
344 ienv.Alias("install", i_n)
346 def __append_target(ienv, name, targets = None):
348 env.Alias(name, targets)
349 env.AppendUnique(TS = [name])
351 def __print_targets(env):
353 ===============================================================================
355 for t in env.get('TS'):
358 \nDefault all targets will be built. You can specify the target to build:
360 $ scons [options] [target]
361 ===============================================================================
364 env.AddMethod(__set_dir, 'SetDir')
365 env.AddMethod(__print_targets, 'PrintTargets')
366 env.AddMethod(__src_to_obj, 'SrcToObj')
367 env.AddMethod(__append_target, 'AppendTarget')
368 env.AddMethod(__install, 'InstallTarget')
369 env.AddMethod(__installlib, 'UserInstallTargetLib')
370 env.AddMethod(__installbin, 'UserInstallTargetBin')
371 env.AddMethod(__installheader, 'UserInstallTargetHeader')
372 env.AddMethod(__installpcfile, 'UserInstallTargetPCFile')
373 env.SetDir(env.GetLaunchDir())
374 env['ROOT_DIR']=env.GetLaunchDir()+'/..'
378 ######################################################################
379 # Scons to generate the iotivity.pc file from iotivity.pc.in file
380 ######################################################################
381 pc_file = env.get('SRC_DIR') + '/iotivity.pc.in'
383 user_prefix = env.get('PREFIX')
384 user_lib = env.get('LIB_INSTALL_DIR')
387 user_prefix = env.get('BUILD_DIR').encode('string_escape')
390 user_lib = '$${prefix}/lib'
393 if env.get('LOGGING'):
394 defines.append('-DTB_LOG=1')
396 if env.get('ROUTING') == 'GW':
397 defines.append('-DROUTING_GATEWAY=1')
398 elif env.get('ROUTING') == 'EP':
399 defines.append('-DROUTING_EP=1')
402 if env.get('WITH_TCP'):
403 defines.append('-DTCP_ADAPTER=1')
404 if env.get('SECURED') == '1':
405 defines.append('-D__WITH_TLS__=1')
407 if env.get('SECURED') == '1':
408 defines.append('-D__WITH_DTLS__=1')
409 if env.get('EXC_PROV_SUPPORT') == '0':
410 libs.append('-locpmapi')
413 '\@VERSION\@': project_version,
414 '\@PREFIX\@': user_prefix,
415 '\@EXEC_PREFIX\@': user_prefix,
416 '\@LIB_INSTALL_DIR\@': user_lib,
417 '\@DEFINES\@': " ".join(defines),
418 '\@LIBS\@': " ".join(libs)
421 env.Substfile(pc_file, SUBST_DICT = pc_vars)
423 ######################################################################
424 # Setting global compiler flags
425 ######################################################################
426 target_transport = env.get('TARGET_TRANSPORT')
427 with_mq = env.get('WITH_MQ')
428 with_ra = env.get('WITH_RA')
429 with_tcp = env.get('WITH_TCP')
430 rd_mode = env.get('RD_MODE')
431 with_ra_ibb = env.get('WITH_RA_IBB')
433 env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
435 if (env.get('WITH_UPSTREAM_LIBCOAP') == '1'):
436 env.AppendUnique(CPPDEFINES = ['WITH_UPSTREAM_LIBCOAP'])
438 if (target_os not in ['arduino', 'windows']):
439 env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
441 if (target_os in ['darwin','ios']):
442 env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
444 if (env.get('SECURED') == '1'):
445 env.AppendUnique(CPPDEFINES = ['__WITH_DTLS__'])
447 if ((env.get('SECURED') == '1') and with_tcp):
448 env.AppendUnique(CPPDEFINES = ['__WITH_TLS__'])
450 if (env.get('MULTIPLE_OWNER') == '1'):
451 env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
453 if (env.get('ROUTING') == 'GW'):
454 env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
455 elif (env.get('ROUTING') == 'EP'):
456 env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
458 if (target_os == 'arduino'):
459 env.AppendUnique(CPPDEFINES = ['SINGLE_THREAD'])
460 env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO'])
461 elif (('IP' in target_transport) or ('ALL' in target_transport)):
462 env.AppendUnique(CPPDEFINES = ['WITH_BWT'])
464 if (target_os in ['linux', 'tizen', 'android'] and with_tcp):
465 env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
467 if (target_os in ['linux', 'tizen', 'android', 'arduino', 'ios']):
468 if (('BLE' in target_transport) or ('BT' in target_transport) or ('ALL' in target_transport)):
469 env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
471 if 'ALL' in target_transport:
473 env.AppendUnique(CPPDEFINES = ['RA_ADAPTER'])
475 env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER'])
476 if (target_os in ['linux', 'yocto']):
477 env.AppendUnique(CPPDEFINES = ['IP_ADAPTER', 'NO_EDR_ADAPTER', 'LE_ADAPTER'])
478 elif (target_os == 'android'):
479 env.AppendUnique(CPPDEFINES = ['IP_ADAPTER', 'EDR_ADAPTER', 'LE_ADAPTER', 'NFC_ADAPTER'])
480 elif (target_os in['darwin', 'ios', 'msys_nt', 'windows']):
481 env.AppendUnique(CPPDEFINES = ['IP_ADAPTER', 'NO_EDR_ADAPTER', 'NO_LE_ADAPTER'])
483 env.AppendUnique(CPPDEFINES = ['IP_ADAPTER', 'EDR_ADAPTER', 'LE_ADAPTER'])
485 if ('BT' in target_transport):
486 if (target_os == 'linux'):
487 print "CA Transport BT is not supported "
490 env.AppendUnique(CPPDEFINES = ['EDR_ADAPTER'])
492 env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
494 if ('BLE' in target_transport):
495 env.AppendUnique(CPPDEFINES = ['LE_ADAPTER'])
497 env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER'])
499 if ('IP' in target_transport):
500 env.AppendUnique(CPPDEFINES = ['IP_ADAPTER'])
502 env.AppendUnique(CPPDEFINES = ['NO_IP_ADAPTER'])
505 if (target_os in ['linux', 'tizen', 'android', 'arduino', 'ios', 'windows']):
506 env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER', 'WITH_TCP'])
508 print "CA Transport TCP is not supported "
511 env.AppendUnique(CPPDEFINES = ['NO_TCP_ADAPTER'])
513 if ('NFC' in target_transport):
514 if (target_os == 'android'):
515 env.AppendUnique(CPPDEFINES = ['NFC_ADAPTER'])
517 print "CA Transport NFC is not supported "
520 env.AppendUnique(CPPDEFINES = ['NO_NFC_ADAPTER'])
522 if ('SUB' in with_mq):
523 env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
525 if ('PUB' in with_mq):
526 env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
528 if ('BROKER' in with_mq):
529 env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
531 if env.get('LOGGING'):
532 env.AppendUnique(CPPDEFINES = ['TB_LOG'])
534 if env.get('WITH_CLOUD') and with_tcp:
535 env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
537 if 'CLIENT' in rd_mode:
538 env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
540 if 'SERVER' in rd_mode:
541 env.AppendUnique(CPPDEFINES = ['RD_SERVER'])
544 env.AppendUnique(CPPDEFINES = ['RA_ADAPTER_IBB'])
546 env.SConscript('external_builders.scons')
548 ######################################################################
549 # Link scons to Yocto cross-toolchain ONLY when target_os is yocto
550 ######################################################################
551 if target_os == "yocto":
553 This code injects Yocto cross-compilation tools+flags into scons'
554 build environment in order to invoke the relevant tools while
559 CC = os.environ['CC']
560 target_prefix = CC.split()[0]
561 target_prefix = target_prefix[:len(target_prefix)-3]
562 tools = {"CC" : target_prefix+"gcc",
563 "CXX" : target_prefix+"g++",
564 "AS" : target_prefix+"as",
565 "LD" : target_prefix+"ld",
566 "GDB" : target_prefix+"gdb",
567 "STRIP" : target_prefix+"strip",
568 "RANLIB" : target_prefix+"ranlib",
569 "OBJCOPY" : target_prefix+"objcopy",
570 "OBJDUMP" : target_prefix+"objdump",
571 "AR" : target_prefix+"ar",
572 "NM" : target_prefix+"nm",
574 "STRINGS": target_prefix+"strings"}
575 PATH = os.environ['PATH'].split(os.pathsep)
577 if tool in os.environ:
579 if os.path.isfile(os.path.join(path, tools[tool])):
580 env[tool] = os.path.join(path, os.environ[tool])
582 env['CROSS_COMPILE'] = target_prefix[:len(target_prefix) - 1]
584 print "ERROR in Yocto cross-toolchain environment"
587 Now reset TARGET_OS to linux so that all linux specific build configurations
588 hereupon apply for the entirety of the build process.
590 env['TARGET_OS'] = 'linux'
592 We want to preserve debug symbols to allow BitBake to generate both DEBUG and
593 RELEASE packages for OIC.
595 env.AppendUnique(CCFLAGS = ['-g'])
597 Additional flags to pass to the Yocto toolchain.
599 if env.get('RELEASE'):
600 env.AppendUnique(CPPDEFINES = ['NDEBUG'])
601 env.AppendUnique(CPPDEFINES = ['__linux__', '_GNU_SOURCE'])
602 env.AppendUnique(CFLAGS = ['-std=gnu99'])
603 env.AppendUnique(CCFLAGS = ['-Wall', '-Wextra', '-fPIC'])
604 env.AppendUnique(LIBS = ['dl', 'pthread', 'uuid'])
608 If target_os is not Yocto, continue with the regular build process
610 # Load config of target os
611 env.SConscript(target_os + '/SConscript')
613 # Delete the temp files of configuration
614 if env.GetOption('clean'):
615 dir = env.get('SRC_DIR')
617 if os.path.exists(dir + '/config.log'):
618 Execute(Delete(dir + '/config.log'))
619 if os.path.exists(dir + '/.sconsign.dblite'):
620 Execute(Delete(dir + '/.sconsign.dblite'))
621 if os.path.exists(dir + '/.sconf_temp'):
622 Execute(Delete(dir + '/.sconf_temp'))
624 ######################################################################
625 # Check for PThreads support
626 ######################################################################
627 import iotivityconfig
628 from iotivityconfig import *
630 conf = Configure(env,
633 'CheckPThreadsSupport' : iotivityconfig.check_pthreads
636 # Identify whether we have pthreads support, which is necessary for
637 # threading and mutexes. This will set the environment variable
638 # POSIX_SUPPORTED, 1 if it is supported, 0 otherwise
639 conf.CheckPThreadsSupport()
642 ######################################################################
644 # must call external_builders.scons second time to properly setup
645 # UnpackAll builder this is due to the system path not being pulled
646 # in for windows till after the windows target has run.
647 env.SConscript('external_builders.scons')
648 env.SConscript('external_libs.scons')