Skip to content

Commit

Permalink
(#22691) libucl: add version 0.9.0
Browse files Browse the repository at this point in the history
* libucl: add version 0.9.0

* link math lib

* remove glib types
  • Loading branch information
toge authored Feb 16, 2024
1 parent 8f62df8 commit 1c4fc7d
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 0 deletions.
14 changes: 14 additions & 0 deletions recipes/libucl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
sources:
"0.9.0":
url: "https://github.com/vstakhov/libucl/archive/refs/tags/0.9.0.tar.gz"
sha256: "87b233048bca7d307b14cffb882d3c198dc3fff96b19e0c3515428f027b3ebfe"
"0.8.2":
url: "https://github.com/vstakhov/libucl/archive/refs/tags/0.8.2.tar.gz"
sha256: "d95a0e2151cc167a0f3e51864fea4e8977a0f4c473faa805269a347f7fb4e165"
"0.8.1":
url: "https://github.com/vstakhov/libucl/archive/refs/tags/0.8.1.tar.gz"
sha256: "a6397e179672f0e8171a0f9a2cfc37e01432b357fd748b13f4394436689d24ef"
patches:
"0.9.0":
- patch_file: "patches/0001-0.8.1-shared-win32.patch"
patch_description: "fix UCL_EXTERN definition for shared build on win32"
patch_type: "portability"
- patch_file: "patches/0002-0.9.0-cmake-add-install+use-find_package.patch"
patch_description: "improve installation, use cci package"
patch_type: "conan"
- patch_file: "patches/0006-0.9.0-remove-glib-types.patch"
patch_description: "remove glib types, use char and size_t instead."
patch_type: "portability"
patch_source: "https://github.com/vstakhov/libucl/pull/283"
"0.8.2":
- patch_file: "patches/0001-0.8.1-shared-win32.patch"
patch_description: "fix UCL_EXTERN definition for shared build on win32"
Expand Down
4 changes: 4 additions & 0 deletions recipes/libucl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from conan import ConanFile
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"
Expand Down Expand Up @@ -90,3 +91,6 @@ def package_info(self):

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.names["pkg_config"] = "libucl"

if Version(self.version) >= "0.9.0" and self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e23994..c67a5b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,12 +5,15 @@ SET(LIBUCL_VERSION_MAJOR 0)
SET(LIBUCL_VERSION_MINOR 9)
SET(LIBUCL_VERSION_PATCH 0)

-SET(LIBUCL_VERSION
- "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}")
+SET(LIBUCL_VERSION "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}")

INCLUDE(CheckCCompilerFlag)
INCLUDE(CheckCSourceCompiles)
-INCLUDE(FindOpenSSL)
+IF(ENABLE_URL_SIGN)
+ FIND_PACKAGE(OpenSSL REQUIRED)
+ SET(HAVE_OPENSSL 1)
+ ADD_DEFINITIONS(-DHAVE_OPENSSL)
+ENDIF(ENABLE_URL_SIGN)
INCLUDE(GNUInstallDirs)

OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF)
@@ -135,30 +138,10 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")

IF(ENABLE_URL_INCLUDE MATCHES "ON")
- FIND_LIBRARY(LIBFETCH_LIBRARY NAMES fetch PATHS PATH_SUFFIXES lib64 lib
- PATHS
- ~/Library/Frameworks
- /Library/Frameworks
- /usr/local
- /usr
- /sw
- /opt/local
- /opt/csw
- /opt
- DOC "Path where the libfetch library can be found")
- IF(LIBFETCH_LIBRARY)
- FIND_FILE(HAVE_FETCH_H NAMES fetch.h PATHS /usr/include
- /opt/include
- /usr/local/include
- DOC "Path to libfetch header")
- ELSE(LIBFETCH_LIBRARY)
- # Try to find libcurl
- FIND_PACKAGE(CURL)
- IF(NOT CURL_FOUND)
- MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration")
- ENDIF(NOT CURL_FOUND)
- ENDIF(LIBFETCH_LIBRARY)
-ENDIF(ENABLE_URL_INCLUDE MATCHES "ON")
+ FIND_PACKAGE(CURL REQUIRED)
+ ADD_DEFINITIONS(-DCURL_FOUND)
+ SET(CURL_LIBRARIES CURL::libcurl)
+ENDIF()

