Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build release without crt, build debug with crt #29

Merged
merged 7 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ dkms.conf
/misc/supermiumman.png
/bin.7z
*.zip
*.res
*.res

release
17 changes: 10 additions & 7 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
@echo off

set DEFS=/DUNICODE
set DIR_ROOT=%~dp0.
set DIR_PROGMGR=%DIR_ROOT%\progmgr
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" ^
Expand Down
6 changes: 5 additions & 1 deletion progmgr/progmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
7 changes: 7 additions & 0 deletions progmgr/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
Loading