Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gettext]Support Linux and OSX build #8692

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ports/gettext/0001-Fix-macro-definitions.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
diff --git a/gettext-runtime/intl/xsize.h b/gettext-runtime/intl/xsize.h
index c256665..7400ea1 100644
index 9b9840f..0724131 100644
--- a/gettext-runtime/intl/xsize.h
+++ b/gettext-runtime/intl/xsize.h
@@ -27,6 +27,12 @@
# include <stdint.h>
#endif
@@ -30,6 +30,12 @@
/* Get ATTRIBUTE_PURE. */
#include "attribute.h"

+#if defined _WIN32
+# define _GL_INLINE_HEADER_BEGIN
Expand Down
60 changes: 30 additions & 30 deletions ports/gettext/0002-Fix-uwp-build.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
diff --git "a/gettext-runtime/intl/langprefs.c" "b/gettext-runtime/intl/langprefs.c"
index aeb1c4e9..2ac531be 100644
--- "a/gettext-runtime/intl/langprefs.c"
+++ "b/gettext-runtime/intl/langprefs.c"
@@ -33,7 +33,13 @@ extern void _nl_locale_name_canonicalize (char *name);
diff --git a/gettext-runtime/intl/langprefs.c b/gettext-runtime/intl/langprefs.c
index f774ba2..e1f9b32 100644
--- a/gettext-runtime/intl/langprefs.c
+++ b/gettext-runtime/intl/langprefs.c
@@ -37,7 +37,13 @@ extern void _nl_locale_name_canonicalize (char *name);
#endif

#if defined _WIN32 || defined __WIN32__
#if defined _WIN32
-# define WIN32_NATIVE
+# if !defined(WINAPI_FAMILY)
+# define WIN32_NATIVE
Expand All @@ -17,12 +17,12 @@ index aeb1c4e9..2ac531be 100644
#endif

#ifdef WIN32_NATIVE
diff --git "a/gettext-runtime/intl/localcharset.c" "b/gettext-runtime/intl/localcharset.c"
index 670b8e6c..035a96bd 100644
--- "a/gettext-runtime/intl/localcharset.c"
+++ "b/gettext-runtime/intl/localcharset.c"
diff --git a/gettext-runtime/intl/localcharset.c b/gettext-runtime/intl/localcharset.c
index ec75427..3028bc2 100644
--- a/gettext-runtime/intl/localcharset.c
+++ b/gettext-runtime/intl/localcharset.c
@@ -36,6 +36,16 @@
# define WINDOWS_NATIVE
# include <locale.h>
#endif

+#if defined _WIN32 || defined __WIN32__
Expand All @@ -38,32 +38,32 @@ index 670b8e6c..035a96bd 100644
#if defined __EMX__
/* Assume EMX program runs on OS/2, even if compiled under DOS. */
# ifndef OS2
@@ -361,7 +371,7 @@ STATIC
@@ -830,7 +840,7 @@ STATIC
const char *
locale_charset (void)
{
- const char *codeset;
+ const char *codeset = NULL;
const char *aliases;

#if !(defined WINDOWS_NATIVE || defined OS2)
@@ -457,7 +467,7 @@ locale_charset (void)
/* This function must be multithread-safe. To achieve this without using
thread-local storage, we use a simple strcpy or memcpy to fill this static
@@ -912,7 +922,7 @@ locale_charset (void)
/* The canonical name cannot be determined. */
codeset = "";

# endif

-#elif defined WINDOWS_NATIVE
+#elif defined WINDOWS_NATIVE && defined HAVE_ACP

static char buf[2 + 10 + 1];
-# elif defined WINDOWS_NATIVE
+# elif defined WINDOWS_NATIVE && defined HAVE_ACP

diff --git "a/gettext-runtime/intl/localename.c" "b/gettext-runtime/intl/localename.c"
index 108dd6f1..ace3aa88 100644
--- "a/gettext-runtime/intl/localename.c"
+++ "b/gettext-runtime/intl/localename.c"
@@ -54,7 +54,13 @@
char buf[2 + 10 + 1];
static char resultbuf[2 + 10 + 1];
diff --git a/gettext-runtime/intl/localename.c b/gettext-runtime/intl/localename.c
index 6458f75..a615729 100644
--- a/gettext-runtime/intl/localename.c
+++ b/gettext-runtime/intl/localename.c
@@ -73,7 +73,13 @@ extern char * getlocalename_l(int, locale_t);
#endif

#if defined _WIN32 || defined __WIN32__
#if defined _WIN32 && !defined __CYGWIN__
-# define WINDOWS_NATIVE
+# if !defined(WINAPI_FAMILY)
+# define WINDOWS_NATIVE
Expand All @@ -72,6 +72,6 @@ index 108dd6f1..ace3aa88 100644
+# define WINDOWS_NATIVE
+# endif
+# endif
#endif

#if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
# if !defined IN_LIBINTL
# include "glthread/lock.h"
# endif
6 changes: 3 additions & 3 deletions ports/gettext/0003-Fix-win-unicode-paths.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git "a/gettext-runtime/intl/loadmsgcat.c" "b/gettext-runtime/intl/loadmsgcat.c"
index 63351523..c078de3f 100644
diff --git a/gettext-runtime/intl/loadmsgcat.c b/gettext-runtime/intl/loadmsgcat.c
index 016fe57..030b861 100644
--- a/gettext-runtime/intl/loadmsgcat.c
+++ b/gettext-runtime/intl/loadmsgcat.c
@@ -477,6 +477,55 @@ char *alloca ();
@@ -388,6 +388,55 @@ char *alloca ();
# define munmap(addr, len) __munmap (addr, len)
#endif

Expand Down
4 changes: 2 additions & 2 deletions ports/gettext/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: gettext
Version: 0.19-15
Version: 0.21
Homepage: https://www.gnu.org/software/gettext/
Description: The GNU gettext utilities are a set of tools that provides a framework to help other GNU packages produce multi-lingual messages. Provides libintl.
Build-Depends: libiconv
Build-Depends: libiconv, libxml2(!windows)
81 changes: 45 additions & 36 deletions ports/gettext/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
if(VCPKG_TARGET_IS_LINUX)
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
if (NOT EXISTS "/usr/include/libintl.h")
message(FATAL_ERROR "Please use command \"sudo apt-get install gettext\" to install gettext on linux.")
endif()
file(COPY ${CMAKE_CURRENT_LIST_DIR}/unofficial-gettext-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/unofficial-gettext)
return()
else()
set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled)
endif()

