IOT-1072 Unfork libcoap: add build flag
authorDaniel Ferguson <daniel.j.ferguson@intel.com>
Fri, 8 Jul 2016 16:43:42 +0000 (09:43 -0700)
committerDave Thaler <dthaler@microsoft.com>
Fri, 16 Sep 2016 21:39:19 +0000 (21:39 +0000)
* Add WITH_UPSTREAM_LIBCOAP command line option for SCons
* Add libcoap downloader, starting on public 'develop' branch
* Move resource\csdk\connectivity\lib\SConscript to extlibs\libcoap
* Restructured forked libcoap to resemble GitHub version, using a
  separate include directory and #include "coap/file.h" where needed
* Modify tizen build scripts
* Note - most platforms will not yet build with WITH_UPSTREAM_LIBCOAP

Change-Id: I51a59701d903adb63ba73e09afd230b9a7fd8696
Signed-off-by: Daniel Ferguson <daniel.j.ferguson@intel.com>
Signed-off-by: David Antler <david.a.antler@intel.com>
Signed-off-by: Ajay Saini <ajay.saini@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9257
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11873

83 files changed:
.gitignore
build_common/SConscript
extlibs/libcoap/SConscript [new file with mode: 0644]
gbsbuild.sh
plugins/src/SConscript
plugins/src/pluginlist.c
plugins/zigbee_wrapper/telegesis_wrapper/include/twsocketlist.h
resource/SConscript
resource/csdk/SConscript
resource/csdk/connectivity/build/tizen/gbsbuild.sh
resource/csdk/connectivity/build/tizen/packaging/com.oic.ca.spec
resource/csdk/connectivity/inc/caadapterutils.h
resource/csdk/connectivity/inc/cablockwisetransfer.h
resource/csdk/connectivity/inc/camessagehandler.h
resource/csdk/connectivity/inc/caprotocolmessage.h
resource/csdk/connectivity/inc/catcpadapter.h
resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript [deleted file]
resource/csdk/connectivity/lib/libcoap-4.1.1/async.c
resource/csdk/connectivity/lib/libcoap-4.1.1/block.c
resource/csdk/connectivity/lib/libcoap-4.1.1/coap_list.c
resource/csdk/connectivity/lib/libcoap-4.1.1/debug.c
resource/csdk/connectivity/lib/libcoap-4.1.1/encode.c
resource/csdk/connectivity/lib/libcoap-4.1.1/hashkey.c
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/address.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/address.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/async.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/async.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/bits.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/bits.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/block.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/block.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/coap.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/coap.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/coap_list.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/coap_list.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/coap_time.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/coap_time.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/config.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/config.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/debug.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/debug.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/encode.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/encode.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/hashkey.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/hashkey.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/mem.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/mem.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/net.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/net.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/option.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/option.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/pdu.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/prng.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/prng.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/resource.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/resource.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/str.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/str.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/subscribe.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/subscribe.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/t_list.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/t_list.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/uri.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/uri.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/uthash.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/uthash.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/include/coap/utlist.h [moved from resource/csdk/connectivity/lib/libcoap-4.1.1/utlist.h with 100% similarity]
resource/csdk/connectivity/lib/libcoap-4.1.1/net.c
resource/csdk/connectivity/lib/libcoap-4.1.1/option.c
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c
resource/csdk/connectivity/lib/libcoap-4.1.1/resource.c
resource/csdk/connectivity/lib/libcoap-4.1.1/str.c
resource/csdk/connectivity/lib/libcoap-4.1.1/subscribe.c
resource/csdk/connectivity/lib/libcoap-4.1.1/uri.c
resource/csdk/connectivity/src/SConscript
resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
resource/csdk/connectivity/src/bt_le_adapter/arduino/cableserver.cpp
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/tcp_adapter/arduino/catcpserver_eth.cpp
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/security/SConscript
resource/csdk/security/include/srmutility.h
resource/csdk/security/provisioning/SConscript
resource/csdk/security/provisioning/ck_manager/sample/SConscript
resource/csdk/security/provisioning/sample/SConscript
resource/csdk/security/provisioning/unittest/SConscript
resource/csdk/security/tool/SConscript
resource/csdk/security/unittest/SConscript
resource/csdk/security/unittest/aclresourcetest.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
resource/csdk/stack/samples/tizen/build/SConscript
resource/csdk/stack/samples/tizen/build/gbsbuild.sh
resource/csdk/stack/samples/tizen/build/packaging/com.oic.ri.spec
resource/csdk/stack/src/occlientcb.c
resource/csdk/stack/src/ocobserve.c
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c
resource/provisioning/SConscript
resource/src/SConscript
run.bat
service/easy-setup/mediator/richsdk/SConscript
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh

index 4f34ee3..03d48b2 100644 (file)
@@ -95,6 +95,7 @@ platform
 iotivity.pc
 
 # Ignore downloaded dependencies
+extlibs/libcoap/libcoap
 extlibs/gtest/gtest-*
 extlibs/hippomocks-master/
 extlibs/master.zip
index b700453..dd4a3a6 100644 (file)
@@ -66,6 +66,8 @@ require_upload = ARGUMENTS.get('UPLOAD', False)
 # Get the device name. This name can be used as network display name wherever possible
 device_name = ARGUMENTS.get('DEVICE_NAME', "OIC-DEVICE")
 
+default_with_upstream_libcoap = 0
+
 if ARGUMENTS.get('TEST'):
        logging_default = False
 else:
