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