[IOT-3022] Build CNC as standalone lib 95/25395/9
authorVitalii Irkha <v.irkha@samsung.com>
Wed, 23 May 2018 08:24:59 +0000 (11:24 +0300)
committerVitalii Irkha <v.irkha@samsung.com>
Fri, 8 Jun 2018 09:30:13 +0000 (12:30 +0300)
SConscript for cloud build
Cloud Reset is also was added

Change-Id: Ibd33bf931322a58e3efac1ccfebd5ea5cb6a1330
Signed-off-by: Vitalii Irkha <v.irkha@samsung.com>
resource/csdk/security/SConscript
resource/csdk/security/provisioning/sample/SConscript
resource/csdk/security/provisioning/src/SConscript
resource/csdk/security/provisioning/src/cloud/SConscript [new file with mode: 0644]
resource/csdk/security/provisioning/src/cloud/utils.c
resource/csdk/security/provisioning/unittest/SConscript
resource/csdk/security/src/deviceonboardingstate.c
resource/provisioning/SConscript
resource/provisioning/examples/SConscript

index 8204141..8cebb4a 100644 (file)
@@ -28,6 +28,10 @@ libocsrm_env = env.Clone()
 
 target_os = libocsrm_env.get('TARGET_OS')
 
+if target_os not in ['msys_nt', 'windows']:
+    if env.get('WITH_TCP') == True and env.get('WITH_CLOUD') == True:
+        env.PrependUnique(LIBS=['cloud'])
+
 ######################################################################
 # Build flags
 ######################################################################
index 213b1b4..5b8a697 100644 (file)
 # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 #
 
-Import('env provisioning_env')
 import os.path
+Import('env provisioning_env')
 
 provisioning_sample_env = provisioning_env.Clone()
 target_os = provisioning_sample_env.get('TARGET_OS')
 
+#Build cloud library
+if provisioning_sample_env.get('WITH_TCP') == True and provisioning_sample_env.get('WITH_CLOUD') == True:
+    SConscript('../src/cloud/SConscript', 'provisioning_env')
+    provisioning_sample_env.AppendUnique(LIBPATH=[os.path.join(env.get('BUILD_DIR'), 'resource', 'csdk', 'security', 'provisioning', 'src', 'cloud')])
+
 ######################################################################
 # Build flags
 ######################################################################
 provisioning_sample_env.AppendUnique(CPPPATH=[
     '#/resource/csdk/include',
-    '#/extlibs/base64',
-    '#/resource/csdk/security/provisioning/sample/cloud',
-    '#resource/csdk/security/provisioning/include/cloud'
+    '#/extlibs/base64'
 ])
 
 target_os = env.get('TARGET_OS')
@@ -50,16 +53,18 @@ else:
     provisioning_sample_env.AppendUnique(
         LIBPATH=[os.path.join(env.get('BUILD_DIR'), 'resource', 'csdk')])
 
-provisioning_sample_env.PrependUnique(LIBS=['coap'])
-
 if target_os not in ['msys_nt', 'windows']:
     provisioning_sample_env.PrependUnique(LIBS=['connectivity_abstraction'])
 
 provisioning_sample_env.PrependUnique(LIBS=['oc', 'octbstack'])
 
 if target_os not in ['msys_nt', 'windows']:
