Move unittest file to test folder to sync with existing folder structure
[platform/upstream/iotivity.git] / resource / csdk / SConscript
index d47f3e0..c32cca0 100644 (file)
@@ -1,18 +1,38 @@
+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
 ##
-# liboctbstack (static library) build script
+# liboctbstack (share library) build script
 ##
 
-Import('env', 'BUILD_TARGET', 'TARGET_CPU_ARCH', 'RELEASE_BUILD', 'BUILD_DIR', 'SRC_TOP_DIR')
+Import('env')
 
-liboctbstack_env = env.Clone()
+lib_env = env.Clone()
+SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
 
-# Add third party libraries
-SConscript(SRC_TOP_DIR + '/third_party_libs.scons')
-Import('OIC_UTILS')
+liboctbstack_env = lib_env.Clone()
 
+target_os = env.get('TARGET_OS')
 # As in the source code, it includes arduino Time library (C++)
 # It requires compile the .c with g++
-if BUILD_TARGET == 'arduino':
+if target_os == 'arduino':
        liboctbstack_env.Replace(CC = env.get('CXX'))
        liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
 
@@ -20,26 +40,43 @@ if BUILD_TARGET == 'arduino':
 # Build flags
 ######################################################################
 liboctbstack_env.PrependUnique(CPPPATH = [
-               OIC_UTILS + '/tb/cJSON/',
-               'ocsocket/include',
+               '../../extlibs/cjson/',
                'logger/include',
                'ocrandom/include',
                'ocmalloc/include',
-               'libcoap',
-               'occoap/include',
                'stack/include',
                'stack/include/internal',
-               '../oc_logger/include'
+               '../oc_logger/include',
+               'connectivity/lib/libcoap-4.1.1',
+               'connectivity/inc',
+               'connectivity/api',
+               'security/include',
+               'security/include/internal',
                ])
 
-if BUILD_TARGET not in ['arduino', 'windows', 'winrt']:
+if target_os not in ['arduino', 'windows', 'winrt']:
        liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX'])
        liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
 
-if BUILD_TARGET not in ['windows', 'winrt']:
+if target_os not in ['windows', 'winrt']:
        liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
 
-if not RELEASE_BUILD:
+liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
+
+liboctbstack_env.AppendUnique(CPPDEFINES = ['CA_SEC_MERGE_WORKAROUND'])
+
+if target_os == 'arduino':
+       liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
+else:
+       liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
+
+if target_os in ['darwin', 'ios']:
+       liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+       liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+       liboctbstack_env.AppendUnique(LIBS = ['coap'])
+
+if env.get('LOGGING'):
        liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
 ######################################################################
@@ -47,24 +84,23 @@ if not RELEASE_BUILD:
 ######################################################################
 OCTBSTACK_SRC = 'stack/src/'
 liboctbstack_src = [
-       'occoap/src/occoap.c',
-       'occoap/src/occoaphelper.c',
+       '../../extlibs/cjson/cJSON.c',
        OCTBSTACK_SRC + 'ocstack.c',
        OCTBSTACK_SRC + 'occlientcb.c',
        OCTBSTACK_SRC + 'ocresource.c',
        OCTBSTACK_SRC + 'ocobserve.c',
        OCTBSTACK_SRC + 'ocserverrequest.c',
        OCTBSTACK_SRC + 'occollection.c',
+       OCTBSTACK_SRC + 'oicgroup.c',
+       'security/src/ocsecurity.c',
+       'logger/src/logger.c',
+       'ocrandom/src/ocrandom.c',
+       'ocmalloc/src/ocmalloc.c'
        ]
-
-if RELEASE_BUILD:
-       prefix = TARGET_CPU_ARCH + '-'
+if target_os == 'arduino':
+       liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
 else:
-       prefix = TARGET_CPU_ARCH + 'd-'
-cjson_obj = liboctbstack_env.Object(OIC_UTILS + '/tb/cJSON/cJSON.c', OBJPREFIX=prefix)
-liboctbstack_src.append(cjson_obj)
-
-liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
-i_lctbs = liboctbstack_env.Install(BUILD_DIR, liboctbstack)
-Alias('liboctbstack', i_lctbs)
-env.AppendUnique(TS = ['liboctbstack'])
+       liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
+
+liboctbstack_env.InstallTarget(liboctbstack, 'liboctbstack')
+