contrib: freetype2: replace the UWP patch to fix bogus CreateFileA call

Patch merged upstream

(cherry picked from commit 54088315e1)

Signed-off-by: Steve Lhomme <robux4@ycbcr.xyz>
This commit is contained in:
Steve Lhomme 2022-02-15 09:08:54 +01:00
parent 0cc084b032
commit 5834265562
4 changed files with 130 additions and 39 deletions

View File

@ -0,0 +1,49 @@
From 20ec99be7ecfd1a07e1ff7a7ef3e510203ea33bd Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Thu, 17 Feb 2022 13:35:52 -0500
Subject: [PATCH] [builds/windows] Add support for legacy UWP builds.
* builds/windows/ftsystem.c: Add neccessary macro substitutions to
enable strict UWP builds.
See !141.
Co-authored-by: Alexei Podtelezhnikov <apodtele@gmail.com>
---
builds/windows/ftsystem.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/builds/windows/ftsystem.c b/builds/windows/ftsystem.c
index 1c49f30db..d4fc95675 100644
--- a/builds/windows/ftsystem.c
+++ b/builds/windows/ftsystem.c
@@ -196,7 +196,25 @@
}
-#ifdef _WIN32_WCE
+#if defined( NTDDI_VERSION ) && NTDDI_VERSION < 0x0A000007 && \
+ defined( WINAPI_FAMILY_PARTITION ) && \
+ !WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_DESKTOP )
+
+#define PACK_DWORD64( hi, lo ) ( ( (DWORD64)(hi) << 32 ) | (DWORD)(lo) )
+
+#define CreateFileW( a, b, c, d, e, f, g ) \
+ CreateFileFromAppW( a, b, c, d, e, f, g )
+#define CreateFileMapping( a, b, c, d, e, f ) \
+ CreateFileMappingFromApp( a, b, c, PACK_DWORD64( d, e ), f )
+#define MapViewOfFile( a, b, c, d, e ) \
+ MapViewOfFileFromApp( a, b, PACK_DWORD64( c, d ), e )
+
+#define UWP_LEGACY
+
+#endif
+
+
+#if defined( _WIN32_WCE ) || defined( UWP_LEGACY )
FT_LOCAL_DEF( HANDLE )
CreateFileA( LPCSTR lpFileName,
--
2.27.0.windows.1

View File

@ -0,0 +1,79 @@
From 1f951898751365e9bd2a920ce76652f2a59c3305 Mon Sep 17 00:00:00 2001
From: Cameron Cawley <ccawley2011@gmail.com>
Date: Mon, 6 Dec 2021 23:08:46 -0500
Subject: [PATCH] [builds/windows] Guard some non-ancient API.
We can support Windows 98 and NT 4.0 in principle...
* builds/windows/ftdebug.c, builds/windows/ftsystem.c: Check for the
ancient SDK using _WIN32_WINDOWS, _WIN32_WCE, or _WIN32_WINNT.
---
builds/windows/ftdebug.c | 6 ++++++
builds/windows/ftsystem.c | 6 +++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/builds/windows/ftdebug.c b/builds/windows/ftdebug.c
index 94c22da75..ff5d4b481 100644
--- a/builds/windows/ftdebug.c
+++ b/builds/windows/ftdebug.c
@@ -136,6 +136,8 @@
va_start( ap, fmt );
vfprintf( stderr, fmt, ap );
+#if ( defined( _WIN32_WINNT ) && _WIN32_WINNT >= 0x0400 ) || \
+ ( defined( _WIN32_WCE ) && _WIN32_WCE >= 0x0600 )
if ( IsDebuggerPresent() )
{
static char buf[1024];
@@ -144,6 +146,7 @@
vsnprintf( buf, sizeof buf, fmt, ap );
OutputDebugStringA( buf );
}
+#endif
va_end( ap );
}
@@ -159,6 +162,8 @@
va_start( ap, fmt );
vfprintf( stderr, fmt, ap );
+#if ( defined( _WIN32_WINNT ) && _WIN32_WINNT >= 0x0400 ) || \
+ ( defined( _WIN32_WCE ) && _WIN32_WCE >= 0x0600 )
if ( IsDebuggerPresent() )
{
static char buf[1024];
@@ -167,6 +172,7 @@
vsnprintf( buf, sizeof buf, fmt, ap );
OutputDebugStringA( buf );
}
+#endif
va_end( ap );
exit( EXIT_FAILURE );
diff --git a/builds/windows/ftsystem.c b/builds/windows/ftsystem.c
index 1ebadd49f..0433d6151 100644
--- a/builds/windows/ftsystem.c
+++ b/builds/windows/ftsystem.c
@@ -233,6 +233,10 @@
dwFlagsAndAttributes, hTemplateFile );
}
+#endif
+
+#if defined( _WIN32_WCE ) || defined ( _WIN32_WINDOWS ) || \
+ !defined( _WIN32_WINNT ) || _WIN32_WINNT <= 0x0400
FT_LOCAL_DEF( BOOL )
GetFileSizeEx( HANDLE hFile,
@@ -248,7 +252,7 @@
return TRUE;
}
-#endif /* _WIN32_WCE */
+#endif
/* documentation is in ftobjs.h */
--
2.27.0.windows.1

View File

@ -15,7 +15,8 @@ $(TARBALLS)/freetype-$(FREETYPE2_VERSION).tar.xz:
freetype: freetype-$(FREETYPE2_VERSION).tar.xz .sum-freetype2
$(UNPACK)
$(APPLY) $(SRC)/freetype2/uwpfixes.patch
$(APPLY) $(SRC)/freetype2/0001-builds-windows-Guard-some-non-ancient-API.patch
$(APPLY) $(SRC)/freetype2/0001-builds-windows-Add-support-for-legacy-UWP-builds.patch
$(call pkg_static, "builds/unix/freetype2.in")
$(MOVE)

View File

@ -1,38 +0,0 @@
diff --git a/builds/windows/ftsystem.c b/builds/windows/ftsystem.c
index 1ebadd49f..ac8ff1f92 100644
--- a/builds/windows/ftsystem.c
+++ b/builds/windows/ftsystem.c
@@ -28,6 +28,7 @@
/* memory mapping and allocation includes and definitions */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#include <winapifamily.h>
/**************************************************************************
@@ -296,7 +297,11 @@
goto Fail_Open;
}
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
fm = CreateFileMapping( file, NULL, PAGE_READONLY, 0, 0, NULL );
+#else
+ fm = CreateFileMappingFromApp( file, NULL, PAGE_READONLY, 0, NULL );
+#endif
if ( fm == NULL )
{
FT_ERROR(( "FT_Stream_Open: can not map file\n" ));
@@ -308,8 +313,13 @@
/* a size greater than LONG_MAX */
stream->size = size.LowPart;
stream->pos = 0;
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
stream->base = (unsigned char *)
MapViewOfFile( fm, FILE_MAP_READ, 0, 0, 0 );
+#else
+ stream->base = (unsigned char *)
+ MapViewOfFileFromApp( fm, FILE_MAP_READ, 0, 0 );
+#endif
CloseHandle( fm );