Repo Merge: Moving resource API down a directory
[platform/upstream/iotivity.git] / resource / third_party_libs.scons
1 ######################################################################
2 # This script manages third party libraries
3 #
4 #Note: The paths must keep consistent with oic-utilities
5 ######################################################################
6 import os
7
8 Import('env', 'BUILD_TARGET', 'TARGET_CPU_ARCH', 'SRC_TOP_DIR')
9
10 # Add 'OIC_UTILS' build option for user to set oic-utilities project path
11 default_dir = os.path.abspath(SRC_TOP_DIR + '/../oic-utilities')
12 OIC_UTILS = ARGUMENTS.get('OIC_UTILS', default_dir)
13 if not os.path.exists(OIC_UTILS):
14         print '''
15 *********************************** Error: ************************************
16 *   oic-utilities project directory(OIC_UTILS) isn't set properly, please set *
17 * enviornment variable OIC_UTILS or set it in command line:                   *
18 *     # scons  OIC_UTILS=<path to oic-utilities> ...                          *
19 *******************************************************************************
20 '''
21         Exit(1)
22
23 if env.get('OIC_UTILS') is None:
24         vars = Variables()
25         vars.Add(PathVariable('OIC_UTILS', 'oic-utilities project path', OIC_UTILS))
26         vars.Update(env)
27         Help(vars.GenerateHelpText(env))
28         Export('OIC_UTILS')
29
30         ######################################################################
31         # Check dependent packages (Linux)
32         ######################################################################
33         if BUILD_TARGET == 'linux':
34                 # Delete the temp files of configuration
35                 if env.GetOption('clean'):
36                         if os.path.exists(SRC_TOP_DIR + 'config.log'):
37                                 Execute(Delete(SRC_TOP_DIR + 'config.log'))
38                                 Execute(Delete(SRC_TOP_DIR + '.sconsign.dblite'))
39                                 Execute(Delete(SRC_TOP_DIR + '.sconf_temp'))
40                 elif not env.GetOption('help'):
41                         conf = Configure(env)
42
43                         if not conf.CheckLib('boost_program_options'):
44                                 print 'Did not find boost_program_options, exiting!'
45                                 Exit(1)
46
47                         conf.Finish()
48
49         ######################################################################
50         # The 'include' path of third party libraries
51         ######################################################################
52
53         if BUILD_TARGET == 'android':
54                 env.AppendUnique(CPPPATH = [OIC_UTILS + '/android/boost/include'])
55
56         ######################################################################
57         # The path of third party libraries binary
58         ######################################################################
59         if BUILD_TARGET == 'android':
60                 arch = TARGET_CPU_ARCH
61                 if arch == 'armeabi-v7a-hard':
62                         arch = 'armeabi-v7a'
63
64                 if arch not in ['x86', 'armeabi', 'armeabi-v7a']:
65                         print '''
66 *********************************** Warning ***********************************
67 * current only x86, armeabi, armeabi-v7a libraries are offered!               *
68 *******************************************************************************
69 '''
70                 else:
71                         env.AppendUnique(LIBPATH = [OIC_UTILS + '/android/boost/libs/' + arch])
72
73         elif BUILD_TARGET == 'ios':
74                 env.AppendUnique(FRAMEWORKPATH = [OIC_UTILS + '/ios/frameworks/'])
75                 env.AppendUnique(FRAMEWORKS = ['boost'])
76         elif BUILD_TARGET == 'darwin':
77                 env.AppendUnique(CPPPATH = ['/usr/local/include'])
78                 env.AppendUnique(LIBPATH = ['/usr/local/lib'])