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