From cec1fbea37eb6de75a2ea801b2b1c661190d6cd3 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Tue, 22 Mar 2022 03:38:10 +0100 Subject: [PATCH] [libdatrie] Update and fixes (#23681) * Libdatrie fixes * Libdatrie fixes and update to v0.2.13 * Add usage * Create feature 'tool' * Update versions * Install pkg-config module * Update versions Co-authored-by: Thomas Heinrichs <46387399+Thomas1664@users.noreply.github.com> --- ports/libdatrie/CMakeLists.txt | 35 ++++++++++--------- ports/libdatrie/fix-trietool.patch | 31 ----------------- ports/libdatrie/portfile.cmake | 56 ++++++++++++------------------ ports/libdatrie/usage | 13 +++++++ ports/libdatrie/vcpkg.json | 22 +++++++++--- scripts/ci.baseline.txt | 2 -- versions/baseline.json | 4 +-- versions/l-/libdatrie.json | 5 +++ 8 files changed, 78 insertions(+), 90 deletions(-) delete mode 100644 ports/libdatrie/fix-trietool.patch create mode 100644 ports/libdatrie/usage diff --git a/ports/libdatrie/CMakeLists.txt b/ports/libdatrie/CMakeLists.txt index bdc1c21eaa..57e7cf58e2 100644 --- a/ports/libdatrie/CMakeLists.txt +++ b/ports/libdatrie/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.22) project(libdatrie LANGUAGES C) option(SKIP_HEADERS "Skip headers" OFF) @@ -49,30 +49,23 @@ check_function_exists(malloc HAVE_MALLOC) configure_file(config.h.cmake config.h) +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}" +) + add_library(libdatrie ${LIB_SRCS}) -target_include_directories(libdatrie PRIVATE ".") -target_include_directories(libdatrie PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -set_target_properties(libdatrie PROPERTIES PREFIX "") -set_target_properties(libdatrie PROPERTIES DEBUG_POSTFIX "d") +set_target_properties(libdatrie PROPERTIES OUTPUT_NAME "datrie") if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) endif() - if (NOT SKIP_TOOL) add_executable(trietool "tools/trietool.c" ) - target_include_directories(trietool PRIVATE ".") - target_include_directories(trietool PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(trietool libdatrie) - - find_path(ICONV_INCLUDE_DIR iconv.h) - find_library(ICONV_LIBRARY NAMES iconv libiconv) - find_library(CHARSET_LIBRARY NAMES charset libcharset) - target_include_directories(trietool PRIVATE ${ICONV_INCLUDE_DIR}) - target_link_libraries(trietool ${ICONV_LIBRARY} ${CHARSET_LIBRARY}) - + find_package(Iconv REQUIRED) + target_link_libraries(trietool PRIVATE libdatrie Iconv::Iconv) install( TARGETS trietool RUNTIME DESTINATION bin @@ -92,3 +85,13 @@ if (NOT SKIP_HEADERS) DESTINATION "include/datrie" ) endif() + +set(prefix "${CMAKE_INSTALL_PREFIX}") +set(exec_prefix "\${prefix}") +set(libdir "\${prefix}/lib") +set(includedir "\${prefix}/include") +configure_file(datrie-0.2.pc.in datrie-0.2.pc) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/datrie-0.2.pc" + DESTINATION "lib/pkgconfig" +) \ No newline at end of file diff --git a/ports/libdatrie/fix-trietool.patch b/ports/libdatrie/fix-trietool.patch deleted file mode 100644 index bcecee26e4..0000000000 --- a/ports/libdatrie/fix-trietool.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 086a76ad7c17060d504371ea724cf5d651d43eb3 Mon Sep 17 00:00:00 2001 -From: Mikhail Paulyshka -Date: Thu, 28 Dec 2017 16:07:51 +0300 -Subject: [PATCH] fix trietool for MSVC runtime - ---- - tools/trietool.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/tools/trietool.c b/tools/trietool.c -index 4cfde2a..7c90905 100644 ---- a/tools/trietool.c -+++ b/tools/trietool.c -@@ -589,12 +589,12 @@ string_trim (char *s) - char *p; - - /* skip leading white spaces */ -- while (*s && isspace (*s)) -+ while (*s && isspace ((unsigned char)*s)) - ++s; - - /* trim trailing white spaces */ - p = s + strlen (s) - 1; -- while (isspace (*p)) -+ while (isspace ((unsigned char)*p)) - --p; - *++p = '\0'; - --- -2.14.1.windows.1 - diff --git a/ports/libdatrie/portfile.cmake b/ports/libdatrie/portfile.cmake index 452b66a174..76e8804601 100644 --- a/ports/libdatrie/portfile.cmake +++ b/ports/libdatrie/portfile.cmake @@ -1,52 +1,40 @@ -set(LIBDATRIE_VERSION 0.2.10) +set(LIBDATRIE_VERSION 0.2.13) -vcpkg_download_distfile(ARCHIVE - URLS "https://linux.thai.net/pub/ThaiLinux/software/libthai/libdatrie-${LIBDATRIE_VERSION}.tar.xz" - FILENAME "libdatrie-${LIBDATRIE_VERSION}.tar.xz" - SHA512 ee68ded9d6e06c562da462d42e7e56098a82478d7b8547506200c3018b72536c4037a4e518924f779dc77d3ab139d93216bdb29ab4116b9dc9efd1a5d1eb9e31 -) - -vcpkg_extract_source_archive_ex( - ARCHIVE ${ARCHIVE} +vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH + REPO tlwg/libdatrie + REF v${LIBDATRIE_VERSION} + SHA512 38f5a3ee1f3ca0f0601a5fcfeec3892cb34857d4b4720b8e018ca1beb6520c4c10af3bd2f0e4d64367cb256e8e2bca4d0a59b1c81fb36782613d2c258b64df59 + HEAD_REF master PATCHES - "${CMAKE_CURRENT_LIST_DIR}/fix-exports.patch" - "${CMAKE_CURRENT_LIST_DIR}/fix-trietool.patch" + fix-exports.patch ) -file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) -file(COPY ${CMAKE_CURRENT_LIST_DIR}/config.h.cmake DESTINATION ${SOURCE_PATH}) +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/config.h.cmake" DESTINATION "${SOURCE_PATH}") -if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - set(SKIP_TOOL ON) -else() - set(SKIP_TOOL OFF) -endif() +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + INVERTED_FEATURES + tool SKIP_TOOL +) -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" OPTIONS -DVERSION=${LIBDATRIE_VERSION} - OPTIONS_RELEASE - -DSKIP_TOOL=${SKIP_TOOL} - -DSKIP_HEADERS=OFF + ${FEATURE_OPTIONS} OPTIONS_DEBUG -DSKIP_TOOL=ON -DSKIP_HEADERS=ON ) -vcpkg_install_cmake() +vcpkg_cmake_install() vcpkg_copy_pdbs() +vcpkg_fixup_pkgconfig() -if(NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/${PORT}) - file(RENAME ${CURRENT_PACKAGES_DIR}/bin/trietool.exe ${CURRENT_PACKAGES_DIR}/tools/${PORT}/trietool.exe) - vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}) +if(NOT SKIP_TOOL) + vcpkg_copy_tools(TOOL_NAMES trietool AUTO_CLEAN) endif() -if(VCPKG_LIBRARY_LINKAGE STREQUAL static) - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin) -endif() - -file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libdatrie RENAME copyright) +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/libdatrie/usage b/ports/libdatrie/usage new file mode 100644 index 0000000000..2eed31d16f --- /dev/null +++ b/ports/libdatrie/usage @@ -0,0 +1,13 @@ +The package libdatrie can be used via CMake: + + find_path(LIBDATRIE_INCLUDE_DIR datrie/trie.h) + find_library(LIBDATRIE_LIBRARY NAMES datrie) + target_include_directories(main PRIVATE "${LIBDATRIE_INCLUDE_DIR}") + target_link_libraries(main PRIVATE "${LIBDATRIE_LIBRARY}") + +The package libdatrie can be imported via CMake FindPkgConfig module: + + include(FindPkgConfig) + pkg_check_modules(LIBDATRIE REQUIRED IMPORTED_TARGET datrie-0.2) + + target_link_libraries(main PRIVATE PkgConfig::LIBDATRIE) diff --git a/ports/libdatrie/vcpkg.json b/ports/libdatrie/vcpkg.json index b9f1f54570..bb78a27aef 100644 --- a/ports/libdatrie/vcpkg.json +++ b/ports/libdatrie/vcpkg.json @@ -1,10 +1,22 @@ { "name": "libdatrie", - "version-string": "0.2.10", - "port-version": 4, - "description": "implementation of double-array structure for representing trie", + "version": "0.2.13", + "description": "Implementation of double-array structure for representing trie", "homepage": "https://linux.thai.net/pub/ThaiLinux/software/libthai", + "license": "LGPL-2.1-or-later", "dependencies": [ - "libiconv" - ] + { + "name": "vcpkg-cmake", + "host": true + } + ], + "features": { + "tool": { + "description": "Build the trietool application", + "supports": "!uwp", + "dependencies": [ + "libiconv" + ] + } + } } diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 1346305cb3..893da2e180 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -495,8 +495,6 @@ libcopp:arm-uwp=fail # Missing system libraries on linux to run/prepare autoconf libgpod:x64-linux=fail libgpod:x64-osx=fail -libdatrie:x64-linux=fail -libdatrie:x64-osx=fail libepoxy:arm-uwp=fail libepoxy:x64-uwp=fail libepoxy:x64-windows-static=fail diff --git a/versions/baseline.json b/versions/baseline.json index cd14828767..320bfc219a 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -3453,8 +3453,8 @@ "port-version": 0 }, "libdatrie": { - "baseline": "0.2.10", - "port-version": 4 + "baseline": "0.2.13", + "port-version": 0 }, "libdc1394": { "baseline": "2.2.6", diff --git a/versions/l-/libdatrie.json b/versions/l-/libdatrie.json index e67f74a58c..643ac455a5 100644 --- a/versions/l-/libdatrie.json +++ b/versions/l-/libdatrie.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "f8e0374439550fd870ff280c0a3321c202b42929", + "version": "0.2.13", + "port-version": 0 + }, { "git-tree": "55aab3566cc2c82313f67f484a411b28f53da90b", "version-string": "0.2.10",