3c0b9cf170e5a64d0807686687c8b7721cf7c0c3
[platform/upstream/iotivity.git] / service / resource-manipulation / src / common / primitiveResource / SConscript
1 #******************************************************************
2 #
3 # Copyright 2015 Samsung Electronics All Rights Reserved.
4 #
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 ##
22 # things_manager project build script
23 ##
24 import os
25 Import('env')
26
27 # Add third party libraries
28 lib_env = env.Clone()
29 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', exports = 'lib_env')
30
31 src_dir = lib_env.get('SRC_DIR')
32
33 gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
34
35 service_common_env = lib_env.Clone()
36 target_os = env.get('TARGET_OS')
37
38 release = env.get('RELEASE')
39
40 ######################################################################
41 # Build flags
42 ######################################################################
43 service_common_env.AppendUnique(CPPPATH = [
44     env.get('SRC_DIR')+'/extlibs',
45     '../../../include',
46     'include'])
47
48 if target_os not in ['windows', 'winrt']:
49     service_common_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
50     if target_os != 'android':
51         service_common_env.AppendUnique(CXXFLAGS = ['-pthread'])
52
53 if target_os == 'android':
54     service_common_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
55     service_common_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
56
57 service_common_env.AppendUnique(LIBS = ['dl'])
58
59 if not release:
60     service_common_env.AppendUnique(CXXFLAGS = ['--coverage'])
61     service_common_env.PrependUnique(LIBS = ['gcov'])
62
63 ######################################################################
64 # Source files and Targets
65 ######################################################################
66 service_common_src = env.Glob('src/*.cpp')
67 service_common_static = service_common_env.StaticLibrary('service_common', service_common_src)
68 service_common_shared = service_common_env.SharedLibrary('service_common', service_common_src)
69
70 service_common_env.InstallTarget([service_common_static,service_common_shared], 'service_common')
71
72 ######################################################################
73 # Build Test
74 ######################################################################
75 service_common_test_env = service_common_env.Clone();
76
77 service_common_test_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
78 service_common_test_env.PrependUnique(CPPPATH = [
79     env.get('SRC_DIR')+'/extlibs/hippomocks-master',
80     gtest_dir + '/include'
81     ])
82
83 gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
84 gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
85
86 service_common_test_env.PrependUnique(LIBS = [
87     'oc',
88     'octbstack',
89     'oc_logger',
90     'connectivity_abstraction',
91     'coap',
92     'service_common',
93     'pthread',
94     gtest,
95     gtest_main
96     ])
97
98 #service_common_test_src = env.Glob('unittests/*.cpp')
99
100 #service_common_test = service_common_test_env.Program('service_common_test', service_common_test_src)
101 #Alias("service_common_test", service_common_test)
102 #env.AppendTarget('service_common_test')