-    provisioning_sample_env.PrependUnique(
-        LIBS=['oc_logger', 'ocpmapi', 'ocsrm'])
+    if provisioning_sample_env.get('WITH_TCP') == True and provisioning_sample_env.get('WITH_CLOUD') == True:
+        provisioning_sample_env.PrependUnique(
+            LIBS=['oc_logger', 'coap', 'cloud', 'ocpmapi', 'ocsrm'])
+    else:
+        provisioning_sample_env.PrependUnique(
+            LIBS=['oc_logger', 'coap', 'ocpmapi', 'ocsrm'])
 
 if env.get('SECURED') == '1':
     provisioning_sample_env.AppendUnique(
@@ -125,7 +130,7 @@ sampleapps = [
     autoprovisioningclient,
     sampleserver_justworks,
     sampleserver_randompin,
-    sampleserver_mfg,
+    sampleserver_mfg
 ]
 sampleapps += provisioning_sample_env.ScanJSON('resource/csdk/security/provisioning/sample')
 if target_os not in ['msys_nt', 'windows']:
index 1dd304c..ca1bd4c 100644 (file)
 Import('provisioning_env')
 
 provisioning_lib_env = provisioning_env.Clone()
+#Build cloud library
+if provisioning_lib_env.get('WITH_TCP') == True and provisioning_lib_env.get('WITH_CLOUD') == True:
+    SConscript('cloud/SConscript', 'provisioning_env')
+
 target_os = provisioning_lib_env.get('TARGET_OS')
 
 provisioning_lib_env.AppendUnique(CPPPATH=['#resource/csdk/security/include/experimental'])
@@ -71,20 +75,6 @@ if provisioning_lib_env.get('MULTIPLE_OWNER') == '1':
         'oxmpreconfpin.c'
     ]
 
-if provisioning_lib_env.get('WITH_TCP') == True and provisioning_lib_env.get('WITH_CLOUD') == True:
-    provisioning_lib_env.AppendUnique(CPPDEFINES=['__WITH_TLS__'])
-    provisioning_src = provisioning_src + [
-        'cloud/utils.c',
-        'cloud/crl.c',
-        'cloud/aclgroup.c',
-        'cloud/aclinvite.c',
-        'cloud/aclid.c',
-        'cloud/csr.c',
-        'cloud/auth.c',
-        'cloud/cloudresource.c',
-        'cloud/config.c'
-    ]
-
 if target_os in ['linux', 'tizen']:
     provisioning_lib_env.ParseConfig('pkg-config --cflags --libs sqlite3')
 else:
