Skip to content

Commit

Permalink
[gettext] Fix uwp "tools" build (microsoft#22489)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhon authored Jan 12, 2022
1 parent e9734e1 commit d2b1baa
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 2 deletions.
116 changes: 116 additions & 0 deletions ports/gettext/0004-Fix-uwp-tools-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
--- a/gettext-runtime/gnulib-lib/fcntl.c 2022-01-11 11:11:28.406622100 +0700
+++ b/gettext-runtime/gnulib-lib/fcntl.c 2022-01-11 11:11:03.406190800 +0700
@@ -38,6 +38,10 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>

+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
+#define HANDLE_FLAG_INHERIT 0
+#endif
+
/* Get _get_osfhandle. */
# if GNULIB_MSVC_NOTHROW
# include "msvc-nothrow.h"
--- a/gettext-tools/gnulib-lib/fcntl.c 2022-01-11 11:11:28.406622100 +0700
+++ b/gettext-tools/gnulib-lib/fcntl.c 2022-01-11 11:11:03.406190800 +0700
@@ -38,6 +38,10 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>

+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
+#define HANDLE_FLAG_INHERIT 0
+#endif
+
/* Get _get_osfhandle. */
# if GNULIB_MSVC_NOTHROW
# include "msvc-nothrow.h"
--- a/gettext-tools/src/hostname.c 2022-01-12 01:41:13.725124300 +0700
+++ b/gettext-tools/src/hostname.c 2022-01-12 01:47:39.384274300 +0700
@@ -35,15 +35,15 @@
/* Get gethostname(). */
#include <unistd.h>

+#if !HAVE_GETHOSTNAME
#ifdef WIN32_NATIVE
/* Native Woe32 API lacks gethostname() but has GetComputerName() instead. */
# include <windows.h>
#else
/* Some systems, like early Solaris versions, lack gethostname() but
have uname() instead. */
-# if !HAVE_GETHOSTNAME
-# include <sys/utsname.h>
-# endif
+# include <sys/utsname.h>
+#endif
#endif

/* Get MAXHOSTNAMELEN. */
@@ -56,6 +56,9 @@

/* Support for using gethostbyname(). */
#if HAVE_GETHOSTBYNAME
+#if HAVE_WINSOCK2_H
+# include <winsock2.h>
+#else
# include <sys/types.h>
# include <sys/socket.h> /* defines AF_INET, AF_INET6 */
# include <netinet/in.h> /* declares ntohs(), defines struct sockaddr_in */
@@ -77,6 +80,7 @@
# endif
# include <netdb.h> /* defines struct hostent, declares gethostbyname() */
#endif
+#endif

/* Include this after <sys/socket.h>, to avoid a syntax error on BeOS. */
#include <stdbool.h>
@@ -250,7 +254,7 @@
static char *
xgethostname ()
{
-#ifdef WIN32_NATIVE
+#ifdef WIN32_NATIVE && !HAVE_GETHOSTNAME
char hostname[MAX_COMPUTERNAME_LENGTH+1];
DWORD size = sizeof (hostname);

--- a/libtextstyle/lib/fcntl.c 2020-06-27 03:00:38.000000000 +0700
+++ b/libtextstyle/lib/fcntl.c 2022-01-11 11:10:29.936269800 +0700
@@ -38,6 +38,10 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>

+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
+#define HANDLE_FLAG_INHERIT 0
+#endif
+
/* Get _get_osfhandle. */
# if GNULIB_MSVC_NOTHROW
# include "msvc-nothrow.h"
--- a/libtextstyle/lib/isatty.c 2020-06-27 03:00:40.000000000 +0700
+++ b/libtextstyle/lib/isatty.c 2022-01-11 11:19:04.852685700 +0700
@@ -99,6 +99,7 @@
BOOL result = FALSE;
ULONG processId;

+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY != WINAPI_FAMILY_APP)
#if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
if (!initialized)
initialize ();
@@ -137,6 +138,7 @@
CloseHandle (processHandle);
}
}
+#endif // !WINAPI_FAMILY_APP
return result;
}

--- a/libtextstyle/lib/unistd.in.h 2020-07-08 08:33:18.000000000 +0700
+++ b/libtextstyle/lib/unistd.in.h 2022-01-11 22:11:46.402435600 +0700
@@ -828,7 +828,7 @@
Null terminate it if the name is shorter than LEN.
If the host name is longer than LEN, set errno = EINVAL and return -1.
Return 0 if successful, otherwise set errno and return -1. */
-# if @UNISTD_H_HAVE_WINSOCK2_H@
+# if !@HAVE_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef gethostname
# define gethostname rpl_gethostname
1 change: 1 addition & 0 deletions ports/gettext/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ vcpkg_extract_source_archive_ex(
PATCHES
0002-Fix-uwp-build.patch
0003-Fix-win-unicode-paths.patch
0004-Fix-uwp-tools-build.patch
rel_path.patch
android.patch
gettext-tools_woe32dll_gettextsrc-exports.c.patch
Expand Down
2 changes: 1 addition & 1 deletion ports/gettext/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gettext",
"version": "0.21",
"port-version": 8,
"port-version": 9,
"description": "GNU gettext provides libintl and a set of tools to help produce multi-lingual messages.",
"homepage": "https://www.gnu.org/software/gettext/",
"dependencies": [
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,7 @@
},
"gettext": {
"baseline": "0.21",
"port-version": 8
"port-version": 9
},
"gettimeofday": {
"baseline": "2017-10-14",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/gettext.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "5bf45743516e2ae999eb14017370828e237ad533",
"version": "0.21",
"port-version": 9
},
{
"git-tree": "d1dc6ee2684911bfcb6f63c498413a118c235ba5",
"version": "0.21",
Expand Down

0 comments on commit d2b1baa

Please sign in to comment.