diff options
Diffstat (limited to 'vcpkg/ports/gettext-libintl')
| -rw-r--r-- | vcpkg/ports/gettext-libintl/0003-Fix-win-unicode-paths.patch | 62 | ||||
| -rw-r--r-- | vcpkg/ports/gettext-libintl/bashify.cmake | 16 | ||||
| -rw-r--r-- | vcpkg/ports/gettext-libintl/detect/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | vcpkg/ports/gettext-libintl/portfile.cmake | 126 | ||||
| -rw-r--r-- | vcpkg/ports/gettext-libintl/usage | 4 | ||||
| -rw-r--r-- | vcpkg/ports/gettext-libintl/uwp.patch | 39 | ||||
| -rw-r--r-- | vcpkg/ports/gettext-libintl/vcpkg-cmake-wrapper.cmake | 23 | ||||
| -rw-r--r-- | vcpkg/ports/gettext-libintl/vcpkg.json | 19 |
8 files changed, 305 insertions, 0 deletions
diff --git a/vcpkg/ports/gettext-libintl/0003-Fix-win-unicode-paths.patch b/vcpkg/ports/gettext-libintl/0003-Fix-win-unicode-paths.patch new file mode 100644 index 0000000..e15e087 --- /dev/null +++ b/vcpkg/ports/gettext-libintl/0003-Fix-win-unicode-paths.patch @@ -0,0 +1,62 @@ +diff --git a/gettext-runtime/intl/loadmsgcat.c b/gettext-runtime/intl/loadmsgcat.c +index d5a5fe1..5c47f48 100644 +--- a/gettext-runtime/intl/loadmsgcat.c ++++ b/gettext-runtime/intl/loadmsgcat.c +@@ -390,9 +390,56 @@ char *alloca (); + # define munmap(addr, len) __munmap (addr, len) + #elif defined _WIN32 && !defined __CYGWIN__ + /* On native Windows, don't require linking with '-loldnames'. */ +-# define open _open ++# define open(name, flags) _open_utf8_windows_wrapper(name, flags) + # define read _read + # define close _close ++ ++/* Provide wrapper of "open" for Windows that supports UTF-8 filenames. */ ++# ifndef WIN32_LEAN_AND_MEAN ++# define WIN32_LEAN_AND_MEAN ++# endif ++# ifndef WIN32_EXTRA_LEAN ++# define WIN32_EXTRA_LEAN ++# endif ++# ifndef NOMINMAX ++# define NOMINMAX ++# endif ++# include <windows.h> // For: MultiByteToWideChar ++# include <io.h> ++# include <wchar.h> ++ ++int _open_utf8_windows_wrapper( ++ const char *filename, ++ int flags ++) ++{ ++ int wstr_len = -1; ++ wchar_t* pUtf16FileName = NULL; ++ int fh = -1; ++ ++ // on Windows, convert the filename from UTF-8 to UTF-16 ++ wstr_len = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0); ++ if (wstr_len <= 0) ++ { ++ // MultiByteToWideChar failed ++ errno = ENOENT; ++ return -1; ++ } ++ pUtf16FileName = malloc(wstr_len * sizeof(wchar_t)); ++ if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, pUtf16FileName, wstr_len) == 0) ++ { ++ // MultiByteToWideChar failed ++ free(pUtf16FileName); ++ errno = ENOENT; ++ return -1; ++ } ++ ++ // and call _wopen ++ fh = _wopen(pUtf16FileName, flags); ++ ++ free(pUtf16FileName); ++ return fh; ++} + #endif + + /* For those losing systems which don't have `alloca' we have to add diff --git a/vcpkg/ports/gettext-libintl/bashify.cmake b/vcpkg/ports/gettext-libintl/bashify.cmake new file mode 100644 index 0000000..8b3d87e --- /dev/null +++ b/vcpkg/ports/gettext-libintl/bashify.cmake @@ -0,0 +1,16 @@ +# By using bash builtin expansion, we can avoid +# expensively spawing three sub-processes (bash, echo, sed). +foreach(dir IN LISTS SOURCE_DIRS) + file(READ "${dir}/configure" script) + string(REGEX REPLACE + "(\n[a-zA-Z0-9_]*)='`[\$]ECHO \"[\$]([^\"]*)\" \\| [\$]SED \"[\$]delay_single_quote_subst\"`'" + [[\1='${\2//\\'/\\'\\\\\\'\\'}']] + script "${script}" + ) + string(REPLACE + [[ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in]] + [[ case "\${!var}" in]] + script "${script}" + ) + file(WRITE "${dir}/configure" "${script}") +endforeach() diff --git a/vcpkg/ports/gettext-libintl/detect/CMakeLists.txt b/vcpkg/ports/gettext-libintl/detect/CMakeLists.txt new file mode 100644 index 0000000..b1a87fd --- /dev/null +++ b/vcpkg/ports/gettext-libintl/detect/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.20) +project(find-libintl C) + +set(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/detected_intl.cmake" CACHE FILEPATH "Where to store results") + +find_package(Intl) +find_file(LIBINTL_H NAMES libintl.h PATHS ${Intl_INCLUDE_DIRS}) + +string(CONFIGURE [[ +set(VCPKG_DETECTED_Intl_FOUND "@Intl_FOUND@") +set(VCPKG_DETECTED_Intl_IS_BUILT_IN "@Intl_IS_BUILT_IN@") +set(VCPKG_DETECTED_Intl_INCLUDE_DIRS "@Intl_INCLUDE_DIRS@") +set(VCPKG_DETECTED_LIBINTL_H "@LIBINTL_H@") +]] detected_intl @ONLY ESCAPE_QUOTES) + +file(WRITE "${OUTFILE}" "${detected_intl}") diff --git a/vcpkg/ports/gettext-libintl/portfile.cmake b/vcpkg/ports/gettext-libintl/portfile.cmake new file mode 100644 index 0000000..987ae00 --- /dev/null +++ b/vcpkg/ports/gettext-libintl/portfile.cmake @@ -0,0 +1,126 @@ +if(VCPKG_TARGET_IS_LINUX AND NOT X_VCPKG_FORCE_VCPKG_GETTEXT_LIBINTL) + set(detection_results "${CURRENT_BUILDTREES_DIR}/detected-intl-${TARGET_TRIPLET}.cmake.log") + file(REMOVE "${detection_results}") + block(SCOPE_FOR VARIABLES) + set(VCPKG_BUILD_TYPE release) + vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/detect" OPTIONS "-DOUTFILE=${detection_results}") + endblock() + include("${detection_results}") + message(STATUS "libintl header: ${VCPKG_DETECTED_LIBINTL_H}") + if(NOT VCPKG_DETECTED_LIBINTL_H) + message(FATAL_ERROR + "When targeting Linux, `libintl.h` is expected to come from a system package. " + "Please use the following commands or the equivalent to install development files.\n" + "On Debian and Ubuntu derivatives: \"sudo apt-get install libc-dev\"\n" + "On Alpine: \"apk add gettext-dev\"\n" + ) + endif() + + set(VCPKG_POLICY_EMPTY_PACKAGE enabled) + file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + return() +endif() + +set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled) + +vcpkg_download_distfile(ARCHIVE + URLS "https://ftpmirror.gnu.org/gnu/gettext/gettext-${VERSION}.tar.gz" + "https://ftp.gnu.org/pub/gnu/gettext/gettext-${VERSION}.tar.gz" + "https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gettext/gettext-${VERSION}.tar.gz" + FILENAME "gettext-${VERSION}.tar.gz" + SHA512 d8b22d7fba10052a2045f477f0a5b684d932513bdb3b295c22fbd9dfc2a9d8fccd9aefd90692136c62897149aa2f7d1145ce6618aa1f0be787cb88eba5bc09be +) + +vcpkg_extract_source_archive(SOURCE_PATH + ARCHIVE "${ARCHIVE}" + PATCHES + uwp.patch + 0003-Fix-win-unicode-paths.patch +) + +if(VCPKG_HOST_IS_WINDOWS) + message(STATUS "Modifying 'configure' to use fast bash variable expansion") + set(ENV{CONFIG_SHELL} "/usr/bin/bash") + vcpkg_execute_required_process( + COMMAND "${CMAKE_COMMAND}" + "-DSOURCE_DIRS=gettext-runtime" + -P "${CMAKE_CURRENT_LIST_DIR}/bashify.cmake" + WORKING_DIRECTORY "${SOURCE_PATH}" + LOGNAME "bashify-${TARGET_TRIPLET}" + ) +endif() + +set(OPTIONS + --no-recursion + --enable-relocatable #symbol duplication with glib-init.c? + --with-included-gettext + --without-libintl-prefix + --disable-dependency-tracking + ac_cv_path_GMSGFMT=false + ac_cv_path_MSGFMT=false + ac_cv_path_MSGMERGE=false + ac_cv_path_XGETTEXT=false + ac_cv_prog_INTLBISON=false +) +if(VCPKG_TARGET_IS_WINDOWS) + list(APPEND OPTIONS + # Avoid unnecessary tests. + am_cv_func_iconv_works=yes + # This is required. For some reason these do not get correctly identified for release builds. + ac_cv_func_wcslen=yes + ac_cv_func_memmove=yes + # May trigger debugger window in debug builds, even in unattended builds. + # Cf. https://github.com/microsoft/vcpkg/issues/35974 + gl_cv_func_printf_directive_n=no + ) + if(NOT VCPKG_TARGET_IS_MINGW) + list(APPEND OPTIONS + # Don't take from port getopt-win32 + ac_cv_header_getopt_h=no + # Don't take from port pthreads + ac_cv_header_pthread_h=no + # Detected 'no' everywhere except x64-windows-static + ac_cv_func_snprintf=no + # Detected x64 values for gnulib, overriding guesses for cross builds + gl_cv_func_mbrtowc_empty_input=no + # Detected x64 values for gettext, overriding guesses for x86 & x64-uwp + gt_cv_int_divbyzero_sigfpe=no + ) + endif() +endif() + +file(REMOVE "${CURRENT_BUILDTREES_DIR}/config.cache-${TARGET_TRIPLET}-rel.log") +file(REMOVE "${CURRENT_BUILDTREES_DIR}/config.cache-${TARGET_TRIPLET}-dbg.log") +vcpkg_make_configure( + SOURCE_PATH "${SOURCE_PATH}/gettext-runtime/intl" + OPTIONS + ${OPTIONS} + OPTIONS_RELEASE + "--cache-file=${CURRENT_BUILDTREES_DIR}/config.cache-${TARGET_TRIPLET}-rel.log" + OPTIONS_DEBUG + "--cache-file=${CURRENT_BUILDTREES_DIR}/config.cache-${TARGET_TRIPLET}-dbg.log" + ) + +# This helps with Windows build times, but should work everywhere in vcpkg. +# - Avoid an extra command to move a temporary file, we are building out of source. +# - Avoid a subshell just to add comments, the build dir is temporary. +# - Avoid cygpath -w when other tools handle this for us. +file(GLOB_RECURSE makefiles "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}*/Makefile") +foreach(file IN LISTS makefiles) + file(READ "${file}" rules) + string(REGEX REPLACE "(\n\ttest -d [^ ]* [|][|] [\$][(]MKDIR_P[)][^\n;]*)(\n\t)" "\\1 || exit 1 ; \\\\\\2" rules "${rules}") + string(REGEX REPLACE "(\n\t){ echo '/[*] [^*]* [*]/'; \\\\\n\t cat ([^;\n]*); \\\\\n\t[}] > [\$]@-t\n\tmv -f [\$]@-t ([\$]@\n)" "\\1cp \\2 \\3" rules "${rules}") + string(REGEX REPLACE " > [\$]@-t\n\t[\$][(]AM_V_at[)]mv [\$]@-t ([\$]@\n)" "> \\1" rules "${rules}") + string(REGEX REPLACE "([\$}[(]COMPILE[)] -c -o [\$]@) `[\$][(]CYGPATH_W[)] '[\$]<'`" "\\1 \$<" rules "${rules}") + string(REPLACE " ../config.h" " config.h" rules "${rules}") + file(WRITE "${file}" "${rules}") +endforeach() + +vcpkg_make_install() +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +file(COPY "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/intl") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/gettext-runtime/intl/COPYING.LIB") diff --git a/vcpkg/ports/gettext-libintl/usage b/vcpkg/ports/gettext-libintl/usage new file mode 100644 index 0000000..35472de --- /dev/null +++ b/vcpkg/ports/gettext-libintl/usage @@ -0,0 +1,4 @@ +gettext-libintl is compatible with built-in CMake targets:
+
+ find_package(Intl REQUIRED)
+ target_link_libraries(main PRIVATE Intl::Intl) # since CMake 3.20
diff --git a/vcpkg/ports/gettext-libintl/uwp.patch b/vcpkg/ports/gettext-libintl/uwp.patch new file mode 100644 index 0000000..c16a0f5 --- /dev/null +++ b/vcpkg/ports/gettext-libintl/uwp.patch @@ -0,0 +1,39 @@ +diff --git a/gettext-runtime/intl/langprefs.c b/gettext-runtime/intl/langprefs.c +index f774ba2..f488b7f 100644 +--- a/gettext-runtime/intl/langprefs.c ++++ b/gettext-runtime/intl/langprefs.c +@@ -38,6 +38,11 @@ extern void _nl_locale_name_canonicalize (char *name); + + #if defined _WIN32 + # define WIN32_NATIVE ++# if defined(WINAPI_FAMILY_PARTITION) ++# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) ++# undef WIN32_NATIVE ++# endif ++# endif + #endif + + #ifdef WIN32_NATIVE +diff --git a/gettext-runtime/intl/gnulib-lib/localcharset.c b/gettext-runtime/intl/gnulib-lib/localcharset.c +index ec75427..9e063e4 100644 +--- a/gettext-runtime/intl/gnulib-lib/localcharset.c ++++ b/gettext-runtime/intl/gnulib-lib/localcharset.c +@@ -34,6 +34,9 @@ + #if defined _WIN32 && !defined __CYGWIN__ + # define WINDOWS_NATIVE + # include <locale.h> ++# if !defined(WINAPI_FAMILY_PARTITION) ++# define WINAPI_FAMILY_PARTITION(x) (0) ++# endif + #endif + + #if defined __EMX__ +@@ -912,6 +915,8 @@ locale_charset (void) + /* The canonical name cannot be determined. */ + codeset = ""; + ++# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) ++ codeset = ""; + # elif defined WINDOWS_NATIVE + + char buf[2 + 10 + 1]; diff --git a/vcpkg/ports/gettext-libintl/vcpkg-cmake-wrapper.cmake b/vcpkg/ports/gettext-libintl/vcpkg-cmake-wrapper.cmake new file mode 100644 index 0000000..10708b6 --- /dev/null +++ b/vcpkg/ports/gettext-libintl/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,23 @@ +_find_package(${ARGS}) + +if(Intl_FOUND AND Intl_LIBRARIES) + include(SelectLibraryConfigurations) + find_library(Intl_LIBRARY_DEBUG NAMES intl libintl intl-8 NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH) + find_library(Intl_LIBRARY_RELEASE NAMES intl libintl intl-8 NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH) + unset(Intl_LIBRARIES) + unset(Intl_LIBRARIES CACHE) + select_library_configurations(Intl) + find_package(Iconv) # Since CMake 3.11 + if(Iconv_FOUND AND NOT Iconv_IS_BUILT_IN) + list(APPEND Intl_LIBRARIES ${Iconv_LIBRARIES}) + if(TARGET Intl::Intl) # Since CMake 3.20 + set_property(TARGET Intl::Intl APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<LINK_ONLY:Iconv::Iconv>) + endif() + endif() + if(APPLE) + list(APPEND Intl_LIBRARIES "-framework CoreFoundation") + if(TARGET Intl::Intl) # Since CMake 3.20 + set_property(TARGET Intl::Intl APPEND PROPERTY INTERFACE_LINK_LIBRARIES "$<LINK_ONLY:-framework CoreFoundation>") + endif() + endif() +endif() diff --git a/vcpkg/ports/gettext-libintl/vcpkg.json b/vcpkg/ports/gettext-libintl/vcpkg.json new file mode 100644 index 0000000..d7e1d52 --- /dev/null +++ b/vcpkg/ports/gettext-libintl/vcpkg.json @@ -0,0 +1,19 @@ +{ + "name": "gettext-libintl", + "version": "0.22.5", + "port-version": 4, + "description": "The libintl C library from GNU gettext-runtime.", + "homepage": "https://www.gnu.org/software/gettext/", + "license": "LGPL-2.1-or-later", + "supports": "!xbox", + "dependencies": [ + { + "name": "libiconv", + "platform": "!linux" + }, + { + "name": "vcpkg-make", + "host": true + } + ] +} |