diff --git a/resource/csdk/security/provisioning/src/cloud/SConscript b/resource/csdk/security/provisioning/src/cloud/SConscript
new file mode 100644 (file)
index 0000000..b85dfcc
--- /dev/null
@@ -0,0 +1,97 @@
+# ******************************************************************
+#
+# Copyright 2018 Samsung Electronics 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.
+#
+# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# libcloud (static library) build script
+##
+
+Import('env')
+
+libcloud_env = env.Clone()
+
+target_os = libcloud_env.get('TARGET_OS')
+
+######################################################################
+# Build flags
+######################################################################
+with_upstream_libcoap = libcloud_env.get('WITH_UPSTREAM_LIBCOAP')
+if with_upstream_libcoap == '1':
+    libcloud_env.AppendUnique(CPPPATH=['#extlibs/libcoap/libcoap/include'])
+else:
+    libcloud_env.AppendUnique(CPPPATH=['#/resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
+
+if libcloud_env.get('RELEASE') == '0':
+    libcloud_env.AppendUnique(CPPPATH=['#/out/linux/x86_64/debug/resource/c_common'])
+else:
+    libcloud_env.AppendUnique(CPPPATH=['#/out/linux/x86_64/release/resource/c_common'])
+
+libcloud_env.PrependUnique(CPPPATH=[
+    '#/resource/csdk/security/provisioning/include',
+    '#/resource/csdk/security/provisioning/include/cloud',
+    '#/resource/csdk/security/provisioning/include/internal',
+    '#/resource/csdk/security/include',
+    '#/resource/csdk/security/include/internal',
+    '#/resource/csdk/include',
+    '#/resource/csdk/stack/include',
+    '#/resource/csdk/stack/include/internal',
+    '#/resource/csdk/logger/include',
+    '#/resource/csdk/connectivity/api',
+    '#/resource/csdk/connectivity/common/inc',
+    '#/resource/c_common',
+    '#/resource/c_common/oic_malloc/include',
+    '#/resource/c_common/oic_string/include',
+    '#/resource/c_common/octhread/include',
+    '#/extlibs/tinycbor/tinycbor/src',
+    '#/resource/csdk/security/include/experimental'
+])
+
+if target_os not in ['windows']:
+    libcloud_env.AppendUnique(CPPDEFINES=['WITH_POSIX', '_GNU_SOURCE'])
+    libcloud_env.AppendUnique(CFLAGS=['-std=c99', '-Wall'])
+
+if target_os in ['darwin', 'ios']:
+    libcloud_env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
+
+if libcloud_env.get('LOGGING'):
+    libcloud_env.AppendUnique(CPPDEFINES=['TB_LOG'])
+
+if libcloud_env.get('MULTIPLE_OWNER') == '1':
+    libcloud_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
+
+if target_os not in ['msys_nt', 'windows']:
+    libcloud_env.PrependUnique(LIBS=['connectivity_abstraction'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+
+if libcloud_env.get('WITH_TCP') == True and libcloud_env.get('WITH_CLOUD') == True:
+    cloud_src = [
+        'auth.c',
+        'cloudresource.c',
+        'utils.c',
+        'crl.c',
+        'aclgroup.c',
+        'aclinvite.c',
+        'aclid.c',
+        'csr.c',
+        'config.c'
+    ]
+    libcloud = libcloud_env.StaticLibrary('cloud', cloud_src, OBJPREFIX='libcloud_')
+    libcloud_env.InstallTarget(libcloud, 'cloud')
index daccfda..519b7d6 100644 (file)
@@ -108,7 +108,7 @@ void fillCallbackData(OCCallbackData *cbData, void *ctx, OCCloudResponseCB cb,
 {
     memset(cbData, 0, sizeof(OCCallbackData));
 
-    ContextInfo_t *info = OICCalloc(1, sizeof(ContextInfo_t));
+    ContextInfo_t *info = (ContextInfo_t *)OICCalloc(1, sizeof(ContextInfo_t));
     if (!info)
     {
         OIC_LOG(ERROR, TAG, "Can't allocate memory for info");
index cc74fb7..f2a16b1 100644 (file)
@@ -40,6 +40,10 @@ target_os = sptest_env.get('TARGET_OS')
 rd_mode = sptest_env.get('RD_MODE')
 out_dir = sptest_env.get('BUILD_DIR')
 
+if target_os not in ['msys_nt', 'windows']:
+    if sptest_env.get('WITH_TCP') == True and sptest_env.get('WITH_CLOUD') == True:
+        sptest_env.PrependUnique(LIBS=['cloud'])
+
 unittest_dir = 'resource/csdk/security/provisioning/unittest/'
 sec_provisioning_src_dir = src_dir + '/resource/csdk/security/provisioning/sample/'
 unittest_build_dir = out_dir + unittest_dir
index d9fcc74..5d0a769 100644 (file)
@@ -32,7 +32,9 @@
 #include "experimental/doxmresource.h"
 #include "pstatresource.h"
 #include "resourcemanager.h"
-
+#if defined(WITH_CLOUD)
+#include "cloud/cloudresource.h"
+#endif
 #define TAG "OIC_SRM_DOS"
 
 /**
@@ -405,6 +407,10 @@ static bool EnterRESET(void)
         isAnonEnabled ? "" : "NOT ");
 #endif // __WITH_DTLS__ or __WITH_TLS__
 
+#if defined(WITH_CLOUD)
+    ResetClouds();
+#endif
+
     ret = true;
 
 exit:
index f0a6f09..8cd4bd6 100644 (file)
@@ -109,5 +109,9 @@ ocprovision_env.UserInstallTargetLib(ocprovision, 'libocprovision')
 ocprovision_env.UserInstallTargetHeader(
     '../include/OCProvisioningManager.hpp', 'resource', 'OCProvisioningManager.hpp')
 
+if target_os not in ['msys_nt', 'windows']:
+    if ocprovision_env.get('WITH_TCP') == True and ocprovision_env.get('WITH_CLOUD') == True:
+        ocprovision_env.PrependUnique(LIBS=['cloud'])
+
 if target_os in ['linux', 'tizen']:
     SConscript('examples/SConscript')
index 586c9e1..2177087 100644 (file)
@@ -103,6 +103,10 @@ if target_os == 'tizen':
 if examples_env.get('MULTIPLE_OWNER') == '1':
     examples_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
 
+if target_os not in ['msys_nt', 'windows']:
+    if examples_env.get('WITH_TCP') == True and examples_env.get('WITH_CLOUD') == True:
+        examples_env.PrependUnique(LIBS=['cloud'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################