Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / common / SConscript
1 #******************************************************************\r
2 #\r
3 # Copyright 2015 Samsung Electronics All Rights Reserved.\r
4 #\r
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
6 #\r
7 # Licensed under the Apache License, Version 2.0 (the "License");\r
8 # you may not use this file except in compliance with the License.\r
9 # You may obtain a copy of the License at\r
10 #\r
11 #      http://www.apache.org/licenses/LICENSE-2.0\r
12 #\r
13 # Unless required by applicable law or agreed to in writing, software\r
14 # distributed under the License is distributed on an "AS IS" BASIS,\r
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 # See the License for the specific language governing permissions and\r
17 # limitations under the License.\r
18 #\r
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
20 \r
21 ##\r
22 # rcs_common (primitiveResource and expiryTimer) build script\r
23 ##\r
24 import os\r
25 Import('env')\r
26 \r
27 # Add third party libraries\r
28 lib_env = env.Clone()\r
29 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', exports = 'lib_env')\r
30 \r
31 src_dir = lib_env.get('SRC_DIR')\r
32 \r
33 gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'\r
34 \r
35 rcs_common_env = lib_env.Clone()\r
36 target_os = env.get('TARGET_OS')\r
37 \r
38 release = env.get('RELEASE')\r
39 \r
40 ######################################################################\r
41 # Build flags\r
42 ######################################################################\r
43 rcs_common_env.AppendUnique(CPPPATH = [\r
44     env.get('SRC_DIR')+'/extlibs',\r
45     '../../include',\r
46     'primitiveResource/include'])\r
47         \r
48 rcs_common_env.AppendUnique(CPPPATH = [\r
49     'expiryTimer/include',\r
50     'expiryTimer/src'])\r
51 \r
52 rcs_common_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])\r
53 \r
54 if target_os not in ['windows', 'winrt']:\r
55     rcs_common_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])\r
56     if target_os != 'android':\r
57         rcs_common_env.AppendUnique(CXXFLAGS = ['-pthread'])\r
58         rcs_common_env.AppendUnique(LIBS = ['pthread'])\r
59 \r
60 if target_os == 'android':\r
61     rcs_common_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])\r
62     rcs_common_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])\r
63 \r
64 rcs_common_env.AppendUnique(LIBS = ['dl'])\r
65 \r
66 if not release:\r
67     rcs_common_env.AppendUnique(CXXFLAGS = ['--coverage'])\r
68     rcs_common_env.PrependUnique(LIBS = ['gcov'])\r
69 \r
70 ######################################################################\r
71 # Source files and Targets\r
72 ######################################################################\r
73 TIMER_SRC_DIR = 'expiryTimer/src/'\r
74 RESOURCE_SRC = 'primitiveResource/src/'\r
75 rcs_common_src = [\r
76         TIMER_SRC_DIR + 'ExpiryTimerImpl.cpp', \r
77                 TIMER_SRC_DIR + 'ExpiryTimer.cpp',\r
78                 RESOURCE_SRC + 'PresenceSubscriber.cpp',\r
79                 RESOURCE_SRC + 'PrimitiveResource.cpp',\r
80                 RESOURCE_SRC + 'RCSException.cpp',\r
81                 RESOURCE_SRC + 'RCSAddress.cpp',\r
82                 RESOURCE_SRC + 'RCSResourceAttributes.cpp',\r
83                 RESOURCE_SRC + 'ResponseStatement.cpp'\r
84         ]\r
85                 \r
86 rcs_common_static = rcs_common_env.StaticLibrary('rcs_common', rcs_common_src)\r
87 rcs_common_shared = rcs_common_env.SharedLibrary('rcs_common', rcs_common_src)\r
88 rcs_common_env.InstallTarget([rcs_common_static,rcs_common_shared], 'rcs_common')\r
89 \r
90 ######################################################################\r
91 # Build Test primitive Resource\r
92 ######################################################################\r
93 rcs_common_test_env = rcs_common_env.Clone();\r
94 \r
95 rcs_common_test_env.PrependUnique(CPPPATH = [\r
96     env.get('SRC_DIR')+'/extlibs/hippomocks-master',\r
97     gtest_dir + '/include',\r
98     'utils/include'\r
99     ])\r
100 \r
101 gtest = File(gtest_dir + '/lib/.libs/libgtest.a')\r
102 gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')\r
103 \r
104 rcs_common_test_env.PrependUnique(LIBS = [\r
105         'oc',\r
106     'octbstack',\r
107     'oc_logger',\r
108     'connectivity_abstraction',\r
109     'coap',\r
110     'rcs_common',\r
111     gtest,\r
112     gtest_main,\r
113     'pthread'\r
114     ])\r
115 \r
116 rcs_common_test_src = [\r
117     env.Glob('primitiveResource/unittests/*.cpp'),\r
118     'expiryTimer/unittests/ExpiryTimerTest.cpp'\r
119     ]\r
120 \r
121 rcs_common_test = rcs_common_test_env.Program('rcs_common_test', rcs_common_test_src)\r
122 Alias("rcs_common_test", rcs_common_test)\r
123 env.AppendTarget('rcs_common_test')\r
124
125 if env.get('TEST') == '1':
126     target_os = env.get('TARGET_OS')
127     if target_os == 'linux':
128         from tools.scons.RunTest import *
129         run_test(rcs_common_test_env, '',
130                 'service/resource-encapsulation/src/common/rcs_common_test')