Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
84ecb78
Only build dynamic libraries if the target platform supports it.
Oxymoron79 Mar 4, 2022
8d32cd7
Raise CMake Error if the port cannot be determined
Oxymoron79 Mar 4, 2022
6dcf029
Add CMake variable for compile options
Oxymoron79 Mar 4, 2022
29bcd1f
Add CMake variable for CMake target dependencies
Oxymoron79 Mar 4, 2022
aab57fb
Detect Zephyr port
Oxymoron79 Mar 4, 2022
cda25f5
Update tinycbor submodule to v0.6.0
Oxymoron79 Mar 4, 2022
2eb7a0d
Add missing include for strncasecmp
Oxymoron79 Mar 4, 2022
89078ec
Remove unneeded wchar.h inclusion
Oxymoron79 Mar 4, 2022
8f658cc
zephyr oc_config.h: Add switch for OC_DYNAMIC_ALLOCATION
Oxymoron79 Mar 4, 2022
e3899b0
zephyr clock.c: Fix k_sleep arguments
Oxymoron79 Mar 4, 2022
8067b20
oc_obt.c: Disable support for float data type if it's disabled in Tin…
Oxymoron79 Mar 8, 2022
1923c7f
Move raw flash storage implementation to storage_flash.c
Oxymoron79 Mar 8, 2022
9dc8246
Add storage implementation using the Zephyr file-system API
Oxymoron79 Mar 8, 2022
fe4d6d9
Determine storage implementation based on Zephyr configuration
Oxymoron79 Mar 8, 2022
a1f9d76
zephyr oc_config.h: Add definition for OC_MULTICAST_RESPONSE_JITTER_MS
Oxymoron79 Mar 8, 2022
ba011a5
oc_helpers: Exclude functions only used by oscore.
Oxymoron79 Mar 9, 2022
3706fbf
Zephyr oc_storage_config: Fix debug message.
Oxymoron79 Mar 14, 2022
6f97616
zephyr oc_config.h: Add definition for OC_NETWORK_MONITOR
Oxymoron79 Mar 15, 2022
0876d78
Add include dirs from net/ip subsystem
Oxymoron79 Mar 15, 2022
a506e43
Port Linux ipadapter implementation to Zephyr
Oxymoron79 Mar 15, 2022
ea295f4
Add 16 padding bits to struct ip_context_t for word alignment.
Oxymoron79 Mar 18, 2022
4c32879
Initialize secure IPv6 socket
Oxymoron79 Mar 18, 2022
659dc83
Fix mbedtls build when dynamic memory allocation is disabled
Oxymoron79 Mar 18, 2022
ad62bb2
zephyr oc_config.h: Fix definitions when dynamic memory allocation is…
Oxymoron79 Mar 18, 2022
75e87cc
Define OC_CLOCK_CONF_TICKS_PER_SECOND from Zephyr configuration
Oxymoron79 Mar 18, 2022
6a784bb
zephyr oc_config.h: Synchonize with linux port
Oxymoron79 Mar 18, 2022
c66f4a1
Only add_dependencies if TARGET_DEPENDENCIES is not empty
Oxymoron79 Apr 5, 2022
309cee4
Automatic format commit
CascodaBot Apr 5, 2022
e56ef85
Add atomic implementation for Zephyr
Oxymoron79 Apr 7, 2022
d52d1e8
Add README for zephyr port update.
Oxymoron79 Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 64 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ include(tools/clang-tidy.cmake)
######## Define compiler flags ########
set(PRIVATE_COMPILE_DEFINITIONS "")
set(PUBLIC_COMPILE_DEFINITIONS "")
set(PRIVATE_COMPILE_OPTIONS "")
if(OC_DYNAMIC_ALLOCATION_ENABLED)
list(APPEND PUBLIC_COMPILE_DEFINITIONS "OC_DYNAMIC_ALLOCATION")
endif()
Expand Down Expand Up @@ -148,6 +149,9 @@ if(OC_DNS_LOOKUP_IPV6_ENABLED)
list(APPEND PRIVATE_COMPILE_DEFINITIONS "OC_DNS_LOOKUP_IPV6")
endif()

######## Target dependencies ########
set(TARGET_DEPENDENCIES "")

