[IOT-2060] Don't force-link with routingmanager
[platform/upstream/iotivity.git] / resource / csdk / stack / SConscript
index beff618..13f6c49 100644 (file)
@@ -49,10 +49,8 @@ if target_os == 'arduino':
 ######################################################################
 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 = ['#resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
 
 liboctbstack_env.PrependUnique(CPPPATH = [
@@ -71,6 +69,7 @@ liboctbstack_env.PrependUnique(CPPPATH = [
         '#resource/csdk/security/include',
         '#resource/csdk/security/include/internal',
         '#resource/csdk/security/provisioning/include',
+        '#resource/csdk/routing/include',
         ])
 
 if 'SUB' in with_mq:
@@ -100,6 +99,9 @@ if target_os in ['linux'] and liboctbstack_env.get('SIMULATOR', False):
 if env.get('SECURED') == '1':
     liboctbstack_env.AppendUnique(LIBS = ['mbedtls','mbedx509'])
 
+# c_common calls into mbedcrypto.
+liboctbstack_env.AppendUnique(LIBS = ['mbedcrypto'])
+
 if target_os in ['android', 'linux', 'tizen', 'msys_nt', 'windows']:
     liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
 
@@ -117,6 +119,10 @@ else:
     # octbstack.def specifies the list of functions exported by octbstack.dll.
     liboctbstack_env.Replace(WINDOWS_INSERT_DEF = ['1'])
 
+    # On Windows, apps don't link directly with oc_logger. oc_logger is linked inside
+    # octbstack.dll and apps import its APIs by linking with octbstack.lib.
+    liboctbstack_env.PrependUnique(LIBS = ['oc_logger_internal'])
+
     if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
         # On Windows:
         # - octbstack.dll is exporting resource_directory C APIs
@@ -136,8 +142,9 @@ else:
     if env.get('SECURED') != '1':
         liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_temp2.def')])
     else:
-        # octbstack.dll is exporting ocpmapi APIs on Windows - there is no ocpmapi.dll.
-        liboctbstack_env.PrependUnique(LIBS = ['ocpmapi'])
+        # On Windows, apps don't link directly with ocpmapi.lib. ocpmapi is linked
+        # inside octbstack.dll and apps import its APIs by linking with octbstack.lib.
+        liboctbstack_env.PrependUnique(LIBS = ['ocpmapi_internal'])
 
         liboctbstack_env.Textfile(target = 'octbstack_temp3.def', source = [File('octbstack_temp2.def'), File('octbstack_product_secured.def')])
 
@@ -170,8 +177,6 @@ if target_os == 'android':
 if env.get('LOGGING'):
     liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
-liboctbstack_env.Append(LIBS = ['c_common', 'mbedcrypto'])
-
 if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
     liboctbstack_env.Prepend(LIBS = ['routingmanager'])
 
@@ -219,30 +224,19 @@ if 'SERVER' in rd_mode:
     if target_os not in ['linux', 'tizen', 'windows']:
         liboctbstack_src.append('#extlibs/sqlite3/sqlite3.c')
 
-if target_os in ['linux']:
-    # Linux uses a Shared library because SCons chooses the shared library on Linux
-    # when only 'octbstack' is added to the LIBS.
-    # TODO: Switch Linux to use a Static library for testing like every other OS.
-    test_liboctbstack = liboctbstack_env.SharedLibrary('octbstack_test', liboctbstack_src)
-else:
-    test_liboctbstack = liboctbstack_env.StaticLibrary('octbstack_test', liboctbstack_src)
-
-octbstack_libs = Flatten(test_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)
+internal_liboctbstack = liboctbstack_env.StaticLibrary('octbstack_internal', liboctbstack_src)
+octbstack_libs = Flatten(internal_liboctbstack)
 
-if target_os not in ['arduino','darwin','ios'] :
+if target_os not in ['arduino', 'darwin', 'ios'] :
     shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
     octbstack_libs += Flatten(shared_liboctbstack)
     liboctbstack_env.UserInstallTargetHeader('include/ocstack.h', 'resource', 'ocstack.h')
     liboctbstack_env.UserInstallTargetHeader('include/ocpresence.h', 'resource', 'ocpresence.h')
 
+if target_os not in ['windows', 'msys_nt']:
+    static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
+    octbstack_libs += Flatten(static_liboctbstack)
+
 liboctbstack_env.InstallTarget(octbstack_libs, 'octbstack')
 liboctbstack_env.UserInstallTargetLib(octbstack_libs, 'octbstack')