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>
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
######################################################################
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))
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)
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()+'/..'
samples_env.AppendTarget('samples')
env.InstallTarget(libtinydtls, 'libtinydtls');
+env.UserInstallTargetLib(libtinydtls, 'libtinydtls');
if target_os == 'android':
static_compatibilitylib = compatibilitylib_env.StaticLibrary('compatibility', compatibilitylib_src)
compatibilitylib_env.InstallTarget(static_compatibilitylib, 'libcompatibility')
+ compatibilitylib_env.UserInstallTargetLib(static_compatibilitylib, 'libcompatibility')
commonlib = common_env.StaticLibrary('c_common', common_src)
common_env.InstallTarget(commonlib, 'c_common')
+common_env.UserInstallTargetLib(commonlib, 'c_common')
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')
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
######################################################################
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))
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])
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()+'/..'
libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
libcoap_env.InstallTarget([libcoap], 'libcoap')
+libcoap_env.UserInstallTargetLib([libcoap], 'libcoap')
\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
else:
casample =sample_env.Program('casample', [sample_src])
env.InstallTarget(casample, 'casample')
+env.UserInstallTargetBin(casample, 'casample')
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
######################################################################
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))
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('''
===============================================================================
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()
else:
calib = env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
env.InstallTarget(calib, 'libconnectivity_abstraction')
+env.UserInstallTargetLib(calib, 'libconnectivity_abstraction')
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')
provisioningserver = provisioning_env.StaticLibrary('ocspapi', provisioning_src)
provisioning_env.InstallTarget(provisioningserver, 'libocspapi')
+provisioning_env.UserInstallTargetLib(provisioningserver, 'libocspapi')
SConscript('sample/SConscript')
['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')
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')
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')
cpluff = cpluff_env.StaticLibrary('cpluff', cpluff_src)
cpluff_env.InstallTarget(cpluff, 'libcpluff')
+cpluff_env.UserInstallTargetLib(cpluff, 'libcpluff')
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')
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
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
mosquitto = mosquitto_env.StaticLibrary('mosquitto', mosquitto_src)
mosquitto_env.InstallTarget(mosquitto, 'libmosquitto')
+mosquitto_env.UserInstallTargetLib(mosquitto, 'libmosquitto')
SConscript('cpp/SConscript')
######################################################################
mosquittopp = mosquittopp_env.SharedLibrary('mosquittopp', 'mosquittopp.cpp')
mosquittopp_env.InstallTarget(mosquittopp, 'libmosquittopp')
+mosquittopp_env.UserInstallTargetLib(mosquittopp, 'libmosquittopp')
source = [ssm_sdk_cpp_src]
)
sdk_env.InstallTarget(libssmsdk, 'libSSMCORE')
+sdk_env.UserInstallTargetLib(libssmsdk, 'libSSMCORE')
######################################################################
# build DiscomfortIndexSensor plugin
DiscomfortIndexSensor = DiscomfortIndexSensor_env.SharedLibrary('DiscomfortIndexSensor', DiscomfortIndexSensor_src)
DiscomfortIndexSensor_env.InstallTarget(DiscomfortIndexSensor, 'libDiscomfortIndexSensor')
+DiscomfortIndexSensor_env.UserInstallTargetLib(DiscomfortIndexSensor, 'libDiscomfortIndexSensor')
BMISensor = BMISensor_env.SharedLibrary('BMISensor', BMISensor_src)
BMISensor_env.InstallTarget(BMISensor, 'libBMISensor')
+BMISensor_env.UserInstallTargetLib(BMISensor, 'libBMISensor')
)
ssmcore_env.InstallTarget([shared_libssmcore, static_libssmcore], 'libSSMCORE')
+ssmcore_env.UserInstallTargetLib([shared_libssmcore, static_libssmcore], 'libSSMCORE')
#######################################################################
## build SampleApp
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':
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')