######## Gather source files ########
file(GLOB COMMON_SRC
${PROJECT_SOURCE_DIR}/api/c-timestamp/timestamp_format.c
Expand Down Expand Up @@ -176,8 +180,45 @@ if(UNIX)
elseif(WIN32)
file(GLOB PORT_SRC port/windows/*.c)
set(PORT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/port/windows)
elseif(DEFINED ZEPHYR_BASE)
# Set the Zephyr CMake task zephyr_interface as dependency.
# Zephyr generates some platform headers in that CMake task which needs to be completed
# before iotivity-lite compilation can start or the headers can not be found.
list(APPEND TARGET_DEPENDENCIES zephyr_interface)

# Set the Zephyr include directories globally.
# Taken from zephyr/cmake/extensions.cmake: zephyr_get_include_directories_for_lang(C includes)
get_property(zephyr_include_dirs TARGET zephyr_interface PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
get_property(posix_subsys_include_dirs TARGET posix_subsys PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
# The Zephyr IP subsystem provides helper functions for IPv6 multicast functions in the
# subsys/net/ip/ipv6.h header file. But this header file is not provided by any Zephyr CMake target.
set(net_ip_subsys_include_dirs ${ZEPHYR_BASE}/subsys/net/ip)
include_directories(${zephyr_include_dirs} ${posix_subsys_include_dirs} ${net_ip_subsys_include_dirs})

# Add Zephyr compile definitions.
# Taken from zephyr/cmake/extensions.cmake: zephyr_get_compile_definitions_for_lang(C definitions)
get_property(zephyr_compile_defs TARGET zephyr_interface PROPERTY INTERFACE_COMPILE_DEFINITIONS)
list(APPEND PRIVATE_COMPILE_DEFINITIONS ${zephyr_compile_defs})
list(APPEND PRIVATE_COMPILE_DEFINITIONS CBOR_NO_FLOATING_POINT)

# Add Zephyr compile options.
# Taken from zephyr/cmake/extensions.cmake: zephyr_get_compile_options_for_lang(C options)
get_property(zephyr_compile_opts TARGET zephyr_interface PROPERTY INTERFACE_COMPILE_OPTIONS)
list(APPEND PRIVATE_COMPILE_OPTIONS ${zephyr_compile_opts})

file(GLOB PORT_SRC port/zephyr/src/[a-r]*.c)
if(CONFIG_FILE_SYSTEM)
message(STATUS "Using file system storage.")
list(APPEND PORT_SRC port/zephyr/src/storage_fs.c)
elseif(CONFIG_FLASH)
message(STATUS "Using raw flash storage.")
list(APPEND PORT_SRC port/zephyr/src/storage_flash.c)
else()
message(FATAL_ERROR "Cannot determine the storage technology to use!")
endif()
set(PORT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/port/zephyr/src)
else()
message(ERROR "Can build only on Linux and Windows!")
message(FATAL_ERROR "Cannot determine the port to use!")
endif()
list(APPEND SERVER_SRC ${PORT_SRC})
list(APPEND CLIENT_SRC ${PORT_SRC})
Expand Down Expand Up @@ -237,32 +278,49 @@ oc_enable_clang_tidy()

add_library(common-obj OBJECT ${COMMON_SRC})
target_compile_definitions(common-obj PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} PUBLIC ${PUBLIC_COMPILE_DEFINITIONS})
target_compile_options(common-obj PRIVATE ${PRIVATE_COMPILE_OPTIONS})
target_include_directories(common-obj PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/port ${PORT_INCLUDE_DIR})
if(TARGET_DEPENDENCIES)
add_dependencies(common-obj ${TARGET_DEPENDENCIES})
endif()

add_library(client-obj OBJECT ${CLIENT_SRC})
target_compile_definitions(client-obj PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} PUBLIC ${PUBLIC_COMPILE_DEFINITIONS} "OC_CLIENT")
target_compile_options(client-obj PRIVATE ${PRIVATE_COMPILE_OPTIONS})
target_include_directories(client-obj PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/port ${PORT_INCLUDE_DIR})
if(OC_SECURITY_ENABLED)
target_include_directories(client-obj PRIVATE ${MBEDTLS_INCLUDE_DIRS})
endif()
if(TARGET_DEPENDENCIES)
add_dependencies(client-obj ${TARGET_DEPENDENCIES})
endif()

add_library(server-obj OBJECT ${SERVER_SRC})
target_compile_definitions(server-obj PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} PUBLIC ${PUBLIC_COMPILE_DEFINITIONS} "OC_SERVER")
target_compile_options(server-obj PRIVATE ${PRIVATE_COMPILE_OPTIONS})
target_include_directories(server-obj PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/port ${PORT_INCLUDE_DIR})
if(OC_SECURITY_ENABLED)
target_include_directories(server-obj PRIVATE ${MBEDTLS_INCLUDE_DIRS})
endif()
if(TARGET_DEPENDENCIES)
add_dependencies(server-obj ${TARGET_DEPENDENCIES})
endif()

add_library(client-server-obj OBJECT ${CLIENT_SRC})
target_compile_definitions(client-server-obj PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} PUBLIC ${PUBLIC_COMPILE_DEFINITIONS} "OC_CLIENT" "OC_SERVER")
target_compile_options(client-server-obj PRIVATE ${PRIVATE_COMPILE_OPTIONS})
target_include_directories(client-server-obj PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/port ${PORT_INCLUDE_DIR})
if(OC_SECURITY_ENABLED)
target_include_directories(client-server-obj PRIVATE ${MBEDTLS_INCLUDE_DIRS})
endif()
if(TARGET_DEPENDENCIES)
add_dependencies(client-server-obj ${TARGET_DEPENDENCIES})
endif()

if(OC_CLOUD_ENABLED)
add_library(cloud-obj OBJECT ${CLOUD_SRC})
target_compile_definitions(cloud-obj PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} PUBLIC ${PUBLIC_COMPILE_DEFINITIONS})
target_compile_options(cloud-obj PRIVATE ${PRIVATE_COMPILE_OPTIONS})
target_include_directories(cloud-obj PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/port ${PORT_INCLUDE_DIR})
if(OC_SECURITY_ENABLED)
target_include_directories(cloud-obj PRIVATE ${MBEDTLS_INCLUDE_DIRS})
Expand All @@ -271,6 +329,7 @@ endif()

add_library(python-obj OBJECT ${PYTHON_SRC})
target_compile_definitions(python-obj PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} OC_LIBRARY_EXPORT PUBLIC ${PUBLIC_COMPILE_DEFINITIONS} "OC_LIBRARY" "OC_CLIENT")
target_compile_options(python-obj PRIVATE ${PRIVATE_COMPILE_OPTIONS})
set_property(TARGET python-obj PROPERTY C_VISIBILITY_PRESET hidden)
set_property(TARGET python-obj PROPERTY VISIBILITY_INLINES_HIDDEN ON)
target_include_directories(python-obj PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/port ${PORT_INCLUDE_DIR})
Expand Down Expand Up @@ -309,7 +368,7 @@ set_target_properties(client-static PROPERTIES
VERSION ${PROJECT_VERSION}
)

if(NOT MSVC)
if(TARGET_SUPPORTS_SHARED_LIBS AND NOT MSVC)
# Since the library symbols are not explicitly exported, no proper DLL and import LIB are generated with MSVC
add_library(client-shared SHARED ${client-lib-obj})
target_link_libraries(client-shared PRIVATE ${PRIVATE_LINK_LIBS})
Expand Down Expand Up @@ -365,7 +424,7 @@ set_target_properties(server-static PROPERTIES
VERSION ${PROJECT_VERSION}
)

if(NOT MSVC)
if(TARGET_SUPPORTS_SHARED_LIBS AND NOT MSVC)
# Since the library symbols are not explicitly exported, no proper DLL and import LIB are generated with MSVC
add_library(server-shared SHARED ${server-lib-obj})
target_link_libraries(server-shared PRIVATE ${PRIVATE_LINK_LIBS})
Expand Down Expand Up @@ -426,7 +485,7 @@ set_target_properties(client-server-static PROPERTIES
VERSION ${PROJECT_VERSION}
)

if(NOT MSVC)
if(TARGET_SUPPORTS_SHARED_LIBS AND NOT MSVC)
# Since the library symbols are not explicitly exported, no proper DLL and import LIB are generated with MSVC
add_library(client-server-shared SHARED ${client-server-lib-obj})
target_link_libraries(client-server-shared PRIVATE ${PRIVATE_LINK_LIBS})
Expand Down Expand Up @@ -596,7 +655,7 @@ set(INSTALL_TARGETS
server-static server-shared
client-server-static client-server-shared
)
if(MSVC)
if(NOT TARGET_SUPPORTS_SHARED_LIBS OR MSVC)
# Since the library symbols are not explicitly exported, no proper DLL and import LIB are generated with MSVC
set(INSTALL_TARGETS
client-static
Expand Down
1 change: 1 addition & 0 deletions api/oc_discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "oc_endpoint.h"

#ifdef OC_SECURITY
#include <strings.h>
#include "security/oc_pstat.h"
#include "security/oc_sdi.h"
#include "security/oc_tls.h"
Expand Down
2 changes: 2 additions & 0 deletions api/oc_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ oc_join_string_array(oc_string_array_t *ocstringarray, oc_string_t *ocstring)
strcpy((char *)oc_string(*ocstring) + len, "");
}

#ifdef OC_OSCORE
int
oc_conv_byte_array_to_hex_string(const uint8_t *array, size_t array_len,
char *hex_str, size_t *hex_str_len)
Expand Down Expand Up @@ -315,3 +316,4 @@ oc_conv_hex_string_to_byte_array(const char *hex_str, size_t hex_str_len,

return 0;
}
#endif /* OC_OSCORE */
10 changes: 9 additions & 1 deletion deps/mbedtls.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ file(GLOB MBEDTLS_SRC
)
list(REMOVE_ITEM MBEDTLS_SRC
${PROJECT_SOURCE_DIR}/deps/mbedtls/library/certs.c
${PROJECT_SOURCE_DIR}/deps/mbedtls/library/memory_buffer_alloc.c
${PROJECT_SOURCE_DIR}/deps/mbedtls/library/x509_crl.c
)
if(OC_DYNAMIC_ALLOCATION_ENABLED)
list(REMOVE_ITEM MBEDTLS_SRC
${PROJECT_SOURCE_DIR}/deps/mbedtls/library/memory_buffer_alloc.c
)
endif()
add_library(mbedtls OBJECT ${MBEDTLS_SRC})
target_include_directories(mbedtls PRIVATE
${PROJECT_SOURCE_DIR}
Expand All @@ -24,7 +28,11 @@ target_include_directories(mbedtls PRIVATE
${PROJECT_SOURCE_DIR}/deps/mbedtls/include
)
target_compile_definitions(mbedtls PUBLIC ${PUBLIC_COMPILE_DEFINITIONS} PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} __OC_RANDOM)
target_compile_options(mbedtls PRIVATE ${PRIVATE_COMPILE_OPTIONS})
# do not treat warnings as errors on Windows
if(MSVC)
target_compile_options(mbedtls PRIVATE /W1 /WX-)
endif()
if(TARGET_DEPENDENCIES)
add_dependencies(mbedtls ${TARGET_DEPENDENCIES})
endif()
8 changes: 7 additions & 1 deletion deps/tinycbor.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ add_library(tinycbor-master OBJECT
${PROJECT_SOURCE_DIR}/deps/tinycbor/src/cborerrorstrings.c
${PROJECT_SOURCE_DIR}/deps/tinycbor/src/cborencoder.c
${PROJECT_SOURCE_DIR}/deps/tinycbor/src/cborencoder_close_container_checked.c
${PROJECT_SOURCE_DIR}/deps/tinycbor/src/cborencoder_float.c
${PROJECT_SOURCE_DIR}/deps/tinycbor/src/cborparser.c
${PROJECT_SOURCE_DIR}/deps/tinycbor/src/cborparser_float.c
${PROJECT_SOURCE_DIR}/deps/tinycbor/src/cborpretty.c
)

target_include_directories(tinycbor-master PUBLIC
${PROJECT_SOURCE_DIR}/deps/tinycbor/src
)

target_compile_definitions(tinycbor-master PUBLIC ${PUBLIC_COMPILE_DEFINITIONS})
target_compile_definitions(tinycbor-master PUBLIC ${PUBLIC_COMPILE_DEFINITIONS} PRIVATE ${PRIVATE_COMPILE_DEFINITIONS})
target_compile_options(tinycbor-master PRIVATE ${PRIVATE_COMPILE_OPTIONS})
if(TARGET_DEPENDENCIES)
add_dependencies(tinycbor-master ${TARGET_DEPENDENCIES})
endif()

install(DIRECTORY ${PROJECT_SOURCE_DIR}/deps/tinycbor/src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/iotivity-lite/deps/tinycbor/src COMPONENT dev
Expand Down
3 changes: 2 additions & 1 deletion include/oc_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ void _oc_alloc_string_array(
#endif
oc_string_array_t *ocstringarray, size_t size);

#ifdef OC_OSCORE
/** Conversions between hex encoded strings and byte arrays */

/**
Expand All @@ -304,7 +305,7 @@ int oc_conv_byte_array_to_hex_string(const uint8_t *array, size_t array_len,
*/
int oc_conv_hex_string_to_byte_array(const char *hex_str, size_t hex_str_len,
uint8_t *array, size_t *array_len);

#endif /* OC_OSCORE */
#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 0 additions & 2 deletions include/oc_introspection.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
#ifndef OC_INTROSPECTION_H
#define OC_INTROSPECTION_H

#include <wchar.h>

#include <inttypes.h>
#include <stddef.h>

Expand Down
Loading