forked from gildor2/UEViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Building and packaging Win32 and Win64 builds of UModel
- SDL2.dll is no longer copied next to umodel.exe, it is picked up from libs during development, using delay-loading tech - package_win32.sh script builds Win32 and Win64 targets and packages executables alongside with SDL2 dlls - Separated SDL2 logic from common.project to SDL2.project - Replaced appMilliseconds implementation from SDL_GetTicks to GetTickCount, so running in command line mode will no longer require SDL2.dll
- Loading branch information
Showing
9 changed files
with
105 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# perl highlighting | ||
|
||
!if "$PLATFORM" ne "osx" | ||
STDLIBS += SDL2 # disabled in macOS build | ||
!endif | ||
|
||
!if "$PLATFORM" eq "win32" | ||
INCLUDES += $R/libs/includewin32 | ||
LIBRARIES += $R/libs/SDL2/x86 | ||
!elif "$PLATFORM" eq "win64" | ||
INCLUDES += $R/libs/includewin32 | ||
LIBRARIES += $R/libs/SDL2/x64 | ||
!endif | ||
|
||
!if "$COMPILER" eq "VisualC" | ||
# Delay loading of SDL2.dll | ||
LINKFLAGS += -DELAYLOAD:SDL2.dll | ||
STDLIBS += delayimp | ||
# Delay loader helper function | ||
sources(MAIN) = $R/libs/SDL2/SDL2Loader.cpp | ||
!endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <windows.h> | ||
#include <delayimp.h> | ||
|
||
// Reference: | ||
// https://docs.microsoft.com/en-us/cpp/build/reference/understanding-the-helper-function | ||
|
||
// Core external functions | ||
void appPrintf(const char*, ...); | ||
void appError(const char*, ...); | ||
|
||
static const char* DllPaths[] = | ||
{ | ||
#ifndef _WIN64 | ||
"SDL2.dll", | ||
"libs\\SDL2\\x86\\SDL2.dll" | ||
#else | ||
"SDL2_64.dll", | ||
"libs\\SDL2\\x64\\SDL2.dll" | ||
#endif | ||
}; | ||
|
||
static FARPROC WINAPI delayHook(unsigned dliNotify, PDelayLoadInfo pdli) | ||
{ | ||
if (dliNotify == dliNotePreLoadLibrary) | ||
{ | ||
if (stricmp(pdli->szDll, "SDL2.dll") == 0) | ||
{ | ||
// Find SDL2.dll in local folder, then in libs. Use a different file name for Win64 builds. | ||
for (const char* DllName : DllPaths) | ||
{ | ||
HANDLE hDll = LoadLibrary(DllName); | ||
if (hDll) | ||
return (FARPROC) hDll; | ||
} | ||
appError("SDL2.dll was not found, terminating..."); | ||
} | ||
else | ||
{ | ||
// Actually can simply return NULL, and let CRT to find a DLL itself | ||
appError("Unknown DelayLoad: %s", pdli->szDll); | ||
} | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
ExternC const PfnDliHook __pfnDliNotifyHook2 = delayHook; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.