Skip to content

Commit

Permalink
Merge pull request #232 from sebastianertz/lib-digest
Browse files Browse the repository at this point in the history
lib: introduce digest library
  • Loading branch information
jow- authored Dec 1, 2024
2 parents 1323a27 + 1752779 commit 60e7a88
Show file tree
Hide file tree
Showing 3 changed files with 393 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- name: Setup
run: |
brew install json-c
brew install json-c libmd
- name: Build minimal version
run: |
Expand Down
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ find_library(libubox NAMES ubox)
find_library(libubus NAMES ubus)
find_library(libblobmsg_json NAMES blobmsg_json)
find_package(ZLIB)
find_library(libmd NAMES libmd.a md)

if(LINUX)
find_library(libnl_tiny NAMES nl-tiny)
Expand All @@ -54,6 +55,10 @@ if(ZLIB_FOUND)
set(DEFAULT_ZLIB_SUPPORT ON)
endif()

if(libmd)
set(DEFAULT_DIGEST_SUPPORT ON)
endif()

option(DEBUG_SUPPORT "Debug plugin support" ON)
option(FS_SUPPORT "Filesystem plugin support" ON)
option(MATH_SUPPORT "Math plugin support" ON)
Expand All @@ -67,6 +72,8 @@ option(ULOOP_SUPPORT "Uloop plugin support" ${DEFAULT_ULOOP_SUPPORT})
option(LOG_SUPPORT "Log plugin support" ON)
option(SOCKET_SUPPORT "Socket plugin support" ON)
option(ZLIB_SUPPORT "Zlib plugin support" ${DEFAULT_ZLIB_SUPPORT})
option(DIGEST_SUPPORT "Digest plugin support" ${DEFAULT_DIGEST_SUPPORT})
option(DIGEST_SUPPORT_EXTENDED "Enable additional hash algorithms" ${DEFAULT_DIGEST_SUPPORT})

set(LIB_SEARCH_PATH "${CMAKE_INSTALL_PREFIX}/lib/ucode/*.so:${CMAKE_INSTALL_PREFIX}/share/ucode/*.uc:./*.so:./*.uc" CACHE STRING "Default library search path")
string(REPLACE ":" "\", \"" LIB_SEARCH_DEFINE "${LIB_SEARCH_PATH}")
Expand Down Expand Up @@ -290,6 +297,19 @@ if(ZLIB_SUPPORT)
target_link_libraries(zlib_lib ZLIB::ZLIB)
endif()

if(DIGEST_SUPPORT)
pkg_check_modules(LIBMD REQUIRED libmd)
include_directories(${LIBMD_INCLUDE_DIRS})
set(LIBRARIES ${LIBRARIES} digest_lib)
add_library(digest_lib MODULE lib/digest.c)
set_target_properties(digest_lib PROPERTIES OUTPUT_NAME digest PREFIX "")
if(DIGEST_SUPPORT_EXTENDED)
target_compile_definitions(digest_lib PUBLIC HAVE_DIGEST_EXTENDED)
endif()
target_link_options(digest_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS})
target_link_libraries(digest_lib ${libmd})
endif()

if(UNIT_TESTING)
enable_testing()
add_definitions(-DUNIT_TESTING)
Expand Down
Loading

0 comments on commit 60e7a88

Please sign in to comment.