summaryrefslogtreecommitdiff
path: root/compile.bat
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-12-18 21:35:50 +0000
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2026-02-16 19:11:24 +0000
commit7a07c08abe46f97f2412f06c77204e9015f97a47 (patch)
tree581b80f55d7d66592fda98fb492d7465cc33f191 /compile.bat
parent186aea515dd773bb11464714886ca5203d2be2ab (diff)
downloadsst-7a07c08abe46f97f2412f06c77204e9015f97a47.tar.gz
sst-7a07c08abe46f97f2412f06c77204e9015f97a47.zip
Move to a shared static RWX section
Does away with the need to mark a region as executable on load. Also allows the self-modified stuff and hook trampolines to fit in the same page, so we take up ever-so-slightly less memory. Unfortunately I had issues getting the test binary to build correctly and eventually decided to give up as it wasn't testing much of value anyway. Also note that the build now allows for .c and .S files with the same basename, which required renaming the .o files, so you might want to clean out your .build/ directory before building this one.
Diffstat (limited to 'compile.bat')
-rw-r--r--compile.bat29
1 files changed, 17 insertions, 12 deletions
diff --git a/compile.bat b/compile.bat
index 0affd05..3cd8c84 100644
--- a/compile.bat
+++ b/compile.bat
@@ -37,17 +37,17 @@ set objs=
goto :main
:cc
-for /F %%b in ("%1") do set basename=%%~nb
+for /F %%f in ("%1") do (
+ set basename=%%~nf
+ set ext=%%~xf
+)
set dmodname= -DMODULE_NAME=%basename%
:: ugly annoying special cases
if "%dmodname%"==" -DMODULE_NAME=con_" set dmodname= -DMODULE_NAME=con
if "%dmodname%"==" -DMODULE_NAME=sst" set dmodname=
-set objs=%objs% .build/%basename%.o
+set objs=%objs% .build/%basename%%ext%.o
%CC% -c -flto -mno-stack-arg-probe %cflags% %warnings% %stdflags% -I.build/include ^
--D_DLL%dmodname% -o .build/%basename%.o %1 || goto :end
-goto :eof
-
-:src
+-D_DLL%dmodname% -o .build/%basename%%ext%.o %1 || goto :end
goto :eof
:main
@@ -55,9 +55,15 @@ goto :eof
set stdflags=-std=c2x -D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN -DNOMINMAX
set src=
+:: metasrc has C sources only -> we don't attempt to run gluegen over asm files.
+:: we could also leave out chunklets, but that doesn't really matter that much.
+set metasrc=
:: funny hack to build a list conveniently, lol.
setlocal EnableDelayedExpansion
-for /f "tokens=2" %%f in ('findstr /B /C:":+ " "%~nx0"') do set src=!src! src/%%f
+for /f "tokens=2" %%f in ('findstr /B /C:":+ " "%~nx0"') do (
+ set src=!src! src/%%f
+ if "%%~xf"==".c" set metasrc=!metasrc! src/%%f
+)
setlocal DisableDelayedExpansion
:+ ac.c
:+ alias.c
@@ -65,6 +71,7 @@ setlocal DisableDelayedExpansion
:+ bind.c
:+ clientcon.c
:+ con_.c
+:+ con_.S
:+ chatrate.c
:+ chunklets/fastspin.c
:+ chunklets/msg.c
@@ -83,6 +90,7 @@ setlocal DisableDelayedExpansion
:+ gameserver.c
:+ hexcolour.c
:+ hook.c
+:+ hook.S
:+ hud.c
:+ inputhud.c
:+ kvsys.c
@@ -121,7 +129,7 @@ if %host64%==1 (
-L.build %lbcryptprimitives_host% -o .build/mkgamedata.exe src/build/mkgamedata.c src/os.c || goto :end
%HOSTCC% -fuse-ld=lld -O2 %warnings% %stdflags% -include stdbool.h ^
-L.build %lbcryptprimitives_host% -o .build/mkentprops.exe src/build/mkentprops.c src/os.c || goto :end
-.build\gluegen.exe%src% || goto :end
+.build\gluegen.exe%metasrc% || goto :end
.build\mkgamedata.exe gamedata/engine.txt gamedata/gamelib.txt gamedata/inputsystem.txt ^
gamedata/matchmaking.txt gamedata/vgui2.txt gamedata/vguimatsurface.txt gamedata/vphysics.txt || goto :end
.build\mkentprops.exe gamedata/entprops.txt || goto :end
@@ -135,7 +143,7 @@ if "%dbg%"=="1" (
) else (
set clibs=-lucrt
)
-%CC% -fuse-ld=lld -shared -flto %ldflags% -Wl,/IMPLIB:.build/sst.lib,/Brepro,/nodefaultlib ^
+%CC% -fuse-ld=lld -shared -flto %ldflags% -Wl,-implib:.build/sst.lib,-Brepro,-nodefaultlib,-safeseh:no ^
-L.build %clibs% -lkernel32 -luser32 -lbcryptprimitives -lshlwapi -ld3d9 -ldsound ^
-ltier0 -lvstdlib -lntdll -o .build/sst.dll%objs% .build/dll.res || goto :end
:: get rid of another useless file (can we just not create this???)
@@ -160,9 +168,6 @@ if exist .build\sst.old.dll del .build\sst.old.dll >nul 2>nul
%HOSTCC% -fuse-ld=lld -O2 -g %warnings% %stdflags% -include test/test.h -o .build/bitbuf.test.exe test/bitbuf.test.c || goto :end
.build\bitbuf.test.exe || goto :end
-:: special case: test must be 32-bit
-%HOSTCC% -fuse-ld=lld -m32 -O2 -g %warnings% %stdflags% -L.build -lbcryptprimitives -include test/test.h -o .build/hook.test.exe test/hook.test.c || goto :end
-.build\hook.test.exe || goto :end
%HOSTCC% -fuse-ld=lld -O2 -g %warnings% %stdflags% -include test/test.h -o .build/x86.test.exe test/x86.test.c || goto :end
.build\x86.test.exe || goto :end