Patch thirdy-party libraries to build for WinRT
- Patch enet code. - Patch OpenSSL code and add shims for unavailable API. - Add extra definition header for Freetype.
This commit is contained in:
parent
c51f54749f
commit
1cb77c3684
@ -642,6 +642,7 @@ openssl_sources = [
|
|||||||
|
|
||||||
# env.drivers_sources+=openssl_sources
|
# env.drivers_sources+=openssl_sources
|
||||||
|
|
||||||
|
env.Append(CPPPATH=["#drivers/builtin_openssl2"])
|
||||||
env_drivers.Append(CPPPATH=["#drivers/builtin_openssl2/crypto"])
|
env_drivers.Append(CPPPATH=["#drivers/builtin_openssl2/crypto"])
|
||||||
env_drivers.Append(CPPPATH=["#drivers/builtin_openssl2/openssl"])
|
env_drivers.Append(CPPPATH=["#drivers/builtin_openssl2/openssl"])
|
||||||
env_drivers.Append(CPPPATH=["#drivers/builtin_openssl2/crypto/evp"])
|
env_drivers.Append(CPPPATH=["#drivers/builtin_openssl2/crypto/evp"])
|
||||||
@ -650,6 +651,9 @@ env_drivers.Append(CPPPATH=["#drivers/builtin_openssl2/crypto/modes"])
|
|||||||
# env_ssl.Append(CPPPATH=["#drivers/builtin_openssl2/crypto/store"])
|
# env_ssl.Append(CPPPATH=["#drivers/builtin_openssl2/crypto/store"])
|
||||||
env_drivers.Append(CPPFLAGS=["-DOPENSSL_NO_ASM", "-DOPENSSL_THREADS", "-DL_ENDIAN"])
|
env_drivers.Append(CPPFLAGS=["-DOPENSSL_NO_ASM", "-DOPENSSL_THREADS", "-DL_ENDIAN"])
|
||||||
|
|
||||||
|
if "platform" in env and env["platform"] == "winrt":
|
||||||
|
openssl_sources += ['winrt.cpp']
|
||||||
|
|
||||||
# Workaround for compilation error with GCC/Clang when -Werror is too greedy (GH-4517)
|
# Workaround for compilation error with GCC/Clang when -Werror is too greedy (GH-4517)
|
||||||
import os
|
import os
|
||||||
if not (os.name == "nt" and os.getenv("VSINSTALLDIR") != None): # not Windows and not MSVC
|
if not (os.name == "nt" and os.getenv("VSINSTALLDIR") != None): # not Windows and not MSVC
|
||||||
|
127
drivers/builtin_openssl2/winrt.cpp
Normal file
127
drivers/builtin_openssl2/winrt.cpp
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/* Snippets extracted from https://github.com/Microsoft/openssl/blob/ec7e430e06e4e3ac87c183dee33cb216814cf980/ms/winrt.cpp
|
||||||
|
* Adapted for Godot definitions
|
||||||
|
*/
|
||||||
|
/* winrt.cpp
|
||||||
|
* Copyright 2014 Microsoft Corporation
|
||||||
|
* C++/CX Entropy/shims for Windows Phone/Windows Store platform
|
||||||
|
* written by Alejandro Jimenez Martinez
|
||||||
|
* (aljim@microsoft.com) for the OpenSSL project 2014.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#if defined(WINAPI_FAMILY)
|
||||||
|
extern "C" {
|
||||||
|
unsigned entropyRT(BYTE *buffer, unsigned len);
|
||||||
|
void RAND_add(const void *buf, int num, double entropy);
|
||||||
|
int RAND_poll(void);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
unsigned entropyRT(BYTE *buffer, unsigned len) {
|
||||||
|
using namespace Platform;
|
||||||
|
using namespace Windows::Foundation;
|
||||||
|
using namespace Windows::Foundation::Collections;
|
||||||
|
using namespace Windows::Security::Cryptography;
|
||||||
|
using namespace Windows::Storage::Streams;
|
||||||
|
IBuffer ^ buf = CryptographicBuffer::GenerateRandom(len);
|
||||||
|
Array<unsigned char> ^ arr;
|
||||||
|
CryptographicBuffer::CopyToByteArray(buf, &arr);
|
||||||
|
unsigned arrayLen = arr->Length;
|
||||||
|
|
||||||
|
// Make sure not to overflow the copy
|
||||||
|
arrayLen = (arrayLen > len) ? len : arrayLen;
|
||||||
|
memcpy(buffer, arr->Data, arrayLen);
|
||||||
|
return arrayLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RAND_poll(void) {
|
||||||
|
BYTE buf[60];
|
||||||
|
unsigned collected = entropyRT(buf, sizeof(buf));
|
||||||
|
RAND_add(buf, collected, collected);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(WINRT_ENABLED)
|
||||||
|
extern "C" {
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void *GetModuleHandle(
|
||||||
|
_In_opt_ LPCTSTR lpModuleName) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
//no log for phone
|
||||||
|
int RegisterEventSource(
|
||||||
|
_In_ LPCTSTR lpUNCServerName,
|
||||||
|
_In_ LPCTSTR lpSourceName) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ReportEvent(
|
||||||
|
_In_ HANDLE hEventLog,
|
||||||
|
_In_ WORD wType,
|
||||||
|
_In_ WORD wCategory,
|
||||||
|
_In_ DWORD dwEventID,
|
||||||
|
_In_ PSID lpUserSid,
|
||||||
|
_In_ WORD wNumStrings,
|
||||||
|
_In_ DWORD dwDataSize,
|
||||||
|
_In_ LPCTSTR *lpStrings,
|
||||||
|
_In_ LPVOID lpRawData) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int MessageBox(
|
||||||
|
_In_opt_ HWND hWnd,
|
||||||
|
_In_opt_ LPCTSTR lpText,
|
||||||
|
_In_opt_ LPCTSTR lpCaption,
|
||||||
|
_In_ UINT uType) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int __cdecl GetProcessWindowStation(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
BOOL __cdecl GetUserObjectInformationW(
|
||||||
|
_In_ HANDLE hObj,
|
||||||
|
_In_ int nIndex,
|
||||||
|
_Out_opt_ PVOID pvInfo,
|
||||||
|
_In_ DWORD nLength,
|
||||||
|
_Out_opt_ LPDWORD lpnLengthNeeded) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int __cdecl GetStdHandle(
|
||||||
|
_In_ DWORD nStdHandle) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
BOOL DeregisterEventSource(
|
||||||
|
_Inout_ HANDLE hEventLog) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
char *getenv(
|
||||||
|
const char *varname) {
|
||||||
|
//hardcoded environmental variables used for the appx testing application for store/phone
|
||||||
|
if (!strcmp(varname, "OPENSSL_CONF")) {
|
||||||
|
return "./openssl.cnf";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int setenv(const char *envname, const char *envval, int overwrite) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int _getch(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int _kbhit() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
BOOL __cdecl FlushConsoleInputBuffer(
|
||||||
|
_In_ HANDLE hConsoleInput) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int winrt_GetTickCount(void) {
|
||||||
|
LARGE_INTEGER t;
|
||||||
|
return (int)(QueryPerformanceCounter(&t) ? t.QuadPart : 0);
|
||||||
|
}
|
||||||
|
void *OPENSSL_UplinkTable[26] = { 0 };
|
||||||
|
} //extern C
|
||||||
|
|
||||||
|
#endif /*defined(WINRT_ENABLED)*/
|
64
drivers/builtin_openssl2/winrt_fix.patch
Normal file
64
drivers/builtin_openssl2/winrt_fix.patch
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
diff --git a/drivers/builtin_openssl2/crypto/rand/rand_win.c b/drivers/builtin_openssl2/crypto/rand/rand_win.c
|
||||||
|
index 06670ae..70fd52a 100644
|
||||||
|
--- a/drivers/builtin_openssl2/crypto/rand/rand_win.c
|
||||||
|
+++ b/drivers/builtin_openssl2/crypto/rand/rand_win.c
|
||||||
|
@@ -118,8 +118,10 @@
|
||||||
|
# ifndef _WIN32_WINNT
|
||||||
|
# define _WIN32_WINNT 0x0400
|
||||||
|
# endif
|
||||||
|
+#ifndef WINRT_ENABLED
|
||||||
|
# include <wincrypt.h>
|
||||||
|
# include <tlhelp32.h>
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Limit the time spent walking through the heap, processes, threads and
|
||||||
|
@@ -161,7 +163,7 @@ typedef struct tagCURSORINFO {
|
||||||
|
# define CURSOR_SHOWING 0x00000001
|
||||||
|
# endif /* CURSOR_SHOWING */
|
||||||
|
|
||||||
|
-# if !defined(OPENSSL_SYS_WINCE)
|
||||||
|
+# if !defined(OPENSSL_SYS_WINCE) && !defined(WINRT_ENABLED)
|
||||||
|
typedef BOOL(WINAPI *CRYPTACQUIRECONTEXTW) (HCRYPTPROV *, LPCWSTR, LPCWSTR,
|
||||||
|
DWORD, DWORD);
|
||||||
|
typedef BOOL(WINAPI *CRYPTGENRANDOM) (HCRYPTPROV, DWORD, BYTE *);
|
||||||
|
@@ -196,6 +198,7 @@ typedef NET_API_STATUS(NET_API_FUNCTION *NETFREE) (LPBYTE);
|
||||||
|
# endif /* 1 */
|
||||||
|
# endif /* !OPENSSL_SYS_WINCE */
|
||||||
|
|
||||||
|
+#if !defined(WINRT_ENABLED)
|
||||||
|
int RAND_poll(void)
|
||||||
|
{
|
||||||
|
MEMORYSTATUS m;
|
||||||
|
@@ -580,6 +583,8 @@ int RAND_poll(void)
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#endif // WINRT_ENABLED
|
||||||
|
+
|
||||||
|
int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
double add_entropy = 0;
|
||||||
|
@@ -682,7 +687,7 @@ static void readtimer(void)
|
||||||
|
|
||||||
|
static void readscreen(void)
|
||||||
|
{
|
||||||
|
-# if !defined(OPENSSL_SYS_WINCE) && !defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||||
|
+# if !defined(OPENSSL_SYS_WINCE) && !defined(OPENSSL_SYS_WIN32_CYGWIN) && !defined(WINRT_ENABLED)
|
||||||
|
HDC hScrDC; /* screen DC */
|
||||||
|
HBITMAP hBitmap; /* handle for our bitmap */
|
||||||
|
BITMAP bm; /* bitmap properties */
|
||||||
|
diff --git a/drivers/builtin_openssl2/openssl/dtls1.h b/drivers/builtin_openssl2/openssl/dtls1.h
|
||||||
|
index 64ad3c8..a58aca2 100644
|
||||||
|
--- a/drivers/builtin_openssl2/openssl/dtls1.h
|
||||||
|
+++ b/drivers/builtin_openssl2/openssl/dtls1.h
|
||||||
|
@@ -81,6 +81,9 @@
|
||||||
|
# include <sys/time.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
+#ifdef WINRT_ENABLED
|
||||||
|
+#include <winsock2.h>
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
32
drivers/freetype/winrtdef.h
Normal file
32
drivers/freetype/winrtdef.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* winrtdef.h */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* http://www.godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* */
|
||||||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
|
/* a copy of this software and associated documentation files (the */
|
||||||
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
|
/* the following conditions: */
|
||||||
|
/* */
|
||||||
|
/* The above copyright notice and this permission notice shall be */
|
||||||
|
/* included in all copies or substantial portions of the Software. */
|
||||||
|
/* */
|
||||||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
// "generic" is a reserved keyword in C++/CX code
|
||||||
|
// this avoids the errors in the variable name from Freetype code
|
||||||
|
#define generic freetype_generic
|
9
thirdparty/openssl/crypto/rand/rand_win.c
vendored
9
thirdparty/openssl/crypto/rand/rand_win.c
vendored
@ -118,8 +118,10 @@
|
|||||||
# ifndef _WIN32_WINNT
|
# ifndef _WIN32_WINNT
|
||||||
# define _WIN32_WINNT 0x0400
|
# define _WIN32_WINNT 0x0400
|
||||||
# endif
|
# endif
|
||||||
|
#ifndef WINRT_ENABLED
|
||||||
# include <wincrypt.h>
|
# include <wincrypt.h>
|
||||||
# include <tlhelp32.h>
|
# include <tlhelp32.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Limit the time spent walking through the heap, processes, threads and
|
* Limit the time spent walking through the heap, processes, threads and
|
||||||
@ -161,7 +163,7 @@ typedef struct tagCURSORINFO {
|
|||||||
# define CURSOR_SHOWING 0x00000001
|
# define CURSOR_SHOWING 0x00000001
|
||||||
# endif /* CURSOR_SHOWING */
|
# endif /* CURSOR_SHOWING */
|
||||||
|
|
||||||
# if !defined(OPENSSL_SYS_WINCE)
|
# if !defined(OPENSSL_SYS_WINCE) && !defined(WINRT_ENABLED)
|
||||||
typedef BOOL(WINAPI *CRYPTACQUIRECONTEXTW) (HCRYPTPROV *, LPCWSTR, LPCWSTR,
|
typedef BOOL(WINAPI *CRYPTACQUIRECONTEXTW) (HCRYPTPROV *, LPCWSTR, LPCWSTR,
|
||||||
DWORD, DWORD);
|
DWORD, DWORD);
|
||||||
typedef BOOL(WINAPI *CRYPTGENRANDOM) (HCRYPTPROV, DWORD, BYTE *);
|
typedef BOOL(WINAPI *CRYPTGENRANDOM) (HCRYPTPROV, DWORD, BYTE *);
|
||||||
@ -196,6 +198,7 @@ typedef NET_API_STATUS(NET_API_FUNCTION *NETFREE) (LPBYTE);
|
|||||||
# endif /* 1 */
|
# endif /* 1 */
|
||||||
# endif /* !OPENSSL_SYS_WINCE */
|
# endif /* !OPENSSL_SYS_WINCE */
|
||||||
|
|
||||||
|
#if !defined(WINRT_ENABLED)
|
||||||
int RAND_poll(void)
|
int RAND_poll(void)
|
||||||
{
|
{
|
||||||
MEMORYSTATUS m;
|
MEMORYSTATUS m;
|
||||||
@ -580,6 +583,8 @@ int RAND_poll(void)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // WINRT_ENABLED
|
||||||
|
|
||||||
int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam)
|
int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
double add_entropy = 0;
|
double add_entropy = 0;
|
||||||
@ -682,7 +687,7 @@ static void readtimer(void)
|
|||||||
|
|
||||||
static void readscreen(void)
|
static void readscreen(void)
|
||||||
{
|
{
|
||||||
# if !defined(OPENSSL_SYS_WINCE) && !defined(OPENSSL_SYS_WIN32_CYGWIN)
|
# if !defined(OPENSSL_SYS_WINCE) && !defined(OPENSSL_SYS_WIN32_CYGWIN) && !defined(WINRT_ENABLED)
|
||||||
HDC hScrDC; /* screen DC */
|
HDC hScrDC; /* screen DC */
|
||||||
HBITMAP hBitmap; /* handle for our bitmap */
|
HBITMAP hBitmap; /* handle for our bitmap */
|
||||||
BITMAP bm; /* bitmap properties */
|
BITMAP bm; /* bitmap properties */
|
||||||
|
3
thirdparty/openssl/openssl/dtls1.h
vendored
3
thirdparty/openssl/openssl/dtls1.h
vendored
@ -81,6 +81,9 @@
|
|||||||
# include <sys/time.h>
|
# include <sys/time.h>
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
#ifdef WINRT_ENABLED
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
Loading…
Reference in New Issue
Block a user