1 import os, string, sys, subprocess
6 boost_env = env.Clone()
8 modules = ['thread','program_options', 'system', 'date_time']
10 target_os = env.get('TARGET_OS')
11 target_arch = env.get('TARGET_ARCH')
12 src_dir = env.get('SRC_DIR')
14 boost_version = '1.60.0'
16 # TODO: Remove coupling between build scripts and 1_58_0 version for Android
17 if target_os in ['android']:
18 boost_version = '1.58.0'
20 boost_base_name = 'boost_'+string.replace(boost_version,'.','_')
21 boost_arch_name = boost_base_name+'.zip'
22 boost_b2_name = boost_base_name+os.sep+'b2'
23 boost_url = 'http://downloads.sourceforge.net/project/boost/boost/'+boost_version+'/'+boost_arch_name+'?r=&ts=1421801329&use_mirror=iweb'
25 boost_dir = os.path.join(src_dir,'extlibs','boost','boost')
26 boost_bootstrap = os.path.join(boost_dir,'bootstrap.bat')
28 if 'linux' == target_os :
29 # Check for Boost libraries in /usr/boost
30 print 'TODO: Perform platform check for linux'
31 raise SCons.Errors.EnvironmentError('Unsupported platform')
33 elif target_os in ['windows']:
34 boost_zip_file = os.path.join(src_dir,'extlibs','boost',boost_arch_name)
36 if not os.path.exists(boost_bootstrap):
38 # Download if necessary
39 if os.path.exists(boost_zip_file):
40 boost_zip = boost_zip_file
42 print '*** Downloading Boost zip file (> 100MB). Please wait... ***'
43 boost_zip = boost_env.Download(boost_zip_file, boost_url)
46 print '*** Unpacking boost %s zip file ... ***' % boost_version
47 boost_env.UnpackAll(boost_dir, boost_zip)
49 # Rename from boost_1_60_0 -> boost
50 os.rename(boost_base_name, 'boost')
52 # Sanity check, in case the above method didn't work
53 if not os.path.exists(boost_bootstrap):
55 *********************************** Error: ****************************************
56 * Please download boost from the following website:
58 * ''' + boost_url + '''
60 * and extract the contents directly into
62 * ''' + boost_dir + '''
64 * such that this build system can find:
66 * ''' + boost_bootstrap + '''
68 ***********************************************************************************
72 elif target_os in ['android']:
73 boost_env.Tool('URLDownload', toolpath=['../../tools/scons'])
74 boost_env.Tool('UnpackAll', toolpath=['../../tools/scons'])
75 boost_env.Tool('BoostBootstrap', toolpath=['../../tools/scons'])
76 boost_env.Tool('BoostBuild', toolpath=['../../tools/scons'])
78 host_os = sys.platform
80 if host_os == 'linux2' :
81 boost_bootstrap = boost_base_name+os.sep+'bootstrap.sh'
83 msg="Host platform (%s) is currently not supported for boost builds" % host_os
84 raise SCons.Errors.EnvironmentError(msg)
86 if not os.path.exists(boost_arch_name) and not os.path.exists(boost_base_name):
87 boost_arch_name = boost_env.URLDownload(boost_arch_name, boost_url)
89 if not os.path.exists(boost_base_name):
90 boost_arch_name = boost_env.UnpackAll(boost_bootstrap, boost_arch_name)
92 boost_b2 = boost_env.BoostBootstrap(boost_b2_name, boost_arch_name)
94 dep_sys_root = boost_env['DEP_SYS_ROOT']
95 dep_src_dir = dep_sys_root + os.sep + 'include'
96 dep_lib_dir = dep_sys_root + os.sep + 'lib'
99 os.path.join(dep_src_dir, 'boost', 'config.hpp'),
100 os.path.join(dep_src_dir, 'boost', 'variant.hpp'),
101 os.path.join(dep_src_dir, 'boost', 'program_options.hpp'),
102 os.path.join(dep_src_dir, 'boost', 'thread.hpp'),
103 os.path.join(dep_src_dir, 'boost', 'date_time.hpp'),
104 os.path.join(dep_src_dir, 'libboost_thread.a'),
105 os.path.join(dep_src_dir, 'libboost_date_time.a'),
106 os.path.join(dep_src_dir, 'libboost_atomic.a'),
107 os.path.join(dep_src_dir, 'libboost_system.a'),
108 os.path.join(dep_src_dir, 'libboost_program_options.a')
111 boost_build = boost_env.BoostBuild(boost_targets, boost_b2, PREFIX=dep_sys_root, MODULES=modules)