Fix for the Jira issue IOT-524
authorRavi Nanjundappa <nravi.n@samsung.com>
Wed, 24 Jun 2015 10:26:02 +0000 (15:56 +0530)
committerErich Keane <erich.keane@intel.com>
Tue, 14 Jul 2015 15:58:27 +0000 (15:58 +0000)
This patch addresses the first part of IOT-524.
Added the --prefix option to install all the build output files
in the user preferred location, if opted for.
All exe files will go into PREFIX/bin and all library files will
go into PREFIX/lib
For ex: /home/XYZ/bin and /home/XYZ/lib

Change-Id: Id1ab0fe0ca0ed0b3b86095df87f172448c366daf
Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1439
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Younghyun Joo <yh_.joo@samsung.com>
Reviewed-by: Minji Park <minjii.park@samsung.com>
Reviewed-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
24 files changed:
build_common/SConscript
extlibs/tinydtls/SConscript
resource/android/SConscript
resource/c_common/SConscript
resource/csdk/SConscript
resource/csdk/connectivity/build/SConscript
resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript
resource/csdk/connectivity/samples/android/SConscript
resource/csdk/connectivity/samples/linux/SConscript
resource/csdk/connectivity/samples/tizen/SConscript
resource/csdk/connectivity/src/SConscript
resource/csdk/security/SConscript
resource/csdk/security/provisioning/SConscript
resource/oc_logger/SConscript
resource/src/SConscript
service/notification-manager/SConscript
service/protocol-plugin/lib/cpluff/SConscript
service/protocol-plugin/plugin-manager/SConscript
service/protocol-plugin/plugin-manager/src/Android/jni/SConscript
service/protocol-plugin/plugins/mqtt-fan/lib/SConscript
service/protocol-plugin/plugins/mqtt-fan/lib/cpp/SConscript
service/soft-sensor-manager/SConscript
service/things-manager/SConscript
service/things-manager/sdk/java/jni/SConscript

index c3f43ce..544bd1a 100644 (file)
@@ -90,6 +90,14 @@ help_vars.Add(BoolVariable('UPLOAD', 'Upload binary ? (For Arduino)', require_up
 help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
 help_vars.AddVariables(('DEVICE_NAME', 'Network display name for device (For Arduino)', device_name, None, None),)
 
+AddOption('--prefix',
+                  dest='prefix',
+                  type='string',
+                  nargs=1,
+                  action='store',
+                  metavar='DIR',
+                  help='installation prefix')
+
 ######################################################################
 # Platform(build target) specific options: SDK/NDK & toolchain
 ######################################################################
@@ -107,7 +115,7 @@ if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compil
                        tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
                        )
 else:
-       env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+       env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os, PREFIX = GetOption('prefix'))
 
 Help(help_vars.GenerateHelpText(env))
 
@@ -188,6 +196,22 @@ def __install(ienv, targets, name):
        Alias(name, i_n)
        env.AppendUnique(TS = [name])
 
+def __installlib(ienv, targets, name):
+       user_prefix = env.get('PREFIX')
+       if user_prefix:
+               i_n = ienv.Install(user_prefix + '/lib', targets)
+       else:
+               i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+       ienv.Alias("install", i_n)
+
+def __installbin(ienv, targets, name):
+       user_prefix = env.get('PREFIX')
+       if user_prefix:
+               i_n = ienv.Install(user_prefix + '/bin', targets)
+       else:
+               i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+       ienv.Alias("install", i_n)
+
 def __append_target(ienv, name, targets = None):
        if targets:
                env.Alias(name, targets)
@@ -211,6 +235,8 @@ env.AddMethod(__print_targets, 'PrintTargets')
 env.AddMethod(__src_to_obj, 'SrcToObj')
 env.AddMethod(__append_target, 'AppendTarget')
 env.AddMethod(__install, 'InstallTarget')
