From d3ae35ceb577c9640e3166983bfb57bbe6e8bb0b Mon Sep 17 00:00:00 2001 From: Zander Thannhauser Date: Sat, 14 Jun 2025 11:39:16 -0500 Subject: [PATCH] added force-rebuild command --- main.c | 32 +++++++++++++++++++++++++++----- makefile | 5 +++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 09ca9ef..8d917d1 100644 --- a/main.c +++ b/main.c @@ -15,6 +15,13 @@ #define argv0 program_invocation_name +#ifdef ZDEBUG +#define zprintf(fmt, ...) \ + printf(fmt, ## __VA_ARGS__); +#else +#define zprintf(...); +#endif + bool print_all_and_quit = false; const char* command = NULL; @@ -39,13 +46,15 @@ bool verbose = false; bool print_with_color = false; +bool force_rebuild = false; + static void parse_args(int argc, char* const* argv) { bool unset_operators = true; print_with_color = isatty(1); - for (int opt; (opt = getopt(argc, argv, "pyvc:eEo:C:")) != -1; ) switch (opt) + for (int opt; (opt = getopt(argc, argv, "pyvc:eEo:C:B")) != -1; ) switch (opt) { case 'p': print_all_and_quit = true; @@ -143,7 +152,14 @@ static void parse_args(int argc, char* const* argv) break; } - + + case 'B': + { + force_rebuild = true; + + break; + } + default: assert(!"TODO"); break; @@ -735,9 +751,13 @@ void get_simplifications(void) strcat(path, ".bin"); - int fd = open(path, O_RDONLY); + int fd = -1; - if (fd > 0) + if (force_rebuild) + { + goto rebuild; + } + else if ((fd = open(path, O_RDONLY)) > 0) { // great, just read it into memory @@ -762,7 +782,9 @@ void get_simplifications(void) "\n" "This may take a while." "\n" ""); - + + rebuild: {}; + if (!verbose) { puts("re-run with '-v' to watch progress"); diff --git a/makefile b/makefile index 4234f8a..47556c4 100644 --- a/makefile +++ b/makefile @@ -5,13 +5,14 @@ args = cc = gcc -cppflags = -D _GNU_SOURCE +cppflags += -D _GNU_SOURCE +#cppflags += -D ZDEBUG cflags = -Werror -Wall -Wextra -Wstrict-prototypes -Wfatal-errors cflags += -O3 -# cflags += -Wno-unused +cflags += -Wno-unused ldflags += -lreadline