diff --git a/.gitignore b/.gitignore index a1a12f1..8030b95 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,6 @@ dkms.conf /misc/supermiumman.png /bin.7z *.zip -*.res \ No newline at end of file +*.res + +release \ No newline at end of file diff --git a/build.cmd b/build.cmd index 4e3210f..112dbe7 100644 --- a/build.cmd +++ b/build.cmd @@ -1,6 +1,5 @@ @echo off -set DEFS=/DUNICODE set DIR_ROOT=%~dp0. set DIR_PROGMGR=%DIR_ROOT%\progmgr set DIR_RELEASE=%DIR_ROOT%\release @@ -8,18 +7,22 @@ set DIR_RELEASE=%DIR_ROOT%\release rmdir /S /Q "%DIR_RELEASE%" > nul 2>&1 if not exist "%DIR_RELEASE%" mkdir "%DIR_RELEASE%" +git rev-parse HEAD > %DIR_RELEASE%\.git_hash +set /P GIT_HASH=<%DIR_RELEASE%\.git_hash +set "GIT_HASH=%GIT_HASH:~0,8%" + if "%1" == "debug" ( - set CL=/MT /Od /Zi /RTC1 /Fdprogmgr.pdb /fsanitize=address %DEFS% + set CL=/MT /Od /Zi /RTC1 /Fdprogmgr.pdb /fsanitize=address /DUNICODE /DPROGMGR_DEBUG /DPROGMGR_GIT_HASH="%GIT_HASH%" set LINK=/DEBUG ) else ( - set CL=/GL /O1 /DNDEBUG /GS- %DEFS% - set LINK=/LTCG /OPT:REF /OPT:ICF + set CL=/O1 /GS- /DUNICODE /DNDEBUG /DPROGMGR_RELEASE /DPROGMGR_GIT_HASH="%GIT_HASH%" + set LINK=/NODEFAULTLIB /OPT:REF /OPT:ICF ) pushd "%DIR_RELEASE%" -rc /nologo /i "%DIR_PROGMGR%" "%DIR_PROGMGR%\lang\dlg_en-US.rc" -rc /nologo /i "%DIR_PROGMGR%" "%DIR_PROGMGR%\lang\res_en-US.rc" -rc /nologo /i "%DIR_PROGMGR%" "%DIR_PROGMGR%\resource.rc" +rc /nologo /DPROGMGR_GIT_HASH="""%GIT_HASH%""" /i "%DIR_PROGMGR%" "%DIR_PROGMGR%\lang\dlg_en-US.rc" +rc /nologo /DPROGMGR_GIT_HASH="""%GIT_HASH%""" /i "%DIR_PROGMGR%" "%DIR_PROGMGR%\lang\res_en-US.rc" +rc /nologo /DPROGMGR_GIT_HASH="""%GIT_HASH%""" /i "%DIR_PROGMGR%" "%DIR_PROGMGR%\resource.rc" cl /nologo /W3 /WX /MP /Feprogmgr.exe ^ "%DIR_PROGMGR%\*.c" ^ "%DIR_PROGMGR%\resource.res" ^ diff --git a/progmgr/progmgr.c b/progmgr/progmgr.c index 705fac9..a503170 100644 --- a/progmgr/progmgr.c +++ b/progmgr/progmgr.c @@ -166,7 +166,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, return 0; } -#ifdef PROGMGR_NO_CRT +// NOTE(u130b8): We're compiling without the C runtime by default in Release builds. +// But in Debug builds, we need the C runtime, otherwise the address sanitizer and +// MSVC debug tools break because they use the wWinMainCRTStartup entrypoint to initialize. + +#ifdef PROGMGR_RELEASE #pragma function(memset) void *memset(char* dst, int value, size_t count) { while (count--) { *dst++ = value; } diff --git a/progmgr/resource.rc b/progmgr/resource.rc index 65fc50d..e614d41 100644 --- a/progmgr/resource.rc +++ b/progmgr/resource.rc @@ -41,6 +41,13 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "progmgr.exe.manifest" #define APSTUDIO_HIDDEN_SYMBOLS #include "version.inc" #undef APSTUDIO_HIDDEN_SYMBOLS + +// NOTE(u130b8): Example of using PROGMGR_GIT_HASH in the resource file +#ifdef PROGMGR_GIT_HASH +#undef VER_PRODUCTVERSION_STR +#define VER_PRODUCTVERSION_STR "git-" PROGMGR_GIT_HASH +#endif + VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION PRODUCTVERSION VER_PRODUCTVERSION diff --git a/zipbuild.bat b/zip.cmd similarity index 100% rename from zipbuild.bat rename to zip.cmd