From 11e3ee039a49f04900cb9d1db1f71e39d061d6b8 Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Tue, 20 May 2025 23:21:09 +0200 Subject: [PATCH] Add GEBS_SHIFT() macro, pass commandline arguments to self after rebuild, add build dep on gebs.h --- gebs.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gebs.h b/gebs.h index 5b52c83..e52fad4 100644 --- a/gebs.h +++ b/gebs.h @@ -25,6 +25,7 @@ #include #include #include +#include #if GEBS_PLATFORM == GEBS_PLATFORM_POSIX # include @@ -37,6 +38,16 @@ #define discard __attribute__((unused)) +// ---------------------------------------------------------------------------- +// Parsing commandline arguments +// ---------------------------------------------------------------------------- + +#define GEBS_SHIFT_CHECK(argc) \ + (*(argc) <= 0 ? (GEBS_LOGE("Expected more arguments\n"), exit(EXIT_FAILURE)) : (0)) + +#define GEBS_SHIFT(argc, argv) \ + (GEBS_SHIFT_CHECK((argc)), --(*(argc)), *(*(argv))++) + // ---------------------------------------------------------------------------- // Defer macro // ---------------------------------------------------------------------------- @@ -553,7 +564,7 @@ void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv, int cmd_argc, char **cmd_argv, char *source) { const char *binary_path = argv[0]; - if (!gebs_needs_rebuild(binary_path, source)) { + if (!gebs_needs_rebuild_many(binary_path, source, __FILE__)) { return; } @@ -576,6 +587,10 @@ void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv, cmd.count = 0; gebs_cmd_append_alloc(alloc, &cmd, (char *)binary_path); + for (size_t i = 1; i < argc; i++) { + gebs_cmd_append_alloc(alloc, &cmd, argv[i]); + } + code = gebs_cmd_run_alloc(alloc, &cmd); if (code != EXIT_SUCCESS) { exit(EXIT_FAILURE);