+env.AddMethod(__installlib, 'UserInstallTargetLib')
+env.AddMethod(__installbin, 'UserInstallTargetBin')
 env.SetDir(env.GetLaunchDir())
 env['ROOT_DIR']=env.GetLaunchDir()+'/..'
 
index 846b27e..ead7ad3 100644 (file)
@@ -97,4 +97,5 @@ if not env.get('RELEASE'):
        samples_env.AppendTarget('samples')
 
 env.InstallTarget(libtinydtls, 'libtinydtls');
+env.UserInstallTargetLib(libtinydtls, 'libtinydtls');
 
index d7bce9f..4ce7309 100644 (file)
@@ -23,3 +23,4 @@ compatibilitylib_src = ['OCAndroid.cpp']
 if target_os == 'android':
        static_compatibilitylib = compatibilitylib_env.StaticLibrary('compatibility', compatibilitylib_src)
        compatibilitylib_env.InstallTarget(static_compatibilitylib, 'libcompatibility')
+       compatibilitylib_env.UserInstallTargetLib(static_compatibilitylib, 'libcompatibility')
index c2741a1..f0e140c 100644 (file)
@@ -50,3 +50,4 @@ common_src = [
 
 commonlib = common_env.StaticLibrary('c_common', common_src)
 common_env.InstallTarget(commonlib, 'c_common')
+common_env.UserInstallTargetLib(commonlib, 'c_common')
index 23635bc..14bfd03 100644 (file)
@@ -115,8 +115,10 @@ liboctbstack_src = [
 if target_os in ['arduino','darwin','ios'] :
        static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
        liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
+       liboctbstack_env.UserInstallTargetLib(static_liboctbstack, 'liboctbstack')
 else:
        static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
        shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
        liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
+       liboctbstack_env.UserInstallTargetLib([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
 
index b901f1a..8117205 100644 (file)
@@ -68,6 +68,14 @@ help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_va
 
 help_vars.AddVariables(('DEVICE_NAME', 'Network display name for device', 'OIC-DEVICE', None, None),)
 
+AddOption('--prefix',
+                  dest='prefix',
+                  type='string',
+                  nargs=1,
+                  action='store',
+                  metavar='DIR',
+                  help='installation prefix')
+
 ######################################################################
 # Platform(build target) specific options: SDK/NDK & toolchain
 ######################################################################
@@ -85,7 +93,7 @@ if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compil
                        tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
                        )
 else:
-       env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+       env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os, PREFIX = GetOption('prefix'))
 
 Help(help_vars.GenerateHelpText(env))
 
@@ -161,6 +169,22 @@ def __install(ienv, targets, name):
        Alias(name, i_n)
        env.AppendUnique(TS = [name])
 
+def __installlib(ienv, targets, name):
+       user_prefix = env.get('PREFIX')
+       if user_prefix:
+               i_n = ienv.Install(user_prefix + '/lib', targets)
+       else:
+               i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+       ienv.Alias("install", i_n)
+
+def __installbin(ienv, targets, name):
+       user_prefix = env.get('PREFIX')
+       if user_prefix:
+               i_n = ienv.Install(user_prefix + '/bin', targets)
+       else:
+               i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+       ienv.Alias("install", i_n)
+
 def __append_target(ienv, target):
        env.AppendUnique(TS = [target])
 
@@ -182,6 +206,8 @@ env.AddMethod(__print_targets, 'PrintTargets')
 env.AddMethod(__src_to_obj, 'SrcToObj')
 env.AddMethod(__append_target, 'AppendTarget')
 env.AddMethod(__install, 'InstallTarget')
+env.AddMethod(__installlib, 'UserInstallTargetLib')
+env.AddMethod(__installbin, 'UserInstallTargetBin')
 env.SetDir(env.GetLaunchDir())
 env['ROOT_DIR']=env.GetLaunchDir()+'/..'
 
index 167613c..c5f9425 100644 (file)
@@ -69,3 +69,4 @@ libcoap_src = [
 libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
 
 libcoap_env.InstallTarget([libcoap], 'libcoap')
+libcoap_env.UserInstallTargetLib([libcoap], 'libcoap')
index e3a4f18..373a3e7 100644 (file)
@@ -47,5 +47,6 @@ if secured == '1':
 \r
 libRMInterface = app_env.SharedLibrary('RMInterface', sample_src, OBJPREFIX='libRMInterface_')\r
 app_env.InstallTarget(libRMInterface, 'RMInterface')\r
+app_env.UserInstallTargetLib(libRMInterface, 'RMInterface')\r
 \r
 \r
index b859463..bd3bfe9 100755 (executable)
@@ -47,6 +47,7 @@ if secured == '1':
 else:
        casample =sample_env.Program('casample', [sample_src])
 env.InstallTarget(casample, 'casample')
+env.UserInstallTargetBin(casample, 'casample')
 
 
 
index be3619b..7013cf4 100644 (file)
@@ -56,6 +56,15 @@ help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL'
 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')))
 
+
+AddOption('--prefix',
+                  dest='prefix',
+                  type='string',
+                  nargs=1,
+                  action='store',
+                  metavar='DIR',
+                  help='installation prefix')
+
 ######################################################################
 # Platform(build target) specific options: SDK/NDK & toolchain
 ######################################################################
@@ -73,7 +82,7 @@ if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compil
                        tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
                        )
 else:
-       env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+       env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os, PREFIX = GetOption('prefix'))
 
 Help(help_vars.GenerateHelpText(env))
 
@@ -149,6 +158,22 @@ def __install(ienv, targets, name):
 def __append_target(ienv, target):
        env.AppendUnique(TS = [target])
 
+def __installlib(ienv, targets, name):
+       user_prefix = env.get('PREFIX')
+       if user_prefix:
+               i_n = ienv.Install(user_prefix + '/lib', targets)
+       else:
+               i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+       ienv.Alias("install", i_n)
+
+def __installbin(ienv, targets, name):
+       user_prefix = env.get('PREFIX')
+       if user_prefix:
+               i_n = ienv.Install(user_prefix + '/bin', targets)
+       else:
+               i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+       ienv.Alias("install", i_n)
+
 def __print_targets(env):
        Help('''
 ===============================================================================
@@ -167,6 +192,8 @@ env.AddMethod(__print_targets, 'PrintTargets')
 env.AddMethod(__src_to_obj, 'SrcToObj')
 env.AddMethod(__append_target, 'AppendTarget')
 env.AddMethod(__install, 'InstallTarget')
+env.AddMethod(__installlib, 'UserInstallTargetLib')
+env.AddMethod(__installbin, 'UserInstallTargetBin')
 env.SetDir(env.GetLaunchDir())
 env['ROOT_DIR']=env.GetLaunchDir()
 
index 9c40115..31ba920 100755 (executable)
@@ -108,4 +108,5 @@ if ca_os in ['android', 'tizen']:
 else:
        calib = env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
 env.InstallTarget(calib, 'libconnectivity_abstraction')
+env.UserInstallTargetLib(calib, 'libconnectivity_abstraction')
 
index 9d8ed6f..379aec5 100644 (file)
@@ -99,6 +99,7 @@ libocsrm_src = [
 libocsrm = libocsrm_env.StaticLibrary('libocsrm', libocsrm_src)
 
 libocsrm_env.InstallTarget(libocsrm, 'libocsrm')
+libocsrm_env.UserInstallTargetLib(libocsrm, 'libocsrm')
 
 if env.get('SECURED') == '1':
         SConscript('provisioning/SConscript')
index dea14c7..a58e868 100644 (file)
@@ -83,5 +83,6 @@ provisioning_src = [
 provisioningserver = provisioning_env.StaticLibrary('ocspapi', provisioning_src)
 
 provisioning_env.InstallTarget(provisioningserver, 'libocspapi')
+provisioning_env.UserInstallTargetLib(provisioningserver, 'libocspapi')
 
 SConscript('sample/SConscript')
index 8bd1edc..98318be 100644 (file)
@@ -50,6 +50,7 @@ liboc_logger = liboc_logger_env.SharedLibrary('oc_logger',
                ['c/oc_logger.c', 'c/oc_console_logger.c', 'cpp/oc_ostream_logger.cpp'])
 
 liboc_logger_env.InstallTarget([liboc_logger_core, liboc_logger], 'liboc_logger')
+liboc_logger_env.UserInstallTargetLib([liboc_logger_core, liboc_logger], 'liboc_logger')
 
 if target_os not in ['ios', 'android']:
        SConscript('examples/SConscript')
index fba709a..10dc8b9 100644 (file)
@@ -71,4 +71,5 @@ oclib_src = [
 oclib_env.AppendUnique(CPPPATH = [oclib_env.get('SRC_DIR') + '/extlibs/cereal/include'])
 oclib = oclib_env.SharedLibrary('oc', oclib_src)
 oclib_env.InstallTarget(oclib, 'liboc')
+oclib_env.UserInstallTargetLib(oclib, 'liboc')
 
index 94aa89e..583c3c1 100644 (file)
@@ -74,6 +74,7 @@ else :
     notificationsdk = notimgr_env.StaticLibrary('NotificationManager', notimgr_src)
 
 notimgr_env.InstallTarget(notificationsdk, 'libResouceHosting')
+notimgr_env.UserInstallTargetLib(notificationsdk, 'libResouceHosting')
 
 # Go to build sample apps
 SConscript('SampleApp/SConscript')
index 0dc1b9f..3778456 100644 (file)
@@ -35,3 +35,4 @@ cpluff_src.extend(env.Glob('kazlib/*.c'))
 
 cpluff = cpluff_env.StaticLibrary('cpluff', cpluff_src)
 cpluff_env.InstallTarget(cpluff, 'libcpluff')
+cpluff_env.UserInstallTargetLib(cpluff, 'libcpluff')
index 5457b7b..f002b78 100644 (file)
@@ -64,7 +64,8 @@ pmimpl_env.PrependUnique(LIBS = File(env.get('BUILD_DIR') + '/libcpluff.a'))
 pmimpl = pmimpl_env.SharedLibrary('pmimpl', pmimpl_src)
 
 plugin_manager_env.InstallTarget([ppm, pmimpl], 'libppm')
+plugin_manager_env.UserInstallTargetLib([ppm, pmimpl], 'libppm')
 
 # Build JNI library for android
 if env.get('TARGET_OS') == 'android':
-        SConscript('src/Android/jni/SConscript')
\ No newline at end of file
+        SConscript('src/Android/jni/SConscript')
index 55ec004..7498767 100644 (file)
@@ -31,6 +31,7 @@ ppm_jni_src = ['PluginManager.cpp']
 ppm_jni = ppm_jni_env.SharedLibrary('PluginManager', ppm_jni_src)
 
 ppm_jni_env.InstallTarget(ppm_jni, 'libPluginManager')
+ppm_jni_env.UserInstallTargetLib(ppm_jni, 'libPluginManager')
 
 ######################################################################
 # Install the libraries to /libs/<TARGET_ARCH> directory
@@ -44,6 +45,7 @@ for gnu_lib_path in gnu_lib_paths:
     gnu_lib_path = gnu_lib_path + '/libgnustl_shared.so'
     if os.path.exists(gnu_lib_path):
         ppm_jni_env.Install(ppm_sdk+'/src/Android/libs/'+env.get('TARGET_ARCH'), gnu_lib_path)
+        ppm_jni_env.Install(ppm_sdk+'/src/Android/libs/'+env.get('TARGET_ARCH'), gnu_lib_path)
         break
 
 
index fc2add8..103a29a 100644 (file)
@@ -25,5 +25,6 @@ mosquitto_src = env.Glob('*.c')
 
 mosquitto = mosquitto_env.StaticLibrary('mosquitto', mosquitto_src)
 mosquitto_env.InstallTarget(mosquitto, 'libmosquitto')
+mosquitto_env.UserInstallTargetLib(mosquitto, 'libmosquitto')
 
 SConscript('cpp/SConscript')
index 55e2333..f935f79 100644 (file)
@@ -22,3 +22,4 @@ mosquittopp_env.AppendUnique(LIBS = ['mosquitto', 'ssl', 'crypto'])
 ######################################################################
 mosquittopp = mosquittopp_env.SharedLibrary('mosquittopp', 'mosquittopp.cpp')
 mosquittopp_env.InstallTarget(mosquittopp, 'libmosquittopp')
+mosquittopp_env.UserInstallTargetLib(mosquittopp, 'libmosquittopp')
index 1a645ef..fe54d61 100644 (file)
@@ -70,6 +70,7 @@ libssmsdk = sdk_env.StaticLibrary(
                source = [ssm_sdk_cpp_src]
                )
 sdk_env.InstallTarget(libssmsdk, 'libSSMCORE')
+sdk_env.UserInstallTargetLib(libssmsdk, 'libSSMCORE')
 
 ######################################################################
 # build DiscomfortIndexSensor plugin
@@ -87,6 +88,7 @@ DiscomfortIndexSensor_src = [ Glob(DISCOMFORTINDEXSENSOR_DIR + 'src/*.cpp')]
 
 DiscomfortIndexSensor = DiscomfortIndexSensor_env.SharedLibrary('DiscomfortIndexSensor', DiscomfortIndexSensor_src)
 DiscomfortIndexSensor_env.InstallTarget(DiscomfortIndexSensor, 'libDiscomfortIndexSensor')
+DiscomfortIndexSensor_env.UserInstallTargetLib(DiscomfortIndexSensor, 'libDiscomfortIndexSensor')
 
 
 
@@ -107,6 +109,7 @@ BMISensor_src = [ Glob(BMISENSOR_DIR + 'src/*.cpp')]
 
 BMISensor = BMISensor_env.SharedLibrary('BMISensor', BMISensor_src)
 BMISensor_env.InstallTarget(BMISensor, 'libBMISensor')
+BMISensor_env.UserInstallTargetLib(BMISensor, 'libBMISensor')
 
 
 
@@ -162,6 +165,7 @@ shared_libssmcore = ssmcore_env.SharedLibrary(
                )
 
 ssmcore_env.InstallTarget([shared_libssmcore, static_libssmcore], 'libSSMCORE')
+ssmcore_env.UserInstallTargetLib([shared_libssmcore, static_libssmcore], 'libSSMCORE')
 
 #######################################################################
 ## build SampleApp
index ccd9b1c..73fd6ee 100644 (file)
@@ -52,6 +52,7 @@ tgmsdk_static = things_manager_env.StaticLibrary('TGMSDKLibrary', tgm_src)
 tgmsdk_shared = things_manager_env.SharedLibrary('TGMSDKLibrary', tgm_src)
 
 things_manager_env.InstallTarget([tgmsdk_static,tgmsdk_shared], 'libTGMSDK')
+things_manager_env.UserInstallTargetLib([tgmsdk_static,tgmsdk_shared], 'libTGMSDK')
 
 # Build JNI layer
 #if target_os == 'android':
index 5a70deb..2c1219b 100644 (file)
@@ -34,6 +34,7 @@ tm_jni_src = [tm_jni_env.Glob('tm/src/*.cpp'), tm_jni_env.Glob('jniutil/src/*.cp
 tm_jni = tm_jni_env.SharedLibrary('things-manager-jni', tm_jni_src)
 
 tm_jni_env.InstallTarget(tm_jni, 'libthings-manager-jni')
+tm_jni_env.UserInstallTargetLib(tm_jni, 'libthings-manager-jni')
 
 # Install the libraries to /libs/<TARGET_ARCH> directory
 tm_jni_env.Install(tm_sdk+'/java/libs/'+tm_jni_env.get('TARGET_ARCH'),tm_jni_env.get('BUILD_DIR')+'/liboc_logger.so')