Tizen build system using GBS.
[platform/upstream/iotivity.git] / build_common / SConscript
index dd1fb3b..6a31598 100644 (file)
@@ -7,7 +7,7 @@ import platform
 
 # Map of host os and allowed target os (host: allowed target os)
 host_target_map = {
-               'linux': ['linux', 'android', 'arduino', 'yocto'],
+               'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
                'windows': ['windows', 'winrt', 'android', 'arduino'],
                'darwin': ['darwin', 'ios', 'android', 'arduino'],
                }
@@ -15,13 +15,14 @@ host_target_map = {
 # Map of os and allowed archs (os: allowed archs)
 os_arch_map = {
                'linux': ['x86', 'x86_64', 'arm', 'arm64'],
+               'tizen': ['x86', 'x86_64', 'arm', 'arm64', 'armeabi-v7a'],
                'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
                'windows': ['x86', 'amd64', 'arm'],
                'winrt': ['arm'],
                'darwin': ['i386', 'x86_64'],
                'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
                'arduino': ['avr', 'arm'],
-                'yocto': ['x86', 'x86_64'],
+               'yocto': ['x86', 'x86_64'],
                }
 
 host = platform.system().lower()
@@ -45,18 +46,42 @@ if default_arch not in os_arch_map[target_os]:
 
 target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
 
+# True if binary needs to be installed on board. (Might need root permissions)
+# set to 'no', 'false' or 0 for only compilation
+require_upload = ARGUMENTS.get('UPLOAD', False) 
+
+if ARGUMENTS.get('TEST'):
+       logging_default = False
+else:
+       logging_default = (ARGUMENTS.get('RELEASE', True) == 'false')
+
+
+
 ######################################################################
 # Common build options (release, target os, target arch)
 ######################################################################
+targets_disallow_multitransport = ['arduino']
+
 help_vars = Variables()
+help_vars.Add(BoolVariable('VERBOSE', 'Show compilation', False))
 help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
 help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
-help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
 
+if target_os in targets_disallow_multitransport:
+    help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ETHERNET', ['WIFI', 'BT', 'BLE', 'ETHERNET']))
+else:
+    help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'WIFI', 'BT', 'BLE', 'ETHERNET']))
+
+help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
+help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
+help_vars.Add(EnumVariable('TEST', 'Run unit tests', '0', allowed_values=('0', '1')))
+help_vars.Add(BoolVariable('LOGGING', 'Enable stack logging', logging_default))
+help_vars.Add(BoolVariable('UPLOAD', 'Upload binary ? (For Arduino)', require_upload))
+help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
 ######################################################################
 # Platform(build target) specific options: SDK/NDK & toolchain
 ######################################################################
-targets_support_cc = ['linux', 'arduino']
+targets_support_cc = ['linux', 'arduino', 'tizen']
 
 if target_os in targets_support_cc:
        # Set cross compile toolchain
@@ -81,6 +106,12 @@ tc_set_msg = '''
 * cause inexplicable errors.                                                  *
 *******************************************************************************
 '''
+if env.get('VERBOSE') == False:
+       env['CCCOMSTR'] = "Compiling $TARGET"
+       env['CXXCOMSTR'] = "Compiling $TARGET"
+       env['LINKCOMSTR'] = "Linking $TARGET"
+       env['ARCOMSTR'] = "Archiving $TARGET"
+       env['RANLIBCOMSTR'] = "Indexing Archive $TARGET"
 
 if target_os in targets_support_cc:
        prefix = env.get('TC_PREFIX')
@@ -165,6 +196,7 @@ env.AddMethod(__src_to_obj, 'SrcToObj')
 env.AddMethod(__append_target, 'AppendTarget')
 env.AddMethod(__install, 'InstallTarget')
 env.SetDir(env.GetLaunchDir())
+env['ROOT_DIR']=env.GetLaunchDir()+'/..'
 
 Export('env')
 
@@ -221,7 +253,12 @@ else:
     If target_os is not Yocto, continue with the regular build process
     '''
     # Load config of target os
-    env.SConscript(target_os + '/SConscript')
+    if target_os in ['linux', 'tizen']:
+               env.SConscript('linux/SConscript')
+    else:
+               env.SConscript(target_os + '/SConscript')
+
+env.SConscript('external_libs.scons')
 
 # Delete the temp files of configuration
 if env.GetOption('clean'):