[IoTivity Simulator] Updated the eclipse plugins to load the
[platform/upstream/iotivity.git] / resource / csdk / SConscript
index 9519797..7aa175e 100644 (file)
 Import('env')
 
 lib_env = env.Clone()
-SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
+SConscript('#resource/third_party_libs.scons', 'lib_env')
 
 liboctbstack_env = lib_env.Clone()
 
 target_os = env.get('TARGET_OS')
+rd_mode = env.get('RD_MODE')
+with_ra = env.get('WITH_RA')
+with_ra_ibb = env.get('WITH_RA_IBB')
+with_tcp = env.get('WITH_TCP')
+with_mq = env.get('WITH_MQ')
 # As in the source code, it includes arduino Time library (C++)
 # It requires compile the .c with g++
 if target_os == 'arduino':
@@ -42,58 +47,102 @@ liboctbstack_env.PrependUnique(CPPPATH = [
                '../../extlibs/cjson/',
                '../../extlibs/timer/',
                'logger/include',
-               'ocrandom/include',
                'stack/include',
                'stack/include/internal',
                '../oc_logger/include',
                'connectivity/lib/libcoap-4.1.1',
+               'connectivity/common/inc',
                'connectivity/inc',
+               'connectivity/inc/pkix',
                'connectivity/api',
                'connectivity/external/inc',
                'security/include',
                'security/include/internal',
+               'security/provisioning/include',
                ])
 
-liboctbstack_env.AppendUnique(LIBS = ['ocsrm'])
+if 'SUB' in with_mq:
+       liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
+if 'PUB' in with_mq:
+       liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
+if 'BROKER' in with_mq:
+       liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
 
-if target_os not in ['arduino', 'windows', 'winrt']:
+if target_os not in ['arduino', 'windows']:
        liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
        liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
 
-if target_os not in ['windows', 'winrt']:
+if liboctbstack_env.get('ROUTING') == 'GW':
+       liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
+elif liboctbstack_env.get('ROUTING') == 'EP':
+       liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
+
+if target_os not in ['windows']:
        liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
 
 liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
 
-if target_os in ['android', 'linux', 'tizen']:
-       liboctbstack_env.AppendUnique(LIBS = ['connectivity_abstraction'])
-liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
+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 target_os == 'tizen':
-    liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
+if env.get('SECURED') == '1':
+       liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
+       if env.get('WITH_TCP') == True:
+               liboctbstack_env.AppendUnique(LIBS = ['mbedtls','mbedx509','mbedcrypto'])
+
+if target_os in ['android', 'linux', 'tizen', 'msys_nt', 'windows']:
+       liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
+
+       if with_ra_ibb:
+               liboctbstack_env.AppendUnique(LIBS = liboctbstack_env['RALIBS'], LIBPATH = liboctbstack_env['RALIBPATH'], RPATH = liboctbstack_env['RARPATH'])
+       else :
+               if with_ra:
+                       liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
+
+if target_os in ['windows', 'msys_nt']:
+       # octbstack.dll is exporting ocpmapi APIs on Windows - there is no ocpmapi.dll.
+       liboctbstack_env.PrependUnique(LIBS = ['ocpmapi'])
+
+       # 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.def', source = [File('octbstack_product.def'), File('octbstack_test.def')])
+       else:
+               liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_product.def')])
+
+       liboctbstack_env.AppendUnique(LIBS = ['ws2_32', 'advapi32', 'iphlpapi'])
+else:
+       liboctbstack_env.AppendUnique(LIBS = ['m'])
 
-if target_os not in ['android', 'arduino', 'windows', 'winrt']:
-       liboctbstack_env.AppendUnique(LIBS = ['pthread'])
+if target_os in ['tizen', 'linux']:
+       liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
 
 if target_os == 'arduino':
        liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
-elif target_os not in ['darwin','ios']:
+elif target_os not in ['darwin','ios', 'msys_nt', 'windows']:
        liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
 if target_os in ['darwin', 'ios']:
        env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
        liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
        liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-if target_os not in ['arduino']:
+if target_os not in ['arduino', 'windows']:
        liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
-
-if env.get('SECURED') == '1':
-       liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
+if target_os == 'android':
+    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']:
+       liboctbstack_env.Prepend(LIBS = ['routingmanager'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################
@@ -110,20 +159,39 @@ liboctbstack_src = [
        OCTBSTACK_SRC + 'ocobserve.c',
        OCTBSTACK_SRC + 'ocserverrequest.c',
        OCTBSTACK_SRC + 'occollection.c',
-       OCTBSTACK_SRC + 'oicgroup.c',
-       'logger/src/logger.c',
-       'ocrandom/src/ocrandom.c'
+       OCTBSTACK_SRC + 'oicgroup.c'
        ]
 
+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 with_tcp == True:
+       liboctbstack_src.append(OCTBSTACK_SRC + 'oickeepalive.c')
+
 liboctbstack_src.extend(env['cbor_files'])
 
-if target_os in ['arduino','darwin','ios'] :
-       static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
-       liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
-       liboctbstack_env.UserInstallTargetLib(static_liboctbstack, 'liboctbstack')
+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)
+
+octbstack_libs = Flatten(static_liboctbstack)
+
+if target_os not in ['arduino','darwin','ios'] :
        shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
-       liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
-       liboctbstack_env.UserInstallTargetLib([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
+       octbstack_libs += Flatten(shared_liboctbstack)
+       liboctbstack_env.UserInstallTargetHeader('stack/include/ocstack.h', 'resource', 'ocstack.h')
+       liboctbstack_env.UserInstallTargetHeader('stack/include/ocpresence.h', 'resource', 'ocpresence.h')
+
+liboctbstack_env.InstallTarget(octbstack_libs, 'octbstack')
+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')