Tizen build system using GBS.
[platform/upstream/iotivity.git] / build_common / SConscript
index e897cfc..6a31598 100644 (file)
@@ -46,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
@@ -82,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')
@@ -96,7 +126,7 @@ if target_os in targets_support_cc:
 
        if tc_path:
                env.PrependENVPath('PATH', tc_path)
-               sys_root = os.path.abspath(os.path.join(tc_path, '..'))
+               sys_root = os.path.abspath(tc_path + '/../')
                env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
                env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
 
@@ -115,7 +145,7 @@ env.SConscriptChdir(1)
 #   env.get('BUILD_DIR')
 
 def __set_dir(env, dir):
-       if not os.path.exists(os.path.join(dir, 'SConstruct')):
+       if not os.path.exists(dir + '/SConstruct'):
                print '''
 *************************************** Error *********************************
 * The directory(%s) seems isn't a source code directory, no SConstruct file is
@@ -124,11 +154,10 @@ def __set_dir(env, dir):
 ''' % dir
                Exit(1)
 
-        build_dir = os.path.join(dir, 'out', target_os, target_arch)
        if env.get('RELEASE'):
-               build_dir = os.path.join(build_dir, 'release')
+               build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
        else:
-               build_dir = os.path.join(build_dir, 'debug')
+               build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
        env.VariantDir(build_dir, dir, duplicate=0)
 
        env.Replace(BUILD_DIR = build_dir)
@@ -145,10 +174,8 @@ def __install(ienv, targets, name):
        Alias(name, i_n)
        env.AppendUnique(TS = [name])
 
-def __append_target(ienv, name, targets = None):
-       if targets:
-               env.Alias(name, targets)
-       env.AppendUnique(TS = [name])
+def __append_target(ienv, target):
+       env.AppendUnique(TS = [target])
 
 def __print_targets(env):
        Help('''
@@ -169,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')
 
@@ -226,33 +254,9 @@ else:
     '''
     # Load config of target os
     if target_os in ['linux', 'tizen']:
-            env.SConscript('linux/SConscript')
+               env.SConscript('linux/SConscript')
     else:
-            env.SConscript(target_os + '/SConscript')
-
-# -------------------------------------------------------------------
-# Configure the build as needed, e.g. detecting and setting
-# appropriate build flags, etc.
-#
-# This is done after the platform-specific configuration is loaded to
-# make sure we give the automated build configuration below an
-# opportunity to detect platform-specific anomalies.
-# -------------------------------------------------------------------
-import iotivityconfig
-from iotivityconfig import *
-
-conf = env.Configure(
-        custom_tests = {
-                'CheckCXX11Flags' : iotivityconfig.check_cxx11_flags
-        } )
-
-# IoTivity requires support for C++11.
-if not conf.CheckCXX11Flags():
-        print('C++11 support is required!')
-        Exit(1)
-
-env = conf.Finish()
-# -------------------------------------------------------------------
+               env.SConscript(target_os + '/SConscript')
 
 env.SConscript('external_libs.scons')
 
@@ -265,28 +269,4 @@ if env.GetOption('clean'):
                Execute(Delete(dir + '/.sconsign.dblite'))
                Execute(Delete(dir + '/.sconf_temp'))
 
-# Check if C/C++ compiler is installed
-cc = env.get('CC', '')
-cxx = env.get('CXX', '')
-
-if not cc:
-       print '''
-*************************************** Error *********************************
-*                                                                             *
-* Didn't find C compiler, please install C compiler (e.g. gcc >= 4.6).        *
-*                                                                             *
-*******************************************************************************
-'''
-       Exit(1)
-
-if not cxx:
-        print '''
-*************************************** Error *********************************
-*                                                                             *
-* Didn't find C++ compiler, please install C++ compiler (e.g. g++ >= 4.6)     *
-*                                                                             *
-*******************************************************************************
-'''
-       Exit(1)
-
 Return('env')