Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / simulator / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 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 # Simulator build script
23 ##
24
25 import os, sys
26 Import('env')
27
28 lib_env = env.Clone()
29 src_dir = env.get('SRC_DIR')
30 SConscript(src_dir + '/service/third_party_libs.scons', 'lib_env')
31 simulator_env = lib_env.Clone()
32
33 #Raml Parser
34 SConscript('ramlparser/SConscript')
35
36 target_os = env.get('TARGET_OS')
37 ######################################################################
38 # Build flags
39 ######################################################################
40 simulator_env.AppendUnique(CPPPATH = ['inc', 'src/client', 'src/server', 'src/common'])
41 simulator_env.AppendUnique(CPPPATH = [
42                 '../../resource/include/',
43                 '../../resource/csdk/stack/include',
44                 '../../resource/c_common/ocrandom/include',
45                 '../../resource/csdk/logger/include',
46                 '../../resource/oc_logger/include',
47                 './ramlparser/raml',
48                 './ramlparser/raml/model',              
49                 './ramlparser/raml/jsonSchemaParser',   
50                 '../../extlibs/yaml/yaml/include'
51                 ])
52
53 # Including Java path for building JNI files
54 try:
55         os.environ['JAVA_HOME']
56 except KeyError:
57         print '''
58 *************************************** Error *********************************
59 * JAVA_HOME environment variable not set                                      
60 * Simulator has dependency on java, Please set environment variable JAVA_HOME
61 *******************************************************************************
62         '''
63         sys.exit(1)
64         
65 java_headers = [os.path.join(os.environ['JAVA_HOME'], 'include')]
66 java_headers.append(os.path.join(java_headers[0], 'win32'))
67 java_headers.append(os.path.join(java_headers[0], 'linux'))
68 java_headers.append(os.path.join(java_headers[0], 'solaris'))
69 simulator_env.AppendUnique(CPPPATH = java_headers)
70
71 simulator_env.Append( RPATH = env.Literal('\\$$ORIGIN'))
72
73 simulator_env.AppendUnique(CPPPATH = ['../../extlibs/cjson'])
74 simulator_env.PrependUnique(LIBS = ['oc', 'octbstack', 'RamlParser'])
75 simulator_env.AppendUnique(LIBS = ['pthread'])
76
77 simulator_env.AppendUnique(CXXFLAGS = ['-O2', '-Wall', '-fmessage-length=0', '-std=c++0x'])
78
79 ######################################################################
80 # Source files and Targets
81 ######################################################################
82 simulator_src = [env.Glob('src/*.cpp')
83                  ,env.Glob('src/*/*.cpp')
84                  ,env.Glob('java/jni/*.cpp')
85                 ]
86 simulatorsdk = simulator_env.SharedLibrary('SimulatorManager', simulator_src)
87
88 simulator_env.InstallTarget(simulatorsdk, 'libSimulatorManager')
89
90 #Build sample application
91 SConscript('examples/server/SConscript')
92 SConscript('examples/client/SConscript')