aboutsummaryrefslogtreecommitdiff
path: root/src/build
diff options
context:
space:
mode:
Diffstat (limited to 'src/build')
-rw-r--r--src/build/gluegen.c48
-rw-r--r--src/build/mkentprops.c22
-rw-r--r--src/build/mkgamedata.c33
3 files changed, 95 insertions, 8 deletions
diff --git a/src/build/gluegen.c b/src/build/gluegen.c
index 4abfd2b..5087a52 100644
--- a/src/build/gluegen.c
+++ b/src/build/gluegen.c
@@ -602,18 +602,44 @@ static cold noreturn diewrite() { die(100, "couldn't write to file"); }
_("/* This file is autogenerated by src/build/gluegen.c. DO NOT EDIT! */")
#define H() H_() _("")
-static void recursefeatdescs(FILE *out, s16 node) {
+static void recursedbgmodnames(FILE *out, s16 node) {
if (node < 0) {
+ if (!(mod_flags[-node] & HAS_INIT)) return;
+F( " switch (status_%.*s) {",
+ mod_names[-node].len, mod_names[-node].s)
+_( " case FEAT_SKIP: colour = &grey; break;")
+_( " case FEAT_OK: colour = &green; break;")
+_( " default: colour = &red; break;")
+_( " }")
if (mod_featdescs[-node].s) {
+F( " con_colourmsg(colour, featmsgs[status_%.*s], \"%.*s (\" %.*s \")\");",
+ mod_names[-node].len, mod_names[-node].s,
+ mod_names[-node].len, mod_names[-node].s,
+ mod_featdescs[-node].len, mod_featdescs[-node].s)
+ }
+ else {
+F( " con_colourmsg(colour, featmsgs[status_%.*s], \"%.*s\");",
+ mod_names[-node].len, mod_names[-node].s,
+ mod_names[-node].len, mod_names[-node].s)
+ }
+ }
+ else if (node > 0) {
+ for (int i = 0; i < 16; ++i) {
+ recursedbgmodnames(out, radices[node].children[i]);
+ }
+ }
+}
+
+static void recursefeatdescs(FILE *out, s16 node) {
+ if (node < 0) {
F( " if (status_%.*s != FEAT_SKIP) {",
- mod_names[-node].len, mod_names[-node].s)
+ mod_names[-node].len, mod_names[-node].s)
F( " con_colourmsg(status_%.*s == FEAT_OK ? &green : &red,",
- mod_names[-node].len, mod_names[-node].s)
+ mod_names[-node].len, mod_names[-node].s)
F( " featmsgs[status_%.*s], %.*s);",
- mod_names[-node].len, mod_names[-node].s,
- mod_featdescs[-node].len, mod_featdescs[-node].s)
+ mod_names[-node].len, mod_names[-node].s,
+ mod_featdescs[-node].len, mod_featdescs[-node].s)
_( " }")
- }
}
else if (node > 0) {
for (int i = 0; i < 16; ++i) {
@@ -660,7 +686,7 @@ static int evargs_notype(FILE *out, s16 i, const char *suffix) {
return j;
}
-static inline void gencode(FILE *out, s16 featdescs) {
+static inline void gencode(FILE *out, s16 modnames, s16 featdescs) {
for (int i = 1; i < nmods; ++i) {
if (mod_flags[i] & HAS_INIT) {
F( "extern int _feat_init_%.*s();", mod_names[i].len, mod_names[i].s)
@@ -818,7 +844,13 @@ _( " struct rgba white = {255, 255, 255, 255};")
_( " struct rgba green = {128, 255, 128, 255};")
_( " struct rgba red = {255, 128, 128, 255};")
_( " con_colourmsg(&white, \"---- List of plugin features ---\\n\");");
+_( "#ifdef SST_DBG")
+_( " struct rgba grey = {192, 192, 192, 255};")
+_( " struct rgba *colour;")
+ recursedbgmodnames(out, modnames);
+_( "#else")
recursefeatdescs(out, featdescs);
+_( "#endif")
_( "}")
_( "")
_( "static inline void endfeatures() {")
@@ -953,7 +985,7 @@ int OS_MAIN(int argc, os_char *argv[]) {
FILE *out = fopen(".build/include/glue.gen.h", "wb");
if_cold (!out) die(100, "couldn't open .build/include/glue.gen.h");
H()
- gencode(out, featdesclookup);
+ gencode(out, modlookup, featdesclookup);
if_cold (fflush(out)) die(100, "couldn't finish writing output");
return 0;
}
diff --git a/src/build/mkentprops.c b/src/build/mkentprops.c
index bd4b082..17d9aa0 100644
--- a/src/build/mkentprops.c
+++ b/src/build/mkentprops.c
@@ -368,6 +368,21 @@ _( " }")
_( "}")
}
+static inline void dodbgdump(FILE *out) {
+_( "static inline void dumpentprops() {")
+_( " con_msg(\"-- entprops.txt --\\n\");")
+ for (int i = 0; i < ndecls; ++i) {
+ const char *s = sbase + decls[i];
+F( " if (has_%s) {", s);
+F( " con_msg(\" [x] %s = %%d\\n\", %s);", s, s)
+_( " }")
+_( " else {")
+F( " con_msg(\" [ ] %s\\n\");", s)
+_( " }")
+ }
+_( "}")
+}
+
int OS_MAIN(int argc, os_char *argv[]) {
if_cold (argc != 2) die(1, "wrong number of arguments");
int f = os_open_read(argv[1]);
@@ -389,6 +404,13 @@ int OS_MAIN(int argc, os_char *argv[]) {
if_cold (!out) die(100, "couldn't open entpropsinit.gen.h");
H();
doinit(out);
+
+ // technically we don't need this header in release builds, but whatever.
+ out = fopen(".build/include/entpropsdbg.gen.h", "wb");
+ if_cold (!out) die(100, "couldn't open entpropsdbg.gen.h");
+ H();
+ dodbgdump(out);
+
return 0;
}
diff --git a/src/build/mkgamedata.c b/src/build/mkgamedata.c
index 325cda2..f187028 100644
--- a/src/build/mkgamedata.c
+++ b/src/build/mkgamedata.c
@@ -265,6 +265,32 @@ _i("}")
_( "}")
}
+static inline void dbgdump(FILE *out) {
+_( "static void dumpgamedata() {")
+ int cursrc = -1;
+ for (int i = 0; i < nents; ++i) {
+ if (indents[i] != 0) continue;
+ if_cold (srcfiles[i] != cursrc) {
+ cursrc = srcfiles[i];
+F( " con_msg(\"-- %" fS " --\\n\");", srcnames[cursrc])
+ }
+ const char *s = sbase + tags[i];
+ int line = srclines[i];
+ if (exprs[i]) {
+F( " con_msg(\" [x] %s = %%d (line %d)\\n\", %s);", s, line, s)
+ }
+ else {
+F( " if (has_%s) {", sbase + tags[i])
+F( " con_msg(\" [x] %s = %%d (line %d)\\n\", %s);", s, line, s)
+_( " }")
+_( " else {")
+F( " con_msg(\" [ ] %s (line %d)\\n\");", s, line);
+_( " }")
+ }
+ }
+_( "}")
+}
+
int OS_MAIN(int argc, os_char *argv[]) {
srcnames = (const os_char *const *)argv;
int sbase_len = 0, sbase_max = 65536;
@@ -304,6 +330,13 @@ int OS_MAIN(int argc, os_char *argv[]) {
defs(out);
_("")
init(out);
+
+ // technically we don't need this header in release builds, but whatever.
+ out = fopen(".build/include/gamedatadbg.gen.h", "wb");
+ if_cold (!out) die(100, "couldn't open gamedatadbg.gen.h");
+ H();
+ dbgdump(out);
+
return 0;
}