[IOT-1089] Change Android build system to accomodate both Android and Generic Java...
[contrib/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/stack/include', 
41                 env.get('SRC_DIR') + '/resource/csdk/ocsocket/include', 
42                 env.get('SRC_DIR') + '/resource/oc_logger/include', 
43                 env.get('SRC_DIR') + '/resource/csdk/logger/include', 
44                 env.get('SRC_DIR') + '/resource/../extlibs/boost/boost_1_58_0', 
45                 env.get('SRC_DIR') + '/resource/../build_common/android/compatibility', 
46                 env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include', 
47                 env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/oxm', 
48                 env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal', 
49                 env.get('SRC_DIR') + '/resource/csdk/security/include'
50                 ])
51
52
53 target_os = env.get('TARGET_OS')
54 jni_env.AppendUnique(CCFLAGS = ['-Wno-error', '-Wno-comment', '-Wno-unused-function', '-Wno-unused-parameter'])
55 if target_os not in ['windows', 'winrt']:
56         jni_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
57
58         # Note: 'pthread' is in libc for android. On other platform, if use
59         # new gcc(>4.9?) it isn't required, otherwise, it's required
60         if target_os != 'android':
61                 jni_env.AppendUnique(LIBS = ['-lpthread'])
62
63 jni_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
64 jni_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
65 jni_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction'])
66 if env.get('SECURED') == '1':
67     jni_env.AppendUnique(LIBS = ['tinydtls', 'ocprovision', 'ocpmapi'])
68
69 if target_os == 'android':
70         jni_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
71         jni_env.AppendUnique(LIBS = ['gnustl_shared'])
72
73         if not env.get('RELEASE'):
74                 jni_env.AppendUnique(LIBS = ['log'])
75
76 if target_os in ['darwin', 'ios']:
77         jni_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
78
79 ######################################################################
80 # Source files and Targets
81 ######################################################################
82
83
84 ca_interface = jni_env.SharedLibrary('ca-interface', ['JniCaInterface.c'])
85
86 ocstack_files = [
87                         'JniOcStack.cpp',
88                         'JniUtils.cpp',
89                         'JniEntityHandler.cpp',
90                         'JniOnResourceFoundListener.cpp',
91                         'JniOnDeviceInfoListener.cpp',
92                         'JniOnPlatformInfoListener.cpp',
93                         'JniOnPresenceListener.cpp',
94                         'JniOnGetListener.cpp',
95                         'JniOnPutListener.cpp',
96                         'JniOnPostListener.cpp',
97                         'JniOnDeleteListener.cpp',
98                         'JniOnObserveListener.cpp',
99                         'JniOcRepresentation.cpp',
100                         'JniOcResourceHandle.cpp',
101                         'JniOcPresenceHandle.cpp',
102                         'JniOcRequestHandle.cpp',
103                         'JniOcResourceRequest.cpp',
104                         'JniOcResourceResponse.cpp',
105                         'JniOcPlatform.cpp',
106                         'JniOcResource.cpp',
107                         'JniOcResourceIdentifier.cpp',
108                         'JniOcSecurity.cpp'
109                 ]
110 if env.get('SECURED') == '1':
111         ocstack_files += [
112                                 'JniOcSecureResource.cpp',
113                                 'JniOcProvisioning.cpp',
114                                 'JniSecureUtils.cpp',
115                                 'JniProvisionResultListner.cpp',
116                                 'JniPinCheckListener.cpp',
117                                 'JniDisplayPinListener.cpp'
118                         ]
119
120 ocstack_jni = jni_env.SharedLibrary('ocstack-jni', ocstack_files)
121
122 jni_env.InstallTarget(ocstack_jni, 'ocstack-jni')
123 jni_env.InstallTarget(ca_interface, 'ca-interface')
124
125 env.AppendTarget('ocstack-jni')