Common adapter for DTLS/TLS
[platform/upstream/iotivity.git] / resource / csdk / SConscript
index 8606857..5897a39 100644 (file)
@@ -43,6 +43,14 @@ if target_os == 'arduino':
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = liboctbstack_env.get('WITH_UPSTREAM_LIBCOAP')
+if with_upstream_libcoap == '1':
+       # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
+       liboctbstack_env.PrependUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       liboctbstack_env.PrependUnique(CPPPATH = ['connectivity/lib/libcoap-4.1.1/include'])
+
 liboctbstack_env.PrependUnique(CPPPATH = [
                '../../extlibs/cjson/',
                '../../extlibs/timer/',
@@ -50,7 +58,6 @@ liboctbstack_env.PrependUnique(CPPPATH = [
                'stack/include',
                'stack/include/internal',
                '../oc_logger/include',
-               'connectivity/lib/libcoap-4.1.1',
                'connectivity/common/inc',
                'connectivity/inc',
                'connectivity/inc/pkix',
@@ -69,7 +76,7 @@ if 'BROKER' in with_mq:
        liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
 
 if target_os not in ['arduino', 'windows']:
-       liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
+       liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX', '_GNU_SOURCE'])
        liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
 
 if liboctbstack_env.get('ROUTING') == 'GW':
@@ -77,12 +84,23 @@ if liboctbstack_env.get('ROUTING') == 'GW':
 elif liboctbstack_env.get('ROUTING') == 'EP':
        liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
 
+if liboctbstack_env.get('WITH_PROXY'):
+       liboctbstack_env.AppendUnique(CPPDEFINES = ['WITH_CHPROXY'])
+
 if target_os not in ['windows']:
        liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
 
 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
 
 liboctbstack_env.PrependUnique(LIBS = ['ocsrm', 'coap'])
+
+if target_os in ['linux'] and liboctbstack_env.get('SIMULATOR', False):
+       liboctbstack_env.Append( RPATH = liboctbstack_env.Literal('\\$$ORIGIN'))
+
+if env.get('SECURED') == '1':
+       liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
+       liboctbstack_env.AppendUnique(LIBS = ['mbedtls','mbedx509','mbedcrypto'])
+
 if target_os in ['android', 'linux', 'tizen', 'msys_nt', 'windows']:
        liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
 
@@ -93,13 +111,28 @@ if target_os in ['android', 'linux', 'tizen', 'msys_nt', 'windows']:
                        liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
 
 if target_os in ['windows', 'msys_nt']:
-       liboctbstack_env.AppendUnique(CPPDEFINES  = ['OC_EXPORT_DLL'])
-       liboctbstack_env.AppendUnique(LIBS = ['ws2_32', 'advapi32', 'iphlpapi'])
+       # octbstack.def specifies the list of functions exported by octbstack.dll.
+       liboctbstack_env.Replace(WINDOWS_INSERT_DEF = ['1'])
+       if env.get('TEST') == '1':
+               liboctbstack_env.Textfile(target = 'octbstack_not_secured.def', source = [File('octbstack_product.def'), File('octbstack_test.def')])
+       else:
+               liboctbstack_env.Textfile(target = 'octbstack_not_secured.def', source = [File('octbstack_product.def')])
+
+       if env.get('SECURED') == '1':
+               # octbstack.dll is exporting ocpmapi APIs on Windows - there is no ocpmapi.dll.
+               liboctbstack_env.PrependUnique(LIBS = ['ocpmapi'])
+               liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_not_secured.def'), File('octbstack_product_secured.def')])
+       else:
+               liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_not_secured.def')])
+
+       liboctbstack_env.AppendUnique(LIBS = ['ws2_32', 'advapi32', 'iphlpapi', 'bcrypt'])
 else:
        liboctbstack_env.AppendUnique(LIBS = ['m'])
 
 if target_os in ['tizen', 'linux']:
        liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
+if target_os in ['tizen']:
+       liboctbstack_env.ParseConfig('pkg-config --cflags --libs sqlite3')
 
 if target_os == 'arduino':
        liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
@@ -112,19 +145,11 @@ if target_os in ['darwin', 'ios']:
 if target_os not in ['arduino', 'windows']:
        liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
 if target_os == 'android':
-    liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboctbstack.so'])
-
-if env.get('SECURED') == '1':
-       liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
-       if env.get('WITH_TCP') == True:
-               liboctbstack_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
+       liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboctbstack.so'])
 
 if env.get('LOGGING'):
        liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
-if env.get('DTLS_WITH_X509') == '1':
-       liboctbstack_env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
-
 liboctbstack_env.Append(LIBS = ['c_common'])
 
 if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
@@ -150,24 +175,24 @@ liboctbstack_src = [
        ]
 
 if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
-       liboctbstack_src.append(OCTBSTACK_SRC + 'rdpayload.c')
-       liboctbstack_src.append(OCTBSTACK_SRC + 'oicresourcedirectory.c')
        if 'CLIENT' in rd_mode:
                liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
        if 'SERVER' in rd_mode:
                liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_SERVER'])
+       if target_os in ['linux', 'android']:
+               liboctbstack_env.Prepend(LIBS = ['resource_directory'])
+               liboctbstack_env.PrependUnique(CPPPATH = [env.get('BUILD_DIR') + 'resource/csdk/resource-directory/include'])
+               liboctbstack_env.PrependUnique(LIBPATH = [env.get('BUILD_DIR') + 'resource/csdk/resource-directory/include'])
 
 if with_tcp == True:
        liboctbstack_src.append(OCTBSTACK_SRC + 'oickeepalive.c')
 
-liboctbstack_src.extend(env['cbor_files'])
-
-if target_os == 'windows':
-       liboctbstack_env.AppendUnique(CPPDEFINES = ['CBOR_API=__declspec(dllexport)',
-                                                   'CBOR_PRIVATE_API=__declspec(dllexport)'
-    ])
+if target_os in ['windows', 'msys_nt']:
+       # Avoid a name conflict with the octbstack.lib target of the SharedLibrary.
+       static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack_static', liboctbstack_src)
+else:
+       static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
 
-static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
 octbstack_libs = Flatten(static_liboctbstack)
 
 if target_os not in ['arduino','darwin','ios'] :
@@ -181,3 +206,4 @@ liboctbstack_env.UserInstallTargetLib(octbstack_libs, 'octbstack')
 
 liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
 liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
+liboctbstack_env.UserInstallTargetHeader('stack/include/ocpayload.h', 'resource', 'ocpayload.h')