aboutsummaryrefslogtreecommitdiff
path: root/compile
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-03-10 02:37:19 +0000
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-06 16:41:13 +0100
commit244fea664121acf12871ab5858a5fe95a2606b52 (patch)
treee42b1990ef97adc0f0ab48b9be7e11de7fee0558 /compile
parentd86b7b41453c69b3854baa7cdc05a79a3cdfe092 (diff)
downloadsst-244fea664121acf12871ab5858a5fe95a2606b52.tar.gz
sst-244fea664121acf12871ab5858a5fe95a2606b52.zip
Rewrite and redesign codegen and feature system
Also switch to somewhat proper C23 flags while we're at it. This is a huge change. It took me forever, in between being really busy. Sorry about that. But the good news is I'm now free to start integrating the various patches that have accumulated since last release. Well, at least in between still being really busy. Gotta manage expectations. The main benefit of introducing GAMESPECIFIC() is that features that don't apply to a particular game no longer show up *at all*, and less time is wasted on init. It also enables a cool optimisation wherein unnecessary REQUIRE_GAMEDATA() checks can elided at compile time whenever the gamedata is known up-front to always exist in supported games. The DEF_FEAT_CVAR macro family meanwhile makes it easier to manage the lifecycle of cvars/ccmds, with less manual registering, unhiding and such. Originally I was going to try and just hack these features into the existing codegen abomination, but it just got too terrible. This rewrite should make it easier to continue tweaking codegen behaviour in future. It also has slightly better error messages.
Diffstat (limited to 'compile')
-rwxr-xr-xcompile27
1 files changed, 13 insertions, 14 deletions
diff --git a/compile b/compile
index 31e4b8f..5b55f55 100755
--- a/compile
+++ b/compile
@@ -21,6 +21,8 @@ warnings="-Wall -pedantic -Wno-parentheses -Wno-missing-braces \
-Wno-gnu-zero-variadic-macro-arguments -Werror=implicit-function-declaration \
-Werror=vla"
+stdflags="-std=c2x -D_DEFAULT_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64"
+
dbg=0
if [ "$dbg" = 1 ]; then
cflags="-O0 -g3"
@@ -38,10 +40,8 @@ cc() {
# ugly annoying special case
if [ "$_mn" = " -DMODULE_NAME=con_" ]; then _mn=" -DMODULE_NAME=con"
elif [ "$_mn" = "-DMODULE_NAME=sst" ]; then _mn=; fi
- # note: using typeof and bool from C23 - see detailed comment in compile.bat
$CC -c -flto -fpic -fno-ident $cflags $warnings -I.build/include \
- -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64$_mn \
- -Dtypeof=__typeof -include stdbool.h -o ".build/${_bn%%.c}.o" "src/$1"
+ $stdflags$_mn -o ".build/${_bn%%.c}.o" "src/$1"
}
ld() {
@@ -69,7 +69,6 @@ src="\
fastfwd.c
fixes.c
fov.c
- gamedata.c
gameinfo.c
gameserver.c
hexcolour.c
@@ -85,20 +84,20 @@ src="\
portalcolours.c
sst.c
trace.c
- xhair.c
- x86.c"
+ x86.c
+ xhair.c"
if [ "$dbg" = 1 ]; then src="$src \
dbg.c
udis86.c"
fi
-$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -include stdbool.h \
- -o .build/codegen src/build/codegen.c src/build/cmeta.c src/os.c
-$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -include stdbool.h \
+$HOSTCC -O2 -fuse-ld=lld $warnings $stdflags \
+ -o .build/gluegen src/build/gluegen .c src/build/cmeta.c src/os.c
+$HOSTCC -O2 -fuse-ld=lld $warnings $stdflags \
-o .build/mkgamedata src/build/mkgamedata.c src/os.c
-$HOSTCC -O2 -fuse-ld=lld $warnings -D_FILE_OFFSET_BITS=64 -include stdbool.h \
+$HOSTCC -O2 -fuse-ld=lld $warnings $stdflags \
-o .build/mkentprops src/build/mkentprops.c src/os.c
-.build/codegen `for s in $src; do echo "src/$s"; done`
+.build/gluegen `for s in $src; do echo "src/$s"; done`
.build/mkgamedata gamedata/engine.txt gamedata/gamelib.txt gamedata/inputsystem.txt \
gamedata/matchmaking.txt gamedata/vgui2.txt gamedata/vguimatsurface.txt
.build/mkentprops gamedata/entprops.txt
@@ -107,14 +106,14 @@ $CC -shared -fpic -fuse-ld=lld -O0 -w -o .build/libtier0.so src/stubs/tier0.c
$CC -shared -fpic -fuse-ld=lld -O0 -w -o .build/libvstdlib.so src/stubs/vstdlib.c
ld
-$HOSTCC -O2 -g3 -include test/test.h -o .build/bitbuf.test test/bitbuf.test.c
+$HOSTCC -O2 -g3 $warnings $stdflags -include test/test.h -o .build/bitbuf.test test/bitbuf.test.c
.build/bitbuf.test
# skipping this test on linux for now, since inline hooks aren't compiled in
#$HOSTCC -m32 -O2 -g3 -include test/test.h -o .build/hook.test test/hook.test.c
#.build/hook.test
-$HOSTCC -O2 -g3 -include test/test.h -o .build/kv.test test/kv.test.c
+$HOSTCC -O2 -g3 $warnings $stdflags -include test/test.h -o .build/kv.test test/kv.test.c
.build/kv.test
-$HOSTCC -O2 -g3 -include test/test.h -o .build/x86.test test/x86.test.c
+$HOSTCC -O2 -g3 $warnings $stdflags -include test/test.h -o .build/x86.test test/x86.test.c
.build/x86.test
# vi: sw=4 tw=4 noet tw=80 cc=80