added force-rebuild command

This commit is contained in:
Zander Thannhauser 2025-06-14 11:39:16 -05:00
parent 4d0451f9d3
commit d3ae35ceb5
2 changed files with 30 additions and 7 deletions

32
main.c
View file

@ -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");

View file

@ -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