152ee819ad1015c614ea9deb5b61f07d5d13b665
[iotivity.git] / java / jni / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 Intel Mobile Communications GmbH 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 # Examples build script
23 ##
24 Import('env')
25 # Add third party libraries
26 lib_env = env.Clone()
27 SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
28
29 jni_env = lib_env.Clone()
30
31 ######################################################################
32 # Build flags
33 ######################################################################
34 jni_env.AppendUnique(CPPPATH = [
35                 env.get('SRC_DIR') + '/resource/csdk/connectivity/api',
36                 env.get('SRC_DIR') + '/resource/include',
37                 env.get('SRC_DIR') + '/resource/c_common',
38                 env.get('SRC_DIR') + '/resource/c_common/oic_string/include',
39                 env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',
40                 env.get('SRC_DIR') + '/resource/csdk/include',
41                 env.get('SRC_DIR') + '/resource/csdk/stack/include',
42                 env.get('SRC_DIR') + '/resource/csdk/ocsocket/include',
43                 env.get('SRC_DIR') + '/resource/csdk/resource-directory/include',
44                 env.get('SRC_DIR') + '/resource/oc_logger/include',
45                 env.get('SRC_DIR') + '/resource/csdk/logger/include',
46                 env.get('SRC_DIR') + '/resource/../extlibs/boost/boost_1_58_0',
47                 env.get('SRC_DIR') + '/resource/../build_common/android/compatibility',
48                 env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include',
49                 env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/oxm',
50                 env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal',
51                 env.get('SRC_DIR') + '/resource/csdk/security/include',
52                 env.get('SRC_DIR') + '/resource/csdk/connectivity/lib/libcoap-4.1.1/include'
53                 ])
54
55 target_os = env.get('TARGET_OS')
56 jni_env.AppendUnique(CCFLAGS = ['-Wno-error', '-Wno-comment', '-Wno-unused-function', '-Wno-unused-parameter'])
57 if target_os not in ['windows', 'winrt']:
58         jni_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
59
60         # Note: 'pthread' is in libc for android. On other platform, if use
61         # new gcc(>4.9?) it isn't required, otherwise, it's required
62         if target_os != 'android':
63                 jni_env.AppendUnique(LIBS = ['-lpthread'])
64
65 jni_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
66 jni_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
67 jni_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction'])
68 if env.get('SECURED') == '1':
69 #    jni_env.AppendUnique(CPPDEFINES= ['__WITH_TLS__'])
70     jni_env.PrependUnique(LIBS = ['tinydtls', 'ocprovision', 'ocpmapi'])
71     jni_env.AppendUnique(CPPPATH = ['#resource/csdk/security/include/internal',
72                                     '#extlibs/cjson',
73                                     '#resource/csdk/security/provisioning/include/cloud'])
74
75 if target_os == 'android':
76         jni_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
77         jni_env.AppendUnique(LIBS = ['gnustl_shared'])
78
79         if not env.get('RELEASE'):
80                 jni_env.AppendUnique(LIBS = ['log'])
81
82 if target_os in ['darwin', 'ios']:
83         jni_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
84
85 if env.get('WITH_CLOUD'):
86         jni_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
87
88 if env.get('WITH_TCP'):
89         jni_env.AppendUnique(CPPDEFINES = ['WITH_TCP', '__WITH_TLS__'])
90
91 with_mq = env.get('WITH_MQ')
92 if 'SUB' in with_mq:
93         jni_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
94 if 'PUB' in with_mq:
95         jni_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
96 if 'BROKER' in with_mq:
97         jni_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
98 ######################################################################
99 # Source files and Targets
100 ######################################################################
101
102 ca_interface = jni_env.SharedLibrary('ca-interface', ['JniCaInterface.c'])
103
104 ocstack_files = [
105                         'JniOcStack.cpp',
106                         'JniUtils.cpp',
107                         'JniEntityHandler.cpp',
108                         'JniOnResourceFoundListener.cpp',
109                         'JniOnDeviceInfoListener.cpp',
110                         'JniOnPlatformInfoListener.cpp',
111                         'JniOnPresenceListener.cpp',
112                         'JniOnGetListener.cpp',
113                         'JniOnPutListener.cpp',
114                         'JniOnPostListener.cpp',
115                         'JniOnDeleteListener.cpp',
116                         'JniOnObserveListener.cpp',
117                         'JniOcRepresentation.cpp',
118                         'JniOcResourceHandle.cpp',
119                         'JniOcPresenceHandle.cpp',
120                         'JniOcRequestHandle.cpp',
121                         'JniOcResourceRequest.cpp',
122                         'JniOcResourceResponse.cpp',
123                         'JniOcPlatform.cpp',
124                         'JniOcResource.cpp',
125                         'JniOcResourceIdentifier.cpp',
126                         'JniOcSecurity.cpp',
127                         'JniOnDPDevicesFoundListener.cpp',
128                         'JniOnDirectPairingListener.cpp',
129                         'JniOcDirectPairDevice.cpp',
130                         'JniOnPublishResourceListener.cpp',
131                         'JniOnDeleteResourceListener.cpp',
132                         'JniOcRDClient.cpp',
133                 ]
134 if ('PUB' in with_mq) or ('SUB' in with_mq) or ('BROKER' in with_mq):
135         ocstack_files += [
136                                 'JniOnMQTopicFoundListener.cpp',
137                                 'JniOnMQSubscribeListener.cpp'
138                         ]
139 if env.get('SECURED') == '1':
140         ocstack_files += [
141                                 'JniOcSecureResource.cpp',
142                                 'JniOcProvisioning.cpp',
143                                 'JniSecureUtils.cpp',
144                                 'JniProvisionResultListner.cpp',
145                                 'JniPinCheckListener.cpp',
146                                 'JniDisplayPinListener.cpp',
147                                 'JniDisplayVerifyNumListener.cpp',
148                                 'JniConfirmNumListener.cpp'
149                         ]
150 if env.get('WITH_CLOUD'):
151         ocstack_files += [
152                                 'JniOcAccountManager.cpp'
153                         ]
154 if env.get('WITH_TCP') or env.get('SECURED') == '1':
155         ocstack_files += [
156                                 'JniOcCloudResultListener.cpp',
157                                 'JniGetAclIdByDeviceListener.cpp'
158                         ]
159 if env.get('WITH_TCP'):
160     ocstack_files += ['JniOcCloudProvisioning.cpp']
161 ocstack_jni = jni_env.SharedLibrary('ocstack-jni', ocstack_files)
162
163 jni_env.InstallTarget(ocstack_jni, 'ocstack-jni')
164 jni_env.InstallTarget(ca_interface, 'ca-interface')
165
166 env.AppendTarget('ocstack-jni')