diff --git a/gebs.c b/gebs.c index c6382c2..057bd49 100644 --- a/gebs.c +++ b/gebs.c @@ -10,19 +10,16 @@ int main(int argc, char ** argv) mkdir1("build"); } - if (needs_rebuild_many("build/self_rebuild", "example/self_rebuild.c", "gebs.h")) { - if (CMD("gcc", "-ggdb", "-o", "build/self_rebuild", "example/self_rebuild.c") != 0) - return 1; - } - if (needs_rebuild_many("build/arena", "example/arena.c", "gebs.h")) { - if (CMD("gcc", "-ggdb", "-o", "build/arena", "example/arena.c") != 0) - return 1; + RULE("build/self_rebuild", "example/self_rebuild.c", "gebs.h") { + CMD("gcc", "-ggdb", "-o", "build/self_rebuild", "example/self_rebuild.c"); } - if (needs_rebuild_many("build/commands", "example/commands.c", "gebs.h")) { - if (CMD("gcc", "-ggdb", "-o", "build/commands", "example/commands.c") != 0) { - return 1; - } + RULE("build/arena", "example/arena.c", "gebs.h") { + CMD("gcc", "-ggdb", "-o", "build/arena", "example/arena.c"); + } + + RULE("build/commands", "example/commands.c", "gebs.h") { + CMD("gcc", "-ggdb", "-o", "build/commands", "example/commands.c"); } return 0; diff --git a/gebs.h b/gebs.h index bb44ac4..9c873c1 100644 --- a/gebs.h +++ b/gebs.h @@ -291,6 +291,8 @@ void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv, } \ } while(0) +#define GEBS_RULE(target, ...) if (needs_rebuild_many(target, __VA_ARGS__)) + // ---------------------------------------------------------------------------- // Scratch arena // ---------------------------------------------------------------------------- @@ -754,6 +756,7 @@ void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv, #define needs_rebuild_many gebs_needs_rebuild_many #define rebuild_self gebs_rebuild_self #define make_compile_flags gebs_make_compile_flags +#define RULE GEBS_RULE #define scratch_arena gebs_scratch_arena #define fmt gebs_fmt