X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=extlibs%2Fboost%2FSConscript;h=cae1be1a0f549c68b4ee5eb089ba3535d54ad31a;hb=3c093548382bb2542c87a67e6e5fa32552c29cb3;hp=f4c085807befe84503c9b4bc89336069d787609c;hpb=d62f032a35b05c36f9b29e3b5676e94495ba6c53;p=platform%2Fupstream%2Fiotivity.git diff --git a/extlibs/boost/SConscript b/extlibs/boost/SConscript index f4c0858..cae1be1 100644 --- a/extlibs/boost/SConscript +++ b/extlibs/boost/SConscript @@ -4,130 +4,108 @@ Import('env') boost_env = env.Clone() -modules = ['thread','program_options'] +modules = ['thread','program_options', 'system', 'date_time'] target_os = env.get('TARGET_OS') +target_arch = env.get('TARGET_ARCH') +src_dir = env.get('SRC_DIR') + +boost_version = '1.60.0' + +# TODO: Remove coupling between build scripts and 1_58_0 version for Android +if target_os in ['android']: + boost_version = '1.58.0' -boost_version = '1.57.0' boost_base_name = 'boost_'+string.replace(boost_version,'.','_') -boost_arch_name = boost_base_name+'.zip' +boost_arch_name = boost_base_name+'.tar.bz2' +boost_b2_name = boost_base_name+os.sep+'b2' boost_url = 'http://downloads.sourceforge.net/project/boost/boost/'+boost_version+'/'+boost_arch_name+'?r=&ts=1421801329&use_mirror=iweb' -host_os = sys.platform - -if host_os == 'linux2' : - boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh' - boost_b2_name = boost_base_name+os.sep+'b2' -else : - msg="Host platform (%s) is currently not supported for boost builds" % host_os - raise SCons.Errors.EnvironmentError(msg) - -# Download source code -boost_zip = boost_env.Download(boost_arch_name, boost_url) - -# Unpack source code -if not os.path.exists(boost_bootstrap): - boost_env.UnpackAll(boost_bootstrap, boost_zip) - -# Run bootstrap.sh -if not os.path.exists(boost_b2_name): - boost_env.Configure(boost_base_name, './bootstrap.sh') - -cmd = None - -# Windows... -if boost_env["PLATFORM"] in ["win32"] : - if boost_env.WhereIs("cmd") : - # TODO: Add Windows Support - cmd = None - -# read the tools on *nix systems and sets the default parameters -elif boost_env["PLATFORM"] in ["darwin", "linux", "posix"] : - if boost_env.WhereIs("sh") : - cmd = ['./b2'] - -if not cmd : - raise SCons.Errors.StopError("Boost build system not supported on this platform [%s]" % (boost_env["PLATFORM"])) - -# We need to be in the target's directory -cwd = boost_base_name - -# Gather all of the path, bin and flags -version = boost_env.get('VERSION','') -target_os = boost_env['TARGET_OS'] -target_arch = boost_env['TARGET_ARCH'] -tool_path = os.path.dirname(boost_env['CXX']) -cxx_bin = os.path.basename(boost_env['CXX']) -ar_bin = os.path.basename(boost_env['AR']) -ranlib_bin = os.path.basename(boost_env['RANLIB']) -ccflags = list(boost_env['CFLAGS']) -cxxflags = list(boost_env['CXXFLAGS']) - -try: - cxxflags.remove('-fno-rtti') -except ValueError: - pass -try: - cxxflags.remove('-fno-exceptions') -except ValueError: - pass - -# Write a user-config for this variant -user_config_name = os.path.join(cwd, 'tools', 'build', 'src', 'user-config.jam') -user_config_file = open(user_config_name, 'w') -user_config_file.write('import os ;\n') -user_config_file.write('using gcc :') -user_config_file.write(' '+version+' :') -#user_config_file.write(' :') -#user_config_file.write(' '+os.path.basename(toolchain['CXX']['BIN'])+' :\n') -user_config_file.write(' '+cxx_bin+' :\n') -user_config_file.write(' '+ar_bin+'\n') -user_config_file.write(' '+ranlib_bin+'\n') -for value in boost_env['CPPDEFINES'] : - if len(value) > 1 : - user_config_file.write(' -D'+value[0]+'='+value[1]+'\n') - else : - user_config_file.write(' -D'+value[0]+'\n') -for value in boost_env['CPPPATH'] : - user_config_file.write(' -I'+value+'\n') -for flag in ccflags : - user_config_file.write(' '+flag+'\n') -for flag in cxxflags : - user_config_file.write(' '+flag+'\n') -user_config_file.write(' ;\n') -user_config_file.close(); - -# Ensure that the toolchain is in the PATH -penv = os.environ.copy() -penv["PATH"] = tool_path + ":" + env['ENV'].get('PATH', '') + ':' + penv["PATH"] - -build_path = os.path.join('build', target_os, target_arch) - -cmd.append('-q') -cmd.append('target-os=linux') -cmd.append('link=static') -cmd.append('threading=multi') -cmd.append('--layout=system') -cmd.append('--build-type=minimal') -cmd.append('--prefix='+ build_path + os.sep + 'install_tmp') -cmd.append('--build-dir='+build_path) -for module in modules : - cmd.append('--with-'+module) -cmd.append('headers') -cmd.append('install') - -# build it now (we need the shell, because some programs need it) -devnull = open(os.devnull, "wb") -print "Building boost [%s] on the source [%s]" % (cmd, boost_b2_name) -handle = subprocess.Popen(cmd, env=penv, cwd=cwd)#, stdout=devnull ) - -if handle.wait() <> 0 : - raise SCons.Errors.BuildError( "Building boost [%s] on the source [%s]" % (cmd, boost_b2_name) ) - -# Use Copy instead of InstallXXX to make sure boost is installed immediately -Execute(Copy(os.path.join(env.get('SRC_DIR'), 'deps', target_os, 'include'), - os.path.join(boost_base_name, build_path, 'install_tmp', 'include'))) - -Execute(Copy(os.path.join(env.get('SRC_DIR'), 'deps', target_os, 'lib', target_arch), - os.path.join(boost_base_name, build_path, 'install_tmp', 'lib'))) +boost_dir = os.path.join(src_dir,'extlibs','boost','boost') +boost_bootstrap = os.path.join(boost_dir,'bootstrap.bat') + +if 'linux' == target_os : + # Check for Boost libraries in /usr/boost + print 'TODO: Perform platform check for linux' + raise SCons.Errors.EnvironmentError('Unsupported platform') + +elif target_os in ['windows']: + boost_zip_file = os.path.join(src_dir,'extlibs','boost',boost_arch_name) + + if not os.path.exists(boost_bootstrap): + + # Download if necessary + if os.path.exists(boost_zip_file): + boost_zip = boost_zip_file + else: + print '*** Downloading Boost zip file (> 100MB). Please wait... ***' + boost_zip = env.Download(boost_zip_file, boost_url) + + # Unzip boost + print '*** Unpacking boost %s zip file ... ***' % boost_version + env.UnpackAll(boost_dir, boost_zip) + + # Rename from boost_1_60_0 -> boost + os.rename(boost_base_name, 'boost') + + # Sanity check, in case the above method didn't work + if not os.path.exists(boost_bootstrap): + print ''' +*********************************** Error: **************************************** +* Please download boost from the following website: +* +* ''' + boost_url + ''' +* +* and extract the contents directly into +* +* ''' + boost_dir + ''' +* +* such that this build system can find: +* +* ''' + boost_bootstrap + ''' +* +*********************************************************************************** +''' + Exit(1) + +elif target_os in ['android']: + env.Tool('URLDownload', toolpath=['../../tools/scons']) + env.Tool('UnpackAll', toolpath=['../../tools/scons']) + env.Tool('BoostBootstrap', toolpath=['../../tools/scons']) + env.Tool('BoostBuild', toolpath=['../../tools/scons']) + + host_os = sys.platform + + if host_os == 'linux2' : + boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh' + else : + msg="Host platform (%s) is currently not supported for boost builds" % host_os + raise SCons.Errors.EnvironmentError(msg) + + if not os.path.exists(boost_arch_name) and not os.path.exists(boost_base_name): + boost_arch_name = env.URLDownload(boost_arch_name, boost_url) + + if not os.path.exists(boost_base_name): + boost_arch_name = env.UnpackAll(boost_bootstrap, boost_arch_name) + + boost_b2 = env.BoostBootstrap(boost_b2_name, boost_arch_name) + + dep_sys_root = env['DEP_SYS_ROOT'] + dep_src_dir = dep_sys_root + os.sep + 'include' + dep_lib_dir = dep_sys_root + os.sep + 'lib' + + boost_targets = [ + os.path.join(dep_src_dir, 'boost', 'config.hpp'), + os.path.join(dep_src_dir, 'boost', 'variant.hpp'), + os.path.join(dep_src_dir, 'boost', 'program_options.hpp'), + os.path.join(dep_src_dir, 'boost', 'thread.hpp'), + os.path.join(dep_src_dir, 'boost', 'date_time.hpp'), + os.path.join(dep_src_dir, 'libboost_thread.a'), + os.path.join(dep_src_dir, 'libboost_date_time.a'), + os.path.join(dep_src_dir, 'libboost_atomic.a'), + os.path.join(dep_src_dir, 'libboost_system.a'), + os.path.join(dep_src_dir, 'libboost_program_options.a') + ] + + boost_build = env.BoostBuild(boost_targets, boost_b2, PREFIX=dep_sys_root, MODULES=modules)