aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/libdatrie
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/libdatrie
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/libdatrie')
-rw-r--r--vcpkg/ports/libdatrie/CMakeLists.txt97
-rw-r--r--vcpkg/ports/libdatrie/config.h.cmake87
-rw-r--r--vcpkg/ports/libdatrie/fix-exports.patch8
-rw-r--r--vcpkg/ports/libdatrie/portfile.cmake40
-rw-r--r--vcpkg/ports/libdatrie/usage13
-rw-r--r--vcpkg/ports/libdatrie/vcpkg.json23
6 files changed, 268 insertions, 0 deletions
diff --git a/vcpkg/ports/libdatrie/CMakeLists.txt b/vcpkg/ports/libdatrie/CMakeLists.txt
new file mode 100644
index 0000000..57e7cf5
--- /dev/null
+++ b/vcpkg/ports/libdatrie/CMakeLists.txt
@@ -0,0 +1,97 @@
+cmake_minimum_required(VERSION 3.22)
+project(libdatrie LANGUAGES C)
+
+option(SKIP_HEADERS "Skip headers" OFF)
+option(SKIP_TOOL "Skip tool" OFF)
+option(BUILD_SHARED_LIBS "Build shared libs" OFF)
+
+set(LIB_SRCS
+ datrie/alpha-map.c
+ datrie/darray.c
+ datrie/dstring.c
+ datrie/fileutils.c
+ datrie/tail.c
+ datrie/trie.c
+ datrie/trie-string.c
+)
+
+set(LIB_HDRS
+ datrie/alpha-map.h
+ datrie/trie.h
+ datrie/triedefs.h
+ datrie/typedefs.h
+)
+
+if(WIN32)
+ list(APPEND LIB_SRCS datrie/libdatrie.def)
+endif()
+
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+
+set(STDC_HEADERS 1)
+check_include_file(dlfcn.h HAVE_DLFCN_H)
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+check_include_file(limits.h HAVE_LIMITS_H)
+check_include_file(memory.h HAVE_MEMORY_H)
+check_include_file(stdint.h HAVE_STDINT_H)
+check_include_file(stdio.h HAVE_STDIO_H)
+check_include_file(stdlib.h HAVE_STDLIB_H)
+check_include_file(strings.h HAVE_STRINGS_H)
+check_include_file(string.h HAVE_STRING_H)
+check_include_file(sys/stat.h HAVE_SYS_STAT_H)
+check_include_file(sys/types.h HAVE_SYS_TYPES_H)
+check_include_file(unistd.h HAVE_UNISTD_H)
+
+check_function_exists(nl_langinfo HAVE_LANGINFO_CODESET)
+check_function_exists(locale_charset HAVE_LOCALE_CHARSET)
+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})
+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" )
+ find_package(Iconv REQUIRED)
+ target_link_libraries(trietool PRIVATE libdatrie Iconv::Iconv)
+ install(
+ TARGETS trietool
+ RUNTIME DESTINATION bin
+ )
+endif()
+
+install(
+ TARGETS libdatrie
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+
+if (NOT SKIP_HEADERS)
+ install(
+ FILES ${LIB_HDRS}
+ 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/vcpkg/ports/libdatrie/config.h.cmake b/vcpkg/ports/libdatrie/config.h.cmake
new file mode 100644
index 0000000..9d575d6
--- /dev/null
+++ b/vcpkg/ports/libdatrie/config.h.cmake
@@ -0,0 +1,87 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#cmakedefine HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H
+
+/* Have nl_langinfo (CODESET) */
+#cmakedefine HAVE_LANGINFO_CODESET
+
+/* Define to 1 if you have the <limits.h> header file. */
+#cmakedefine HAVE_LIMITS_H
+
+/* Have locale_charset() */
+#cmakedefine HAVE_LOCALE_CHARSET
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+#cmakedefine HAVE_MALLOC
+
+/* Define to 1 if you have the <memory.h> header file. */
+#cmakedefine HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#cmakedefine HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#cmakedefine HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#cmakedefine HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#cmakedefine HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#cmakedefine LT_OBJDIR
+
+/* Name of package */
+#define PACKAGE "libdatrie"
+
+/* Define to the address where bug reports for this package should be sent. */
+#cmakedefine PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libdatrie"
+
+/* Define to the full name and version of this package. */
+#cmakedefine PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#cmakedefine PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "https://linux.thai.net/~thep/datrie/datrie.html"
+
+/* Define to the version of this package. */
+#cmakedefine PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#cmakedefine STDC_HEADERS 1
+
+/* Version number of package */
+#cmakedefine VERSION "@VERSION@"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#cmakedefine const
+
+/* Define to rpl_malloc if the replacement function should be used. */
+#cmakedefine malloc
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#cmakedefine size_t
diff --git a/vcpkg/ports/libdatrie/fix-exports.patch b/vcpkg/ports/libdatrie/fix-exports.patch
new file mode 100644
index 0000000..3c407c2
--- /dev/null
+++ b/vcpkg/ports/libdatrie/fix-exports.patch
@@ -0,0 +1,8 @@
+diff -Naur ./a/libdatrie.def ./b/libdatrie.def
+--- a/datrie/libdatrie.def 2013-10-17 06:27:57.000000000 +0300
++++ b/datrie/libdatrie.def 2017-12-21 02:42:39.873879000 +0300
+@@ -1,3 +1,4 @@
++EXPORTS
+ alpha_map_new
+ alpha_map_clone
+ alpha_map_free
diff --git a/vcpkg/ports/libdatrie/portfile.cmake b/vcpkg/ports/libdatrie/portfile.cmake
new file mode 100644
index 0000000..76e8804
--- /dev/null
+++ b/vcpkg/ports/libdatrie/portfile.cmake
@@ -0,0 +1,40 @@
+set(LIBDATRIE_VERSION 0.2.13)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO tlwg/libdatrie
+ REF v${LIBDATRIE_VERSION}
+ SHA512 38f5a3ee1f3ca0f0601a5fcfeec3892cb34857d4b4720b8e018ca1beb6520c4c10af3bd2f0e4d64367cb256e8e2bca4d0a59b1c81fb36782613d2c258b64df59
+ HEAD_REF master
+ PATCHES
+ 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}")
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ INVERTED_FEATURES
+ tool SKIP_TOOL
+)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -DVERSION=${LIBDATRIE_VERSION}
+ ${FEATURE_OPTIONS}
+ OPTIONS_DEBUG
+ -DSKIP_TOOL=ON
+ -DSKIP_HEADERS=ON
+)
+
+vcpkg_cmake_install()
+vcpkg_copy_pdbs()
+vcpkg_fixup_pkgconfig()
+
+if(NOT SKIP_TOOL)
+ vcpkg_copy_tools(TOOL_NAMES trietool AUTO_CLEAN)
+endif()
+
+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/vcpkg/ports/libdatrie/usage b/vcpkg/ports/libdatrie/usage
new file mode 100644
index 0000000..e63cede
--- /dev/null
+++ b/vcpkg/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:
+
+ find_package(PkgConfig)
+ pkg_check_modules(LIBDATRIE REQUIRED IMPORTED_TARGET datrie-0.2)
+
+ target_link_libraries(main PRIVATE PkgConfig::LIBDATRIE)
diff --git a/vcpkg/ports/libdatrie/vcpkg.json b/vcpkg/ports/libdatrie/vcpkg.json
new file mode 100644
index 0000000..e143b03
--- /dev/null
+++ b/vcpkg/ports/libdatrie/vcpkg.json
@@ -0,0 +1,23 @@
+{
+ "name": "libdatrie",
+ "version": "0.2.13",
+ "port-version": 1,
+ "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": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ }
+ ],
+ "features": {
+ "tool": {
+ "description": "Build the trietool application",
+ "supports": "!uwp",
+ "dependencies": [
+ "libiconv"
+ ]
+ }
+ }
+}