From cbe0cff53dadc29735977899c69a5231cb00eff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 6 Oct 2021 07:42:01 +0200 Subject: [PATCH] bullet: Fix UWP build by disabling TaskScheduler dynamic loading Cf. https://github.com/bulletphysics/bullet3/pull/3991 --- thirdparty/README.md | 2 +- .../TaskScheduler/btThreadSupportWin32.cpp | 6 +++++ .../patches/fix-win32-scheduler-uwp.patch | 24 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 thirdparty/bullet/patches/fix-win32-scheduler-uwp.patch diff --git a/thirdparty/README.md b/thirdparty/README.md index 61c7016524b..6e57bcc666b 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -16,7 +16,7 @@ Files extracted from upstream source: - `src/*` apart from CMakeLists.txt and premake4.lua files - `LICENSE.txt`, and `VERSION` as `VERSION.txt` -Includes a warning fix which should be upstreamed soon (see patch in `patches`). +Includes some patches in the `patches` folder which have been sent upstream. ## certs diff --git a/thirdparty/bullet/LinearMath/TaskScheduler/btThreadSupportWin32.cpp b/thirdparty/bullet/LinearMath/TaskScheduler/btThreadSupportWin32.cpp index 922e449cce2..5862264a67b 100644 --- a/thirdparty/bullet/LinearMath/TaskScheduler/btThreadSupportWin32.cpp +++ b/thirdparty/bullet/LinearMath/TaskScheduler/btThreadSupportWin32.cpp @@ -82,6 +82,11 @@ typedef BOOL(WINAPI* Pfn_GetLogicalProcessorInformation)(PSYSTEM_LOGICAL_PROCESS void getProcessorInformation(btProcessorInfo* procInfo) { memset(procInfo, 0, sizeof(*procInfo)); +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ + !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + // Can't dlopen libraries on UWP. + return; +#else Pfn_GetLogicalProcessorInformation getLogicalProcInfo = (Pfn_GetLogicalProcessorInformation)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformation"); if (getLogicalProcInfo == NULL) @@ -160,6 +165,7 @@ void getProcessorInformation(btProcessorInfo* procInfo) } } free(buf); +#endif } ///btThreadSupportWin32 helps to initialize/shutdown libspe2, start/stop SPU tasks and communication diff --git a/thirdparty/bullet/patches/fix-win32-scheduler-uwp.patch b/thirdparty/bullet/patches/fix-win32-scheduler-uwp.patch new file mode 100644 index 00000000000..c65db49388a --- /dev/null +++ b/thirdparty/bullet/patches/fix-win32-scheduler-uwp.patch @@ -0,0 +1,24 @@ +diff --git a/thirdparty/bullet/LinearMath/TaskScheduler/btThreadSupportWin32.cpp b/thirdparty/bullet/LinearMath/TaskScheduler/btThreadSupportWin32.cpp +index 922e449cce..5862264a67 100644 +--- a/thirdparty/bullet/LinearMath/TaskScheduler/btThreadSupportWin32.cpp ++++ b/thirdparty/bullet/LinearMath/TaskScheduler/btThreadSupportWin32.cpp +@@ -82,6 +82,11 @@ typedef BOOL(WINAPI* Pfn_GetLogicalProcessorInformation)(PSYSTEM_LOGICAL_PROCESS + void getProcessorInformation(btProcessorInfo* procInfo) + { + memset(procInfo, 0, sizeof(*procInfo)); ++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ ++ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) ++ // Can't dlopen libraries on UWP. ++ return; ++#else + Pfn_GetLogicalProcessorInformation getLogicalProcInfo = + (Pfn_GetLogicalProcessorInformation)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformation"); + if (getLogicalProcInfo == NULL) +@@ -160,6 +165,7 @@ void getProcessorInformation(btProcessorInfo* procInfo) + } + } + free(buf); ++#endif + } + + ///btThreadSupportWin32 helps to initialize/shutdown libspe2, start/stop SPU tasks and communication