windows: fix UWP builds, add GHA job

Add new job to test building for UWP (aka `CURL_WINDOWS_APP`).

Fix fallouts when building for UWP:
- rand: do not use `BCryptGenRandom()`.
- cmake: disable using win32 LDAP.
- cmake: disable telnet.
- version_win32: fix code before declaration.
- schannel: disable `HAS_MANUAL_VERIFY_API`.
- schannel: disable `SSLSUPP_PINNEDPUBKEY`
  and make `schannel_checksum()` a stub.
  Ref: e178fbd40a #1429
- schannel: make `cert_get_name_string()` a failing stub.
- system_win32: make `Curl_win32_impersonating()` a failing stub.
- system_win32: try to fix `Curl_win32_init()` (untested).
- threads: fix to use `CreateThread()`.
- src: disable searching `PATH` for the CA bundle.
- src: disable bold text support and capability detection.
- src: disable `getfiletime()`/`setfiletime()`.
- tests: make `win32_load_system_library()` a failing stub.
- tests/server/util: make it compile.
- tests/server/sockfilt: make it compile.
- tests/lib3026: fix to use `CreateThread()`.

See individual commits for build error details.

Some of these fixes may have better solutions, and some may not work
as expected. The goal of this patch is to make curl build for UWP.

Closes #13870
This commit is contained in:
Viktor Szakats 2024-06-03 23:06:56 +02:00
parent 3060557af7
commit 998b17ea7f
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
18 changed files with 95 additions and 38 deletions

View file

@ -152,7 +152,7 @@ enum sockmode {
ACTIVE_DISCONNECT /* as a client, disconnected from server */
};
#ifdef _WIN32
#if defined(_WIN32) && !defined(CURL_WINDOWS_APP)
/*
* read-wrapper to support reading from stdin on Windows.
*/
@ -420,7 +420,7 @@ static bool read_data_block(unsigned char *buffer, ssize_t maxlen,
}
#ifdef USE_WINSOCK
#if defined(USE_WINSOCK) && !defined(CURL_WINDOWS_APP)
/*
* WinSock select() does not support standard file descriptors,
* it can only check SOCKETs. The following function is an attempt

View file

@ -493,7 +493,7 @@ static SIGHANDLER_T old_sigterm_handler = SIG_ERR;
static SIGHANDLER_T old_sigbreak_handler = SIG_ERR;
#endif
#ifdef _WIN32
#if defined(_WIN32) && !defined(CURL_WINDOWS_APP)
#ifdef _WIN32_WCE
static DWORD thread_main_id = 0;
#else
@ -574,6 +574,9 @@ static BOOL WINAPI ctrl_event_handler(DWORD dwCtrlType)
}
return TRUE;
}
#endif
#if defined(_WIN32) && !defined(CURL_WINDOWS_APP)
/* Window message handler for Windows applications to add support
* for graceful process termination via taskkill (without /f) which
* sends WM_CLOSE to all Windows of a process (even hidden ones).
@ -687,12 +690,6 @@ static SIGHANDLER_T set_signal(int signum, SIGHANDLER_T handler,
void install_signal_handlers(bool keep_sigalrm)
{
#ifdef _WIN32
#ifdef _WIN32_WCE
typedef HANDLE curl_win_thread_handle_t;
#else
typedef uintptr_t curl_win_thread_handle_t;
#endif
curl_win_thread_handle_t thread;
/* setup windows exit event before any signal can trigger */
exit_event = CreateEvent(NULL, TRUE, FALSE, NULL);
if(!exit_event)
@ -741,16 +738,27 @@ void install_signal_handlers(bool keep_sigalrm)
#ifdef _WIN32
if(!SetConsoleCtrlHandler(ctrl_event_handler, TRUE))
logmsg("cannot install CTRL event handler");
#ifndef CURL_WINDOWS_APP
{
#ifdef _WIN32_WCE
thread = CreateThread(NULL, 0, &main_window_loop,
(LPVOID)GetModuleHandle(NULL), 0, &thread_main_id);
typedef HANDLE curl_win_thread_handle_t;
#else
thread = _beginthreadex(NULL, 0, &main_window_loop,
(void *)GetModuleHandle(NULL), 0, &thread_main_id);
typedef uintptr_t curl_win_thread_handle_t;
#endif
curl_win_thread_handle_t thread;
#ifdef _WIN32_WCE
thread = CreateThread(NULL, 0, &main_window_loop,
(LPVOID)GetModuleHandle(NULL), 0, &thread_main_id);
#else
thread = _beginthreadex(NULL, 0, &main_window_loop,
(void *)GetModuleHandle(NULL), 0, &thread_main_id);
#endif
thread_main_window = (HANDLE)thread;
if(!thread_main_window || !thread_main_id)
logmsg("cannot start main window loop");
}
#endif
thread_main_window = (HANDLE)thread;
if(!thread_main_window || !thread_main_id)
logmsg("cannot start main window loop");
#endif
}
@ -786,6 +794,7 @@ void restore_signal_handlers(bool keep_sigalrm)
#endif
#ifdef _WIN32
(void)SetConsoleCtrlHandler(ctrl_event_handler, FALSE);
#ifndef CURL_WINDOWS_APP
if(thread_main_window && thread_main_id) {
if(PostThreadMessage(thread_main_id, WM_APP, 0, 0)) {
if(WaitForSingleObjectEx(thread_main_window, INFINITE, TRUE)) {
@ -802,6 +811,7 @@ void restore_signal_handlers(bool keep_sigalrm)
}
}
#endif
#endif
}
#ifdef USE_UNIX_SOCKETS