#Based on https://github.com/winlibs/gettext
set(VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled)

set(GETTEXT_VERSION 0.19)
set(GETTEXT_VERSION 0.21)

vcpkg_download_distfile(ARCHIVE
URLS "https://ftp.gnu.org/pub/gnu/gettext/gettext-${GETTEXT_VERSION}.tar.gz" "https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gettext/gettext-${GETTEXT_VERSION}.tar.gz"
FILENAME "gettext-${GETTEXT_VERSION}.tar.gz"
SHA512 a5db035c582ff49d45ee6eab9466b2bef918e413a882019c204a9d8903cb3770ddfecd32c971ea7c7b037c7b69476cf7c56dcabc8b498b94ab99f132516c9922
SHA512 bbe590c5dd3580c75bf30ff768da99a88eb8d466ec1ac9eea20be4cab4357ecf72448e6b81b47425e39d50fa6320ba426632914d7898dfebb4f159abc39c31d1
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
Expand All @@ -27,29 +16,49 @@ vcpkg_extract_source_archive_ex(
0002-Fix-uwp-build.patch
0003-Fix-win-unicode-paths.patch
)

file(COPY
${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt
${CMAKE_CURRENT_LIST_DIR}/config.win32.h
${CMAKE_CURRENT_LIST_DIR}/config.unix.h.in
DESTINATION ${SOURCE_PATH}/gettext-runtime
)
file(REMOVE ${SOURCE_PATH}/gettext-runtime/intl/libgnuintl.h ${SOURCE_PATH}/gettext-runtime/config.h)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/libgnuintl.win32.h DESTINATION ${SOURCE_PATH}/gettext-runtime/intl)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/gettext-runtime
PREFER_NINJA
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
)

vcpkg_install_cmake()

vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-gettext TARGET_PATH share/unofficial-gettext)
if (VCPKG_TARGET_IS_WINDOWS)
file(COPY
${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt
${CMAKE_CURRENT_LIST_DIR}/config.win32.h
${CMAKE_CURRENT_LIST_DIR}/config.unix.h.in
DESTINATION ${SOURCE_PATH}/gettext-runtime
)
file(REMOVE ${SOURCE_PATH}/gettext-runtime/intl/libgnuintl.h ${SOURCE_PATH}/gettext-runtime/config.h)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/libgnuintl.win32.h DESTINATION ${SOURCE_PATH}/gettext-runtime/intl)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/gettext-runtime
PREFER_NINJA
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
)

vcpkg_install_cmake()

vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-gettext TARGET_PATH share/unofficial-gettext)
else()
set(GETTEXT_OPTS --disable-java --disable-native-java)
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
set(GETTEXT_OPTS ${GETTEXT_OPTS} --enable-shared)
else()
set(GETTEXT_OPTS ${GETTEXT_OPTS} --enable-static)
endif()

get_filename_component(INSTALLED_PATH "${CURRENT_INSTALLED_DIR}" PATH)

vcpkg_configure_make(
SOURCE_PATH ${SOURCE_PATH}
#COPY_SOURCE
OPTIONS
${GETTEXT_OPTS}
--with-libiconv-prefix=${INSTALLED_PATH}
--with-libxml2-prefix=${INSTALLED_PATH}
)

vcpkg_install_make()
endif()

# Handle copyright
file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/gettext)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/gettext/COPYING ${CURRENT_PACKAGES_DIR}/share/gettext/copyright)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

vcpkg_copy_pdbs()