Windows: Replace BLI_File* calls with system calls in system_win32.c
Using BLI calls in this file triggered a condition where poorly modelled dependencies in cmake (ie bf_blenlib using zlib headers but not linking the libraries) leading to linker error in debug builds of some of the tests. This diff sidesteps the dependencies issue by using native calls rather than BLI calls to check if a file exists and what its size is. Effectively sweeping the issue right back under the rug where I found it. The best solution would be to audit all libraries and ensure they have proper link requirements set, but that requires significantly more time than I have available right now. (zlib in blenlib was one of them and would have been easy to fix, but there were others that required more work) The alternative is tests that fail to build which worse. I'll revisit this and fix it properly but for now this will have to do.
This commit is contained in:
@@ -24,8 +24,6 @@
|
||||
#include <shlwapi.h>
|
||||
#include <tlhelp32.h>
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
@@ -319,24 +317,29 @@ static void bli_load_symbols()
|
||||
PathRemoveFileSpecA(pdb_file);
|
||||
/* append blender.pdb */
|
||||
PathAppendA(pdb_file, "blender.pdb");
|
||||
if (BLI_exists(pdb_file)) {
|
||||
if (PathFileExistsA(pdb_file)) {
|
||||
HMODULE mod = GetModuleHandle(NULL);
|
||||
if (mod) {
|
||||
size_t size = BLI_file_size(pdb_file);
|
||||
WIN32_FILE_ATTRIBUTE_DATA file_data;
|
||||
if (GetFileAttributesExA(pdb_file, GetFileExInfoStandard, &file_data)) {
|
||||
/* SymInitialize will try to load symbols on its own, so we first must unload whatever it
|
||||
* did trying to help */
|
||||
SymUnloadModule64(GetCurrentProcess(), (DWORD64)mod);
|
||||
|
||||
/* SymInitialize will try to load symbols on its own, so we first must unload whatever it
|
||||
* did trying to help */
|
||||
SymUnloadModule64(GetCurrentProcess(), (DWORD64)mod);
|
||||
|
||||
DWORD64 module_base = SymLoadModule(
|
||||
GetCurrentProcess(), NULL, pdb_file, NULL, (DWORD64)mod, (DWORD)size);
|
||||
if (module_base == 0) {
|
||||
fprintf(stderr,
|
||||
"Error loading symbols %s\n\terror:0x%.8x\n\tsize = %zi\n\tbase=0x%p\n",
|
||||
pdb_file,
|
||||
GetLastError(),
|
||||
size,
|
||||
(LPVOID)mod);
|
||||
DWORD64 module_base = SymLoadModule(GetCurrentProcess(),
|
||||
NULL,
|
||||
pdb_file,
|
||||
NULL,
|
||||
(DWORD64)mod,
|
||||
(DWORD)file_data.nFileSizeLow);
|
||||
if (module_base == 0) {
|
||||
fprintf(stderr,
|
||||
"Error loading symbols %s\n\terror:0x%.8x\n\tsize = %d\n\tbase=0x%p\n",
|
||||
pdb_file,
|
||||
GetLastError(),
|
||||
file_data.nFileSizeLow,
|
||||
(LPVOID)mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user