1+ @ echo off
2+ set " name = %1 "
3+ set " ico_name = %name% "
4+ set " subsys = WINDOWS"
5+ set " seh = /EHsc"
6+ set " optim = /O2 /Oi /GL /Gy"
7+ set " linkopt = /LTCG"
8+ set " warns = /Wall"
9+ set " slib = "
10+ set " asm = "
11+ set " debug = /MD"
12+ set " debug_link = "
13+ set " debug_def = "
14+ set " no_launch = "
15+ set " res_file = "
16+ cd " %2 "
17+
18+ if not exist ico goto :noico
19+ if not exist ico\%ico_name% .ico set ico_name = main
20+
21+ echo MAINICON ICON " ico\\%ico_name% .ico" > ico\res.rc
22+ rc /r /nologo ico\res.rc
23+ set res_file = ico\res.res
24+
25+ :noico
26+
27+ nppsave
28+
29+ title sd_msvc_build
30+
31+ if %name% == small set subsys = CONSOLE
32+
33+ set /p fline = < %name% .cpp
34+
35+ :parse_loop
36+ for /f " tokens=1,* delims= " %%a in (" %fline% " ) do (
37+ if " %%a " == " CONSOLE" set " subsys = CONSOLE"
38+ if " %%a " == " DSEH" set " seh = /wd4577"
39+ if " %%a " == " NOPT" set " optim = /Od" & set " linkopt = "
40+ if " %%a " == " NW" set " warns = /w"
41+ if " %%a " == " SLIB" set " slib = /c" & set " res_file = "
42+ if " %%a " == " ASM" set " asm = /FAcsu"
43+ if " %%a " == " DBG" set " debug = /MDd /Z7" & set " debug_link = /DEBUG" & set " debug_def = /D DEBUG"
44+ if " %%a " == " NLAUNCH" set " no_launch = no"
45+
46+
47+ set " fline = %%b "
48+ goto :parse_loop
49+ )
50+
51+ :recompile
52+ cl %warns% /wd4530 /wd4710 /wd4711 /wd5045 /external:anglebrackets /external:W0 /diagnostics:caret /I %2 %optim% %debug_def% /D _%subsys% /D _UNICODE /D UNICODE /D _CRT_SECURE_NO_WARNINGS /Gm- %seh% %debug% /GS- /J /Zc:wchar_t /Zc:forScope /Zc:inline /permissive- /nologo %slib% %asm% %name% .cpp %res_file% /link /SUBSYSTEM:%subsys% %linkopt% %debug_link% /DYNAMICBASE:NO /MACHINE:X64 /ENTRY:wmainCRTStartup | vcstyle
53+
54+ :: #pragma warning has priority over switches
55+ :: C4514 The optimizer removed an inline function that is not called. (DISABLE CANDIDATE)
56+ :: C4530 C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
57+ :: C4710 function not inlined (code gen.)
58+ :: C4711 function selected for automatic inline expansion (code gen.)
59+ :: C5045 Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified (code gen.)
60+
61+ if %ERRORLEVEL% EQU 1 pause > nul & exit
62+ if %ERRORLEVEL% EQU 2 pause > nul
63+
64+ if " %slib% " == " /c" ( if " %debug_link% " == " /DEBUG" (
65+ lib /NOLOGO /VERBOSE /OUT:%name% d.lib %name% .obj ) else (
66+ lib /NOLOGO /VERBOSE %name% .obj
67+ set " debug = /MDd /Z7" & set " debug_link = /DEBUG" & set " debug_def = /D DEBUG"
68+ goto :recompile )
69+ if %ERRORLEVEL% NEQ 0 ( pause > nul & goto :cleanup ) else ( goto :cleanup ) )
70+
71+ :: pause > nul
72+ if " %asm% " == " /FAcsu" notepad++ %name% .cod & goto :cleanup
73+ if " %debug_link% " == " /DEBUG" start sddbg %name% .exe & goto :cleanup
74+
75+ if " %no_launch% " == " " start " %name% " %name% .exe
76+ :cleanup
77+ del ico\res.rc ico\res.res %name% .obj
78+ taskkill /f /im cmd.exe /fi " windowtitle eq sd_msvc_build"
0 commit comments