set(SYNC_BUILTINS_TEST_SOURCE [====[
int main()
@@ -249,35 +232,24 @@ TARGET_COMPILE_DEFINITIONS(ucl
${UCL_COMPILE_DEFS}
)

-IF(ENABLE_LUA MATCHES "ON")
- IF(ENABLE_LUAJIT MATCHES "ON")
- FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}")
- IF(NOT LUA_FOUND)
- MESSAGE(FATAL_ERROR "Lua not found, lua support is required")
- ELSE(NOT LUA_FOUND)
- INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
- ENDIF(NOT LUA_FOUND)
- ELSE(ENABLE_LUAJIT MATCHES "ON")
- FindLua(VERSION_MAJOR "5" VERSION_MINOR "2" ROOT "${LUA_ROOT}")
- IF(NOT LUA_FOUND)
- FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}")
- ENDIF(NOT LUA_FOUND)
- IF(NOT LUA_FOUND)
- MESSAGE(FATAL_ERROR "Lua not found, lua support is required")
- ELSE(NOT LUA_FOUND)
- INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
- ENDIF(NOT LUA_FOUND)
- ENDIF(ENABLE_LUAJIT MATCHES "ON")
+IF(ENABLE_LUA OR ENABLE_LUAJIT)
SET(UCL_LUA_SRC lua/lua_ucl.c)
ADD_LIBRARY(lua-ucl ${LIB_TYPE} ${UCL_LUA_SRC})
ADD_LIBRARY(ucl::lua ALIAS lua-ucl)
+ TARGET_LINK_LIBRARIES(lua-ucl ucl)
IF(ENABLE_LUAJIT MATCHES "ON")
- TARGET_LINK_LIBRARIES(lua-ucl "${LUAJIT_LIBRARY}")
+ TARGET_LINK_LIBRARIES(lua-ucl luajit::luajit)
ELSE(ENABLE_LUAJIT MATCHES "ON")
- TARGET_LINK_LIBRARIES(lua-ucl "${LUA_LIBRARY}")
+ TARGET_LINK_LIBRARIES(lua-ucl lua::lua)
ENDIF(ENABLE_LUAJIT MATCHES "ON")
- TARGET_LINK_LIBRARIES(lua-ucl ucl)
TARGET_INCLUDE_DIRECTORIES(lua-ucl PUBLIC include PRIVATE src uthash)
+ IF(ENABLE_LUA)
+ FIND_PACKAGE(lua REQUIRED CONFIG)
+ TARGET_LINK_LIBRARIES(lua-ucl lua::lua)
+ ELSEIF(ENABLE_LUAJIT)
+ FIND_PACKAGE(luajit REQUIRED CONFIG)
+ TARGET_LINK_LIBRARIES(lua-ucl luajit::luajit)
+ ENDIF()
SET_TARGET_PROPERTIES(lua-ucl PROPERTIES
VERSION ${LIBUCL_VERSION}
SOVERSION ${LIBUCL_VERSION_MAJOR}
@@ -306,8 +278,11 @@ ENDIF(UNIX)
SET_TARGET_PROPERTIES(ucl PROPERTIES
PUBLIC_HEADER "${UCLHDR}")

-INSTALL(TARGETS ucl EXPORT uclConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+INSTALL(TARGETS ucl EXPORT uclConfig
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

IF(ENABLE_UTILS MATCHES "ON")
ADD_SUBDIRECTORY(utils)
32 changes: 32 additions & 0 deletions recipes/libucl/all/patches/0006-0.9.0-remove-glib-types.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/lua/lua_ucl.c b/lua/lua_ucl.c
index c2e39c4..d6be69e 100644
--- a/lua/lua_ucl.c
+++ b/lua/lua_ucl.c
@@ -406,7 +406,6 @@ ucl_object_lua_fromtable (lua_State *L, int idx, ucl_string_flags_t flags)

/* Table iterate */
if (is_array) {
- int i;

if (!is_implicit) {
top = ucl_object_typed_new (UCL_ARRAY);
@@ -416,7 +415,7 @@ ucl_object_lua_fromtable (lua_State *L, int idx, ucl_string_flags_t flags)
top = NULL;
}

- for (i = 1; i <= max; i ++) {
+ for (size_t i = 1; i <= max; i ++) {
lua_pushinteger (L, i);
lua_gettable (L, idx);

@@ -886,8 +885,8 @@ lua_ucl_parser_parse_text (lua_State *L)
t = lua_touserdata (L, 2);
}
else if (lua_type (L, 2) == LUA_TSTRING) {
- const gchar *s;
- gsize len;
+ const char *s;
+ size_t len;
static struct _rspamd_lua_text st_t;

s = lua_tolstring (L, 2, &len);
2 changes: 2 additions & 0 deletions recipes/libucl/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"0.9.0":
folder: all
"0.8.2":
folder: all
"0.8.1":
Expand Down

0 comments on commit 1c4fc7d

Please sign in to comment.