@@ -115,6 +117,7 @@ help_vars.AddVariables(('DEVICE_NAME', 'Network display name for device (For Ard
 help_vars.Add(PathVariable('ANDROID_NDK', 'Android NDK path', None, PathVariable.PathAccept))
 help_vars.Add(PathVariable('ANDROID_HOME', 'Android SDK path', None, PathVariable.PathAccept))
 help_vars.Add(PathVariable('ANDROID_GRADLE', 'Gradle binary file', None, PathVariable.PathIsFile))
+help_vars.Add(EnumVariable('WITH_UPSTREAM_LIBCOAP', 'Use latest stable version of LibCoAP downloaded from github', default_with_upstream_libcoap, allowed_values=('0','1')))
 
 AddOption('--prefix',
                   dest='prefix',
diff --git a/extlibs/libcoap/SConscript b/extlibs/libcoap/SConscript
new file mode 100644 (file)
index 0000000..338e650
--- /dev/null
@@ -0,0 +1,162 @@
+################################################################################
+#
+# Copyright 2016 Intel Corporation
+#
+#
+#
+# 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.
+#
+################################################################################
+
+##
+# 'libcoap' script to check if LibCoAP library is installed.  If not,
+# get it and install it
+#
+##
+
+import os
+import glob
+
+Import('env')
+
+libcoap_env = env.Clone()
+target_os = libcoap_env.get('TARGET_OS')
+src_dir = libcoap_env.get('SRC_DIR')
+ca_transport = libcoap_env.get('TARGET_TRANSPORT')
+with_tcp = libcoap_env.get('WITH_TCP')
+with_upstream_libcoap = libcoap_env.get('WITH_UPSTREAM_LIBCOAP')
+
+######################################################################
+# Download libCoAP
+######################################################################
+libcoap_branch           = 'develop'
+libcoap_dir              = os.path.join(src_dir, 'extlibs', 'libcoap', 'libcoap')
+libcoap_zip_file         = os.path.join(src_dir, 'extlibs', 'libcoap', libcoap_branch + '.zip')
+libcoap_repo_url         = 'https://github.com/obgm/libcoap'
+libcoap_url              = libcoap_repo_url + '/archive/' + libcoap_branch + '.zip'
+libcoap_checkout_command = 'git clone ' + libcoap_repo_url + '.git extlibs/libcoap/libcoap --branch ' + libcoap_branch
+
+if with_upstream_libcoap == '1':
+    print '*** Checking for installation of libCoAP ***'
+    if not os.path.exists(libcoap_dir):
+        # If the libcoap zip file is not already present, download it
+        if not os.path.exists(libcoap_zip_file):
+            libcoap_zip = libcoap_env.Download(libcoap_zip_file, libcoap_url)
+        else:
+            libcoap_zip = libcoap_zip_file
+        # Unzip libcoap
+        if libcoap_zip and not os.path.exists(os.path.join(libcoap_dir, 'configure')):
+            print 'Unzipping libCoAP'
+            env.UnpackAll(libcoap_dir, libcoap_zip)
+        # Rename libcoap
+        libcoap_unzip_dir = os.path.join(src_dir, 'extlibs', 'libcoap', 'libcoap-' + libcoap_branch)
+        if os.path.exists(os.path.join(libcoap_unzip_dir)):
+            os.rename(libcoap_unzip_dir, libcoap_dir)
+        if not os.path.exists(os.path.join(libcoap_dir, 'README')):
+            print '''
+*********************************** Error: ****************************************
+* Unable to download and unpack libcoap!                                          *
+* Please download libcoap using the following command:                            *
+*                                                                                 *
+''' + libcoap_checkout_command + '''
+*                                                                                 *
+***********************************************************************************'''
+            Exit()
+else:
+    print '''
+*********************************** Info: *****************************************
+* Using FORKED copy of libCoap located in:                                        *
+* resource/csdk/connectivity/lib/libcoap-4.1.1                                    *
+***********************************************************************************'''
+
+######################################################################
+# Build libCoAP
+######################################################################
+# As in the source code(C) includes arduino Time library head file(C++)
+# It requires compile the .c with g++
+if target_os == 'arduino':
+    libcoap_env.Replace(CFLAGS = libcoap_env.get('CXXFLAGS'))
+    libcoap_env.PrependUnique(CPPPATH = [
+        './',
+        env.get('ARDUINO_HOME') + '/',
+        env.get('ARDUINO_HOME') + '/hardware/arduino/avr/cores/arduino',
+        env.get('ARDUINO_HOME') + '/hardware/tools/avr/avr/include/',
+        env.get('ARDUINO_HOME') + '/hardware/arduino/avr/variants/mega',
+        env.get('ARDUINO_HOME') + '/libraries/Time/Time',
+        env.get('ARDUINO_HOME') + '/libraries/TimedAction',
+        env.get('ARDUINO_HOME') + '/hardware/arduino/avr/libraries/SPI',
+        env.get('ARDUINO_HOME') + '/libraries/Ethernet/src/utility',
+        ])
+
+# Build flags
+if target_os not in ['arduino', 'windows', 'winrt', 'msys_nt']:
+    libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_DEFAULT_SOURCE'])
+    libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99','-fPIC'])
+
+if target_os not in ['windows', 'winrt']:
+    libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
+            '-fdata-sections', '-fno-exceptions'])
+
+if target_os == 'msys_nt':
+    libcoap_env.AppendUnique(CPPDEFINES = ['_DEFAULT_SOURCE'])
+    libcoap_env.AppendUnique(CFLAGS = ['-std=c99'])
+
+if target_os in ['linux', 'tizen', 'android', 'ios', 'arduino']:
+    if with_tcp == True:
+        libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
+
+if target_os in ['linux', 'tizen', 'android', 'arduino']:
+    libcoap_env.AppendUnique(LIBS = ['log'])
+    if (('BLE' in ca_transport) or ('BT' in ca_transport) or ('ALL' in ca_transport)):
+        libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
+
+if target_os == 'arduino':
+    libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
+
+if target_os in ['darwin', 'ios']:
+    libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+
+if env.get('LOGGING') == '1':
+    libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+
+######################################################################
+# Source files and Target(s)
+######################################################################
+with_upstream_libcoap = libcoap_env.get('WITH_UPSTREAM_LIBCOAP')
+if with_upstream_libcoap == '1':
+    libcoap_env.AppendUnique(CPPDEFINES = ['WITH_UPSTREAM_LIBCOAP'])
+    libcoap_src_root = os.path.join(libcoap_dir, 'src')
+
+    # We need to generate coap.h from coap.h.in
+    coap_h_pc_file = os.path.join(libcoap_dir, 'include', 'coap', 'coap.h.in')
+    coap_h_output  = os.path.join(libcoap_dir, 'include', 'coap', 'coap.h')
+
+    libcoap_version = libcoap_branch
+    lib_prefix = '' + str(libcoap_env.get('PREFIX'))
+    pc_vars = {
+        '\@LIBCOAP_PACKAGE_NAME\@'          : lib_prefix + 'coap',
+        '\@LIBCOAP_PACKAGE_STRING\@'        : lib_prefix + 'coap-' + libcoap_version,
+        '\@LIBCOAP_PACKAGE_URL\@'           : libcoap_repo_url,
+        '\@LIBCOAP_PACKAGE_BUGREPORT\@'     : libcoap_repo_url + '/issues',
+        '\@LIBCOAP_PACKAGE_VERSION\@'       : libcoap_version
+        }
+    libcoap_env.Substfile(coap_h_pc_file, SUBST_DICT = pc_vars)
+else:
+    # For bring up purposes only, the forked version will live here.
+    libcoap_src_root = src_dir + '/resource/csdk/connectivity/lib/libcoap-4.1.1'
+
+libcoap_src = glob.glob(os.path.join(libcoap_src_root, '*.c'))
+libcoap = libcoap_env.StaticLibrary('coap', libcoap_src, OBJPREFIX='libcoap_')
+
+libcoap_env.InstallTarget([libcoap], 'coap')
+
index 633a286..72ef981 100755 (executable)
@@ -36,6 +36,7 @@ cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
+cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs
 cp -R ./resource $sourcedir/tmp
 cp -R ./service $sourcedir/tmp
 cp ./extra_options.scons $sourcedir/tmp
index a586483..1cca407 100644 (file)
@@ -34,14 +34,20 @@ print"Reading PI script"
 ######################################################################
 # Build flags
 ######################################################################
+with_unforked_libcoap = env.get('WITH_UNFORKED_LIBCOAP')
+if with_unforked_libcoap == '1':
+    # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
+    env.PrependUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+    # For bring up purposes only, the forked version will live here.
+    env.PrependUnique(CPPPATH = [os.path.join(src_dir, 'resource', 'csdk', 'connectivity', 'lib', 'libcoap-4.1.1', 'include')])
 
 env.PrependUnique(CPPPATH = [ os.path.join(src_dir, 'resource', 'c_common', 'oic_malloc', 'include'),
                               os.path.join(src_dir, 'resource', 'c_common', 'oic_string', 'include'),
                               os.path.join(src_dir, 'resource', 'c_common', 'oic_time', 'include'),
                               os.path.join(src_dir, 'resource', 'oc_logger', 'include'),
                               os.path.join(src_dir, 'resource', 'csdk', 'logger', 'include'),
-                              os.path.join(src_dir, 'resource', 'csdk', 'stack', 'include'),
-                              os.path.join(src_dir, 'resource', 'csdk', 'connectivity', 'lib', 'libcoap-4.1.1')
+                              os.path.join(src_dir, 'resource', 'csdk', 'stack', 'include')
                             ])
 env.AppendUnique(CPPPATH = [ os.path.join(pi_path, 'include'),
                              os.path.join(pi_path, 'include', 'internal'),
index 01c7adc..2b5b661 100644 (file)
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include "zigbee_wrapper.h"
-#include "utlist.h"
+#include <coap/utlist.h>
 #include "oic_malloc.h"
 #include "oic_string.h"
 #include "ocstack.h"
index 6b4092f..ebd6bc7 100644 (file)
@@ -36,7 +36,8 @@ extern "C" {
 
 #include "plugintypes.h"
 #include "telegesis_socket.h"
-#include "utlist.h"
+
+#include <coap/utlist.h>
 
 // TODO: Use OICThread instead of pthread directly.
 // TODO: Use OICMutex instead of mutex directly.
index e3f217e..decd536 100644 (file)
@@ -34,8 +34,8 @@ SConscript('csdk/logger/SConscript')
 if target_os not in ['arduino', 'darwin', 'ios', 'android', 'msys_nt', 'windows']:
        env.AppendUnique(LIBS=['rt'])
 
-# Build libcoap
-SConscript('csdk/connectivity/lib/libcoap-4.1.1/SConscript')
+# Download (if not already present) & build libcoap
+SConscript('#extlibs/libcoap/SConscript')
 
 # Build C Common dependencies
 SConscript('c_common/SConscript')
index 1d17c0e..afcfe76 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',
index d7c12a6..2376dac 100755 (executable)
@@ -42,19 +42,21 @@ echo `pwd`
 rm -rf ./tmp
 mkdir ./tmp
 mkdir ./tmp/con/
+mkdir -p $sourcedir/tmp/con/extlibs/
+
 cp -R $cur_dir/* $sourcedir/tmp/con
 cp -R $cur_dir/SConscript $sourcedir/tmp/con
 cp -R $cur_dir/src/ip_adapter/SConscript $sourcedir/tmp/con/src/ip_adapter/
 cp -R $cur_dir/src/bt_le_adapter/SConscript $sourcedir/tmp/con/src/bt_le_adapter/
 cp -R $cur_dir/src/bt_edr_adapter/SConscript $sourcedir/tmp/con/src/bt_edr_adapter/
 cp -R $cur_dir/common/SConscript $sourcedir/tmp/con/common/
-cp -R $cur_dir/lib/libcoap-4.1.1/SConscript $sourcedir/tmp/con/lib/libcoap-4.1.1/
 cp -R $cur_dir/samples/tizen/ $sourcedir/tmp/con/sample/
 mkdir -p $sourcedir/tmp/con/sample/external/inc
 cp -R $cur_dir/external/inc/* $sourcedir/tmp/con/sample/external/inc/
-mkdir -p $sourcedir/tmp/con/extlibs/
+
 cp -R ./extlibs/tinydtls/ $sourcedir/tmp/con/extlibs/
 cp -R ./extlibs/timer/ $sourcedir/tmp/con/extlibs/
+cp -R ./extlibs/libcoap/ $sourcedir/tmp/con/extlibs/
 mkdir -p $sourcedir/tmp/con/c_common
 cp -R ./resource/c_common/* $sourcedir/tmp/con/c_common/
 cp -R ./resource/csdk/logger/include/* $sourcedir/tmp/con/common/inc/
index 1fd3468..11e7823 100644 (file)
@@ -44,7 +44,7 @@ mkdir -p %{DEST_INC_DIR}
 mkdir -p %{DEST_LIB_DIR}/pkgconfig
 
 cp -f %{ROOTDIR}/con/src/libconnectivity_abstraction.so %{buildroot}/%{_libdir}
-cp -f %{ROOTDIR}/con/lib/libcoap-4.1.1/libcoap.a %{buildroot}/%{_libdir}
+cp -f %{ROOTDIR}/extlibs/libcoap/libcoap.a %{buildroot}/%{_libdir}
 if echo %{SECURED}|grep -qi '1'; then
        cp -f %{ROOTDIR}/con/extlibs/tinydtls/libtinydtls.a %{buildroot}/%{_libdir}
 fi
index 5c2dcc7..1f2d113 100644 (file)
@@ -48,7 +48,7 @@
 
 #include "cacommon.h"
 #include "logger.h"
-#include "pdu.h"
+#include <coap/pdu.h>
 #include "uarraylist.h"
 #include "cacommonutil.h"
 
index 51677e6..39c4d7f 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <stdint.h>
 
-#include "coap.h"
+#include <coap/coap.h>
 #include "cathreadpool.h"
 #include "camutex.h"
 #include "uarraylist.h"
index 5a70271..5596039 100644 (file)
@@ -27,7 +27,7 @@
 #define CA_MESSAGE_HANDLER_H_
 
 #include "cacommon.h"
-#include "coap.h"
+#include <coap/coap.h>
 
 #define CA_MEMORY_ALLOC_CHECK(arg) { if (NULL == arg) {OIC_LOG(ERROR, TAG, "Out of memory"); \
 goto memory_error_exit;} }
index b752a4d..4323120 100644 (file)
 #define CA_PROTOCOL_MESSAGE_H_
 
 #include "cacommon.h"
-#include "config.h"
-#include "coap.h"
+#ifndef WITH_UPSTREAM_LIBCOAP
+#include "coap/config.h"
+#endif
+#include <coap/coap.h>
 
 #ifdef __cplusplus
 extern "C"
index da1a91d..f258711 100644 (file)
@@ -29,7 +29,7 @@
 #include "caadapterinterface.h"
 #include "cathreadpool.h"
 #include "cainterface.h"
-#include "pdu.h"
+#include <coap/pdu.h>
 
 #ifdef __cplusplus
 extern "C"
diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript b/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript
deleted file mode 100644 (file)
index b47c835..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-##
-# libcoap (share library) build script
-##
-
-Import('env')
-
-libcoap_env = env.Clone()
-
-target_os = env.get('TARGET_OS')
-ca_transport = env.get('TARGET_TRANSPORT')
-with_tcp = env.get('WITH_TCP')
-# As in the source code(C) includes arduino Time library head file(C++)
-# It requires compile the .c with g++
-if target_os == 'arduino':
-       libcoap_env.Replace(CFLAGS = env.get('CXXFLAGS'))
-
-######################################################################
-# Build flags
-######################################################################
-       libcoap_env.PrependUnique(CPPPATH = [
-               './',
-               env.get('ARDUINO_HOME')+'/',
-               env.get('ARDUINO_HOME')+'/hardware/arduino/avr/cores/arduino',
-               env.get('ARDUINO_HOME')+'/hardware/tools/avr/avr/include/',
-               env.get('ARDUINO_HOME')+'/hardware/arduino/avr/variants/mega',
-               env.get('ARDUINO_HOME')+'/libraries/Time/Time',
-               env.get('ARDUINO_HOME')+'/libraries/TimedAction',
-               env.get('ARDUINO_HOME')+'/hardware/arduino/avr/libraries/SPI',
-               env.get('ARDUINO_HOME')+'/libraries/Ethernet/src/utility',
-               ])
-
-if target_os not in ['arduino', 'windows', 'msys_nt']:
-       libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '_DEFAULT_SOURCE'])
-       libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99','-fPIC'])
-
-if target_os not in ['windows']:
-       libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
-                       '-fdata-sections', '-fno-exceptions'])
-
-if target_os == 'msys_nt':
-       libcoap_env.AppendUnique(CPPDEFINES = ['_DEFAULT_SOURCE'])
-       libcoap_env.AppendUnique(CFLAGS = ['-std=c99'])
-
-if target_os in ['linux', 'tizen', 'android', 'ios', 'arduino']:
-       if with_tcp == True:
-               libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
-
-if target_os in ['linux', 'tizen', 'android', 'arduino']:
-       libcoap_env.AppendUnique(LIBS = ['log'])
-       if (('BLE' in ca_transport) or ('BT' in ca_transport) or ('ALL' in ca_transport)):
-               libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
-
-if target_os == 'arduino':
-       libcoap_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
-
-if target_os in ['darwin', 'ios']:
-       libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
-
-if env.get('LOGGING'):
-       libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
-
-######################################################################
-# Source files and Target(s)
-######################################################################
-libcoap_src = [
-       'pdu.c',
-       'net.c',
-       'debug.c',
-       'encode.c',
-       'uri.c',
-       'coap_list.c',
-       'resource.c',
-       'hashkey.c',
-       'str.c',
-       'option.c',
-       'async.c',
-       'subscribe.c',
-       'block.c'
-       ]
-
-libcoap = libcoap_env.StaticLibrary('coap', libcoap_src, OBJPREFIX='libcoap_')
-
-libcoap_env.InstallTarget([libcoap], 'coap')
index 5bf5d95..236d0c4 100644 (file)
 
 #ifndef WITHOUT_ASYNC
 
-#include "config.h"
-
-#include "utlist.h"
-
-#include "mem.h"
-#include "debug.h"
-#include "async.h"
+#include "include/coap/config.h"
+#include "include/coap/utlist.h"
+#include "include/coap/mem.h"
+#include "include/coap/debug.h"
+#include "include/coap/async.h"
 
 coap_async_state_t *
 coap_register_async(coap_context_t *context, coap_address_t *peer, coap_pdu_t *request,
index de83a62..f431689 100644 (file)
@@ -6,7 +6,7 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #if defined(HAVE_ASSERT_H) && !defined(assert)
 # include <assert.h>
@@ -17,8 +17,8 @@
 #include <stdlib.h>
 #endif
 
-#include "debug.h"
-#include "block.h"
+#include "include/coap/debug.h"
+#include "include/coap/block.h"
 
 #define min(a,b) ((a) < (b) ? (a) : (b))
 
index 73f1595..e95c178 100644 (file)
@@ -6,14 +6,14 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #include <stdio.h>
 #include <string.h>
 
-#include "debug.h"
-#include "mem.h"
-#include "coap_list.h"
+#include "include/coap/debug.h"
+#include "include/coap/mem.h"
+#include "include/coap/coap_list.h"
 
 int coap_insert(coap_list_t **queue, coap_list_t *node, int (*order)(void *, void *node))
 {
index fc4f1da..2970459 100644 (file)
@@ -6,7 +6,7 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #if defined(HAVE_ASSERT_H) && !defined(assert)
 # include <assert.h>
@@ -25,8 +25,8 @@
 #include <time.h>
 #endif
 
-#include "debug.h"
-#include "net.h"
+#include "include/coap/debug.h"
+#include "include/coap/net.h"
 
 #ifdef WITH_CONTIKI
 # ifndef DEBUG
index a310008..3569bc2 100644 (file)
@@ -6,7 +6,7 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #if defined(HAVE_ASSERT_H) && !defined(assert)
 # include <assert.h>
@@ -16,9 +16,8 @@
 #  include <stdio.h>
 #endif
 
-#include "config.h"
-#include "encode.h"
-#include "option.h"
+#include "include/coap/encode.h"
+#include "include/coap/option.h"
 
 /* Carsten suggested this when fls() is not available: */
 int coap_fls(unsigned int i)
index 30447e6..129147b 100644 (file)
@@ -6,7 +6,7 @@
  * README for terms of use.
  */
 
-#include "hashkey.h"
+#include "include/coap/hashkey.h"
 
 /* Caution: When changing this, update COAP_DEFAULT_WKC_HASHKEY
  * accordingly (see int coap_hash_path());
index 48e0455..e81acae 100644 (file)
@@ -6,7 +6,7 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #include <ctype.h>
 #include <stdio.h>
 #include <lwip/timers.h>
 #endif
 
-#include "debug.h"
-#include "mem.h"
-#include "str.h"
-#include "async.h"
-#include "resource.h"
-#include "option.h"
-#include "encode.h"
-#include "block.h"
-#include "net.h"
+#include "include/coap/debug.h"
+#include "include/coap/mem.h"
+#include "include/coap/str.h"
+#include "include/coap/async.h"
+#include "include/coap/resource.h"
+#include "include/coap/option.h"
+#include "include/coap/encode.h"
+#include "include/coap/block.h"
+#include "include/coap/net.h"
 
 #if defined(WITH_POSIX) || defined(WITH_ARDUINO) || defined(_WIN32)
 
index 60bb865..f4ec497 100644 (file)
@@ -7,7 +7,7 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #if defined(HAVE_ASSERT_H) && !defined(assert)
 # include <assert.h>
@@ -16,9 +16,9 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "option.h"
-#include "debug.h"
-#include "pdu.h"
+#include "include/coap/option.h"
+#include "include/coap/debug.h"
+#include "include/coap/pdu.h"
 
 coap_opt_t *
 options_start(coap_pdu_t *pdu, coap_transport_type transport)
index dec32b5..6e869c3 100644 (file)
@@ -6,7 +6,7 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #if defined(HAVE_ASSERT_H) && !defined(assert)
 # include <assert.h>
 #include <winsock2.h>
 #endif
 
-#include "debug.h"
-#include "pdu.h"
-#include "option.h"
-#include "encode.h"
+#include "include/coap/debug.h"
+#include "include/coap/pdu.h"
+#include "include/coap/option.h"
+#include "include/coap/encode.h"
 
 #ifdef WITH_ARDUINO
 #include "util.h"
@@ -47,7 +47,7 @@ coap_pdu_resources_init()
     memb_init(&pdu_storage);
 }
 #else /* WITH_CONTIKI */
-#include "mem.h"
+#include "include/coap/mem.h"
 #endif /* WITH_CONTIKI */
 
 void coap_pdu_clear(coap_pdu_t *pdu, size_t size, coap_transport_type transport, unsigned int length)
@@ -283,7 +283,7 @@ coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size)
     {
         return coap_tcp_16bit;
     }
-    else //if (size - COAP_TCP_LENGTH_FIELD_32_BIT < ULONG_MAX) always true due to range of data types
+    else
     {
         return coap_tcp_32bit;
     }
index 3af2f0c..cc00899 100644 (file)
@@ -6,19 +6,19 @@
  * README for terms of use.
  */
 
-#include "config.h"
-#include "net.h"
-#include "debug.h"
-#include "resource.h"
-#include "subscribe.h"
+#include "include/coap/config.h"
+#include "include/coap/net.h"
+#include "include/coap/debug.h"
+#include "include/coap/resource.h"
+#include "include/coap/subscribe.h"
 
 #ifdef WITH_LWIP
-#include "utlist.h"
+#include "include/coap/utlist.h"
 /* mem.h is only needed for the string free calls for
  * COAP_ATTR_FLAGS_RELEASE_NAME / COAP_ATTR_FLAGS_RELEASE_VALUE /
  * COAP_RESOURCE_FLAGS_RELEASE_URI. not sure what those lines should actually
  * do on lwip. */
-#include "mem.h"
+#include "include/coap/mem.h"
 
 #include <lwip/memp.h>
 
@@ -28,8 +28,8 @@
 
 #endif
 #if defined(WITH_POSIX) || defined(WITH_ARDUINO) || defined(_WIN32)
-#include "utlist.h"
-#include "mem.h"
+#include "include/coap/utlist.h"
+#include "include/coap/mem.h"
 
 #define COAP_MALLOC_TYPE(Type) \
   ((coap_##Type##_t *)coap_malloc(sizeof(coap_##Type##_t)))
index 950803d..c615456 100644 (file)
@@ -6,13 +6,13 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #include <stdio.h>
 
-#include "debug.h"
-#include "mem.h"
-#include "str.h"
+#include "include/coap/debug.h"
+#include "include/coap/mem.h"
+#include "include/coap/str.h"
 
 str *coap_new_string(size_t size)
 {
index f168d96..9ff35ad 100644 (file)
@@ -7,7 +7,7 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #if defined(HAVE_ASSERT_H) && !defined(assert)
 # include <assert.h>
 
 /* #include "resource.h" */
 
-#include "mem.h"
-#include "encode.h"
-#include "debug.h"
-#include "subscribe.h"
+#include "include/coap/mem.h"
+#include "include/coap/encode.h"
+#include "include/coap/debug.h"
+#include "include/coap/subscribe.h"
 
 void coap_subscription_init(coap_subscription_t *s)
 {
index d496e72..5e70b81 100644 (file)
@@ -6,7 +6,7 @@
  * README for terms of use.
  */
 
-#include "config.h"
+#include "include/coap/config.h"
 
 #if defined(HAVE_ASSERT_H) && !defined(assert)
 # include <assert.h>
 #include <string.h>
 #include <ctype.h>
 
-#include "mem.h"
-#include "debug.h"
-#include "pdu.h"
-#include "option.h"
-#include "uri.h"
+#include "include/coap/mem.h"
+#include "include/coap/debug.h"
+#include "include/coap/pdu.h"
+#include "include/coap/option.h"
+#include "include/coap/uri.h"
 /**
  * A length-safe version of strchr(). This function returns a pointer
  * to the first occurrence of @p c  in @p s, or @c NULL if not found.
index c305735..05db21b 100644 (file)
@@ -1,7 +1,6 @@
 ##
 # CA build script
 ##
-
 import os.path
 
 Import('env')
@@ -23,8 +22,16 @@ ca_path = os.curdir
 print"Reading ca script %s"%ca_transport
 
 env.PrependUnique(CPPPATH = [ os.path.join(root_dir, 'api') ])
+
+with_upstream_libcoap = 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.
+       env.AppendUnique(CPPPATH = [os.path.join('#extlibs', 'libcoap', 'libcoap', 'include')])
+else:
+       # For bring up purposes only, the forked version will live here.
+       env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'lib', 'libcoap-4.1.1', 'include')])
+
 env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
-                             os.path.join(root_dir, 'lib', 'libcoap-4.1.1'),
                              os.path.join(src_dir, 'resource', 'csdk', 'logger', 'include'),
                              os.path.join(root_dir, 'common', 'inc'),
                              os.path.join(root_dir, 'util', 'inc') ])
index 97d282a..a905e2f 100644 (file)
@@ -32,7 +32,7 @@
 #include "caqueueingthread.h"
 #include "oic_malloc.h"
 #include "caremotehandler.h"
-#include "pdu.h"
+#include <coap/pdu.h>
 
 /**
  * Logging tag for module name.
index 1672e63..0eb0ed6 100644 (file)
@@ -29,7 +29,7 @@
 #include <boards.h>
 #include <RBL_nRF8001.h>
 
-#include "pdu.h"
+#include <coap/pdu.h>
 #include "caleinterface.h"
 #include "oic_malloc.h"
 #include "caadapterutils.h"
index b1d19be..e96e5a1 100644 (file)
@@ -38,7 +38,7 @@
 #include "oic_malloc.h"
 #include "oic_string.h"
 #include "caremotehandler.h"
-#include "pdu.h"
+#include <coap/pdu.h>
 
 /**
  * Logging tag for module name.
index 5f21a2e..ba1106a 100644 (file)
@@ -28,7 +28,9 @@
 #include "caremotehandler.h"
 #include "caprotocolmessage.h"
 #include "logger.h"
-#include "config.h" /* for coap protocol */
+#ifndef WITH_UPSTREAM_LIBCOAP
+#include "coap/config.h"
+#endif
 #include "oic_malloc.h"
 #include "canetworkconfigurator.h"
 #include "caadapterutils.h"
index 1cca9fe..722524f 100644 (file)
@@ -57,7 +57,7 @@
 #include <linux/rtnetlink.h>
 #endif
 
-#include "pdu.h"
+#include <coap/pdu.h>
 #include "caipinterface.h"
 #include "caadapterutils.h"
 #ifdef __WITH_DTLS__
index b290eb3..77fd1ae 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "catcpadapterutils_eth.h"
 #include "catcpinterface.h"
-#include "pdu.h"
+#include <coap/pdu.h>
 #include "caadapterutils.h"
 #include "camutex.h"
 #include "oic_malloc.h"
index 74818a0..42fa112 100644 (file)
@@ -38,7 +38,7 @@
 #endif
 
 #include "catcpinterface.h"
-#include "pdu.h"
+#include <coap/pdu.h>
 #include "caadapterutils.h"
 #include "camutex.h"
 #include "oic_malloc.h"
index d288790..f878587 100644 (file)
@@ -29,16 +29,24 @@ SConscript('#resource/third_party_libs.scons', 'lib_env')
 
 libocsrm_env = lib_env.Clone()
 
-target_os = env.get('TARGET_OS')
+target_os = libocsrm_env.get('TARGET_OS')
 # As in the source code, it includes arduino Time library (C++)
 # It requires compile the .c with g++
 if target_os == 'arduino':
-       libocsrm_env.Replace(CC = env.get('CXX'))
-       libocsrm_env.Replace(CFLAGS = env.get('CXXFLAGS'))
+       libocsrm_env.Replace(CC = libocsrm_env.get('CXX'))
+       libocsrm_env.Replace(CFLAGS = libocsrm_env.get('CXXFLAGS'))
 
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = libocsrm_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.
+       libocsrm_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       libocsrm_env.AppendUnique(CPPPATH = ['../connectivity/lib/libcoap-4.1.1/include'])
+
 libocsrm_env.PrependUnique(CPPPATH = [
                '../../../extlibs/cjson/',
                '../../../extlibs/tinydtls/',
@@ -47,7 +55,6 @@ libocsrm_env.PrependUnique(CPPPATH = [
                '../stack/include',
                '../stack/include/internal',
                '../../oc_logger/include',
-               '../connectivity/lib/libcoap-4.1.1',
                '../connectivity/external/inc',
                '../connectivity/common/inc',
                '../connectivity/inc/pkix',
@@ -62,7 +69,7 @@ if target_os not in ['arduino', 'windows']:
        libocsrm_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX', '_GNU_SOURCE'])
        libocsrm_env.AppendUnique(CFLAGS = ['-std=c99', '-Wall'])
 
-libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+libocsrm_env.AppendUnique(LIBPATH = [libocsrm_env.get('BUILD_DIR')])
 libocsrm_env.AppendUnique(LIBS = ['coap'])
 
 if target_os == 'arduino':
@@ -72,11 +79,11 @@ elif target_os not in ['windows', 'msys_nt']:
        libocsrm_env.AppendUnique(LIBS = ['m'])
 
 if target_os in ['windows', 'msys_nt']:
-       libocsrm_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'oc_logger')])
+       libocsrm_env.AppendUnique(LIBPATH = [os.path.join(libocsrm_env.get('BUILD_DIR'), 'resource', 'oc_logger')])
 
 if target_os in ['darwin', 'ios']:
        libocsrm_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
-       libocsrm_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+       libocsrm_env.AppendUnique(LIBPATH = [libocsrm_env.get('BUILD_DIR')])
        libocsrm_env.AppendUnique(LIBS = ['coap'])
 
 if env.get('LOGGING'):
@@ -129,8 +136,8 @@ libocsrm = libocsrm_env.StaticLibrary('ocsrm', libocsrm_src)
 
 libocsrm_env.InstallTarget(libocsrm, 'ocsrm')
 
-if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and env.get('SECURED') == '1':
+if target_os in ['linux', 'android', 'tizen', 'msys_nt', 'windows'] and libocsrm_env.get('SECURED') == '1':
        SConscript('provisioning/SConscript')
 
-if target_os in ['linux'] and env.get('SECURED') == '1':
+if target_os in ['linux'] and libocsrm_env.get('SECURED') == '1':
        SConscript('tool/SConscript')
index 4e6c02a..bcf5ea8 100644 (file)
@@ -28,7 +28,7 @@
 extern "C"
 {
 #endif
-#include "uri.h"
+#include <coap/uri.h>
 #ifdef __cplusplus
 }
 #endif
index 68a68ab..593a6c4 100644 (file)
@@ -27,6 +27,14 @@ root_dir = './../../../../'
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = provisioning_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.
+       provisioning_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       provisioning_env.AppendUnique(CPPPATH = ['../../connectivity/lib/libcoap-4.1.1/include'])
+
 provisioning_env.AppendUnique(CPPPATH = [
                '../../stack/include',
                '../../stack/include/internal',
@@ -45,7 +53,6 @@ provisioning_env.AppendUnique(CPPPATH = [
                '../../connectivity/inc/pkix',
                '../../connectivity/external/inc',
                '../../connectivity/common/inc',
-               '../../connectivity/lib/libcoap-4.1.1',
                '../../connectivity/api',
                '../include',
                '../include/internal',
index 2512f98..71e938f 100644 (file)
@@ -27,6 +27,14 @@ provisioning_env = env.Clone()
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = provisioning_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.
+       provisioning_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       provisioning_env.AppendUnique(CPPPATH = ['../../../../connectivity/lib/libcoap-4.1.1/include'])
+
 provisioning_env.AppendUnique(CPPPATH = [
                '../../../../stack/include',
                '../../../../../c_common/ocrandom/include',
@@ -45,7 +53,6 @@ provisioning_env.AppendUnique(CPPPATH = [
                '../../../../connectivity/inc',
                '../../../../connectivity/inc/pkix/',
                '../../../../connectivity/common/inc',
-               '../../../../connectivity/lib/libcoap-4.1.1',
                '../../../../connectivity/api',
                '../../../../../c_common/oic_malloc/include',
                '../include',
index 34b58d4..fc7005e 100644 (file)
@@ -28,6 +28,14 @@ target_os = provisioning_env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = provisioning_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.
+       provisioning_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       provisioning_env.AppendUnique(CPPPATH = ['../../../connectivity/lib/libcoap-4.1.1/include'])
+
 provisioning_env.AppendUnique(CPPPATH = [
                '../../../stack/include',
                '../../../ocrandom/include',
@@ -47,7 +55,6 @@ provisioning_env.AppendUnique(CPPPATH = [
                '../../../connectivity/inc',
                '../../../connectivity/inc/pkix',
                '../../../connectivity/common/inc',
-               '../../../connectivity/lib/libcoap-4.1.1',
                '../../../connectivity/api',
                'cloud'
                ])
index b1d9412..7818df5 100644 (file)
@@ -30,6 +30,14 @@ target_os = sptest_env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = sptest_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.
+       sptest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       sptest_env.AppendUnique(CPPPATH = ['../../../connectivity/lib/libcoap-4.1.1/include'])
+
 sptest_env.PrependUnique(CPPPATH = [
                '../include',
                '../../include',
@@ -49,7 +57,6 @@ sptest_env.PrependUnique(CPPPATH = [
                '../../../connectivity/inc',
                '../../../connectivity/inc/pkix',
                '../../../connectivity/common/inc',
-               '../../../connectivity/lib/libcoap-4.1.1',
                '../../../connectivity/api',
                '../../../../../extlibs/tinydtls'
                ])
index 6c3c995..871e7a9 100644 (file)
@@ -26,6 +26,14 @@ src_dir = tools_env.get('SRC_DIR')
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = tools_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.
+    tools_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+    # For bring up purposes only, the forked version will live here.
+    tools_env.AppendUnique(CPPPATH = ['../../connectivity/lib/libcoap-4.1.1/include'])
+
 tools_env.PrependUnique(CPPPATH = ['../../../../extlibs/cjson',
                                   '../../stack/include',
                                   '../../stack/include/internal',
@@ -34,13 +42,11 @@ tools_env.PrependUnique(CPPPATH = ['../../../../extlibs/cjson',
                                   '../../connectivity/api',
                                   '../../connectivity/inc/pkix',
                                   '../include',
-                                  '../include/internal',
-                                  '../../connectivity/lib/libcoap-4.1.1',
-
+                                  '../include/internal'
                                   ])
 tools_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-Wextra', '-std=c++0x'])
-tools_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-tools_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
+tools_env.AppendUnique(LIBPATH = [tools_env.get('BUILD_DIR')])
+tools_env.AppendUnique(RPATH = [tools_env.get('BUILD_DIR')])
 tools_env.PrependUnique(LIBS = ['oc', 'octbstack'])
 
 ######################################################################
index 3e4c594..a2399b0 100644 (file)
@@ -30,13 +30,20 @@ target_os = srmtest_env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = srmtest_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.
+       srmtest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       srmtest_env.AppendUnique(CPPPATH = ['../../connectivity/lib/libcoap-4.1.1/include'])
+
 srmtest_env.PrependUnique(CPPPATH = [
                '../../../c_common/oic_malloc/include',
                '../../connectivity/inc',
                '../../connectivity/inc/pkix',
                '../../connectivity/api',
                '../../connectivity/external/inc',
-               '../../connectivity/lib/libcoap-4.1.1',
                '../include/internal',
                '../../logger/include',
                '../../stack/include',
index dbf4cb8..c20e297 100644 (file)
@@ -19,7 +19,7 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 #include "gtest/gtest.h"
-#include "utlist.h"
+#include <coap/utlist.h>
 #include <sys/stat.h>
 #include "ocstack.h"
 #include "psinterface.h"
index bfa9bda..9b52f2d 100644 (file)
@@ -26,13 +26,20 @@ with_ra = samples_env.get ('WITH_RA')
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = samples_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.
+       samples_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       samples_env.AppendUnique(CPPPATH = ['../../../../../connectivity/lib/libcoap-4.1.1/include'])
+
 samples_env.PrependUnique(CPPPATH = [
                '../../../../logger/include',
                '../../../../stack/include',
                '../../../../../../extlibs/cjson',
                '../../../../../../extlibs/boost/boost',
                '../../../../../oc_logger/include',
-               '../../../../../connectivity/lib/libcoap-4.1.1'
                ])
 
 compiler = samples_env.get('CXX')
index 9a2c022..3f4efc8 100644 (file)
@@ -16,12 +16,19 @@ routing = env.get('ROUTING')
 with_proxy = env.get('WITH_PROXY')
 with_tcp = env.get('WITH_TCP')
 
+with_upstream_libcoap = 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.
+       env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       env.AppendUnique(CPPPATH = ['../../../../connectivity/lib/libcoap-4.1.1'])
+
 env.PrependUnique(CPPPATH = [
                '../../../../logger/include',
                '../../../../stack/include',
                '../../../../../../extlibs/cjson',
-               '../../../../../oc_logger/include',
-               '../../../../../connectivity/lib/libcoap-4.1.1'
+               '../../../../../oc_logger/include'
                ])
 
 env.AppendUnique(CPPDEFINES = ['TB_LOG'])
index d0b488f..1e288fc 100644 (file)
@@ -52,6 +52,7 @@ cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
 cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
+cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs
 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
 cp -R ./resource/csdk/stack/samples/tizen/build/packaging/*.spec $sourcedir/tmp/packaging
 cp -R ./resource $sourcedir/tmp/
index ea8f03f..0171d1a 100644 (file)
@@ -47,7 +47,7 @@ cp -f %{ROOTDIR}/resource/csdk/liboctbstack.so %{buildroot}/%{_libdir}
 cp -f %{ROOTDIR}/resource/c_common/libc_common.a %{buildroot}/%{_libdir}
 cp -f %{ROOTDIR}/resource/csdk/security/libocsrm.a %{buildroot}/%{_libdir}
 cp -f %{ROOTDIR}/resource/csdk/connectivity/src/libconnectivity_abstraction.so %{buildroot}/%{_libdir}
-cp -f %{ROOTDIR}/resource/csdk/connectivity/lib/libcoap-4.1.1/libcoap.a %{buildroot}/%{_libdir}
+cp -f %{ROOTDIR}/extlibs/libcoap/libcoap.a %{buildroot}/%{_libdir}
 cp /usr/lib/libuuid.so.1 %{buildroot}%{_libdir}
 if echo %{SECURED}|grep -qi '1'; then
        cp -f %{ROOTDIR}/out/tizen/*/*/extlibs/tinydtls/libtinydtls.a %{buildroot}/%{_libdir}
index 872e8c4..9619889 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "iotivity_config.h"
 #include "occlientcb.h"
-#include "utlist.h"
+#include <coap/utlist.h>
 #include "logger.h"
 #include "oic_malloc.h"
 #include <string.h>
@@ -31,7 +31,7 @@
 #ifdef HAVE_ARDUINO_TIME_H
 #include "Time.h"
 #endif
-#include "coap_time.h"
+#include <coap/coap_time.h>
 
 #include "cacommon.h"
 #include "cainterface.h"
index 2051f73..3e0a9ba 100644 (file)
@@ -31,8 +31,8 @@
 #include "ocserverrequest.h"
 #include "logger.h"
 
-#include "utlist.h"
-#include "pdu.h"
+#include <coap/utlist.h>
+#include <coap/pdu.h>
 
 
 // Module Name
index 8c825e4..041c75c 100644 (file)
@@ -36,8 +36,8 @@
 #include "cacommon.h"
 #include "cainterface.h"
 
-#include "utlist.h"
-#include "pdu.h"
+#include <coap/utlist.h>
+#include <coap/pdu.h>
 
 // Module Name
 #define VERIFY_NON_NULL(arg) { if (!arg) {OIC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
@@ -643,7 +643,7 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
                     OICFree(responseInfo.info.options);
                     return result;
                 }
-                //Add CONTENT_FORMAT OPT if payload exist
+                // Add CONTENT_FORMAT OPT if payload exist
                 if (responseInfo.info.payloadSize > 0)
                 {
                     responseInfo.info.payloadFormat = CA_FORMAT_APPLICATION_CBOR;
index 5f3424e..a6df796 100644 (file)
@@ -80,9 +80,9 @@
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
-#include "coap_time.h"
-#include "utlist.h"
-#include "pdu.h"
+#include <coap/coap_time.h>
+#include <coap/utlist.h>
+#include <coap/pdu.h>
 
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
index d8cf349..9b2d7a3 100644 (file)
@@ -25,6 +25,14 @@ ocprovision_env = env.Clone()
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = ocprovision_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.
+       ocprovision_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       ocprovision_env.AppendUnique(CPPPATH = ['../csdk/connectivity/lib/libcoap-4.1.1/include'])
+
 ocprovision_env.AppendUnique(CPPPATH = [
                '../include/',
                '../csdk/stack/include',
@@ -36,25 +44,24 @@ ocprovision_env.AppendUnique(CPPPATH = [
                '../csdk/security/provisioning/include',
                '../csdk/security/provisioning/include/oxm',
                '../csdk/security/provisioning/include/internal',
-        '../csdk/connectivity/lib/libcoap-4.1.1/',
-        '../../extlibs/cjson/'
+               '../../extlibs/cjson/'
                ])
 
-target_os = env.get('TARGET_OS')
+target_os = ocprovision_env.get('TARGET_OS')
 if target_os not in ['windows']:
        ocprovision_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-fPIC'])
 
 if target_os == 'android':
        ocprovision_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       ocprovision_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+       ocprovision_env.AppendUnique(LIBPATH = [ocprovision_env.get('BUILD_DIR')])
        ocprovision_env.AppendUnique(LIBS = ['oc', 'octbstack', 'ocpmapi', 'oc_logger', 'boost_thread', 'gnustl_shared', 'log'])
 
 if target_os in ['linux', 'tizen']:
-       ocprovision_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+       ocprovision_env.AppendUnique(LIBPATH = [ocprovision_env.get('BUILD_DIR')])
         ocprovision_env.AppendUnique(LIBS = ['oc', 'octbstack', 'ocpmapi', 'oc_logger', 'boost_thread'])
 
 if target_os in ['darwin', 'ios']:
-       ocprovision_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+       ocprovision_env.AppendUnique(LIBPATH = [ocprovision_env.get('BUILD_DIR')])
        ocprovision_env.AppendUnique(LIBS = ['octbstack', 'oc_logger'])
 
 ######################################################################
index 301e7df..e0106c5 100644 (file)
@@ -37,13 +37,20 @@ with_mq = oclib_env.get('WITH_MQ')
 ######################################################################
 # Build flags
 ######################################################################
+with_upstream_libcoap = oclib_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.
+       oclib_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+else:
+       # For bring up purposes only, the forked version will live here.
+       oclib_env.AppendUnique(CPPPATH = ['../csdk/connectivity/lib/libcoap-4.1.1/include'])
+
 oclib_env.AppendUnique(CPPPATH = [
                '../include/',
                '../csdk/stack/include',
                '../c_common/ocrandom/include',
                '../csdk/logger/include',
                '../oc_logger/include',
-               '../csdk/connectivity/lib/libcoap-4.1.1',
                '../csdk/connectivity/api'
                ])
 
diff --git a/run.bat b/run.bat
index 861d851..75d039f 100644 (file)
--- a/run.bat
+++ b/run.bat
@@ -57,8 +57,9 @@ set TEST=1
 set LOGGING=OFF
 set WITH_RD=1
 set ROUTING=EP
+set WITH_UPSTREAM_LIBCOAP=0
 
-set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% RELEASE=0 WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=0 BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% WITH_RD=%WITH_RD% ROUTING=%ROUTING%
+set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% RELEASE=0 WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=0 BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% WITH_RD=%WITH_RD% ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
 
 REM *** BUILD OPTIONS ***
 
@@ -109,6 +110,7 @@ if "!CURRENT_ARG!"=="server" (
   echo   LOGGING=%LOGGING%
   echo   WITH_RD=%WITH_RD%
   echo   ROUTING=%ROUTING%
+  echo   WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
   CL.exe | findstr "Compiler Verison"
   echo.scons VERBOSE=1 %BUILD_OPTIONS%
   scons VERBOSE=1 %BUILD_OPTIONS%
index 103ecf6..41a73fa 100644 (file)
@@ -90,19 +90,26 @@ if target_os in ['android','linux']:
                env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',
                env.get('SRC_DIR') + '/resource/include',
                env.get('SRC_DIR') + '/resource/csdk/logger/include',
-               env.get('SRC_DIR') + '/resource/csdk/stack/include',
-               env.get('SRC_DIR') + '/resource/csdk/logger/include',
+               env.get('SRC_DIR') + '/resource/csdk/stack/include',
+               env.get('SRC_DIR') + '/resource/csdk/logger/include',
                env.get('SRC_DIR') + '/resource/csdk/security/include',
                env.get('SRC_DIR') + '/extlibs/cjson',
                env.get('SRC_DIR') + '/extlibs/sqlite3',
                env.get('SRC_DIR') + '/service/easy-setup/inc',
                'inc'])
        if env.get('SECURED') == '1':
+               with_upstream_libcoap = easy_setup_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.
+                       easy_setup_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+               else:
+                       # For bring up purposes only, the forked version will live here.
+                       easy_setup_env.AppendUnique(CPPPATH = [env.get('SRC_DIR') + '/resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
                easy_setup_env.AppendUnique(CPPPATH = [
                        env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include',
                        env.get('SRC_DIR') + '/resource/csdk/security/include/internal',
                        env.get('SRC_DIR') + '/resource/csdk/connectivity/api/',
-                       env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal',
+                       env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal',
                        env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/oxm'])
                if env.get('WITH_TCP') == True:
                        easy_setup_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
index d869bbe..8e72b50 100644 (file)
@@ -39,6 +39,7 @@ cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
+cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs
 cp -R ./resource $sourcedir/tmp
 cp -R ./service $sourcedir/tmp
 cp ./extra_options.scons $sourcedir/tmp