Add RULE() macro for conviniently defining build rules
This commit is contained in:
19
gebs.c
19
gebs.c
@ -10,19 +10,16 @@ int main(int argc, char ** argv)
|
|||||||
mkdir1("build");
|
mkdir1("build");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needs_rebuild_many("build/self_rebuild", "example/self_rebuild.c", "gebs.h")) {
|
RULE("build/self_rebuild", "example/self_rebuild.c", "gebs.h") {
|
||||||
if (CMD("gcc", "-ggdb", "-o", "build/self_rebuild", "example/self_rebuild.c") != 0)
|
CMD("gcc", "-ggdb", "-o", "build/self_rebuild", "example/self_rebuild.c");
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needs_rebuild_many("build/commands", "example/commands.c", "gebs.h")) {
|
RULE("build/arena", "example/arena.c", "gebs.h") {
|
||||||
if (CMD("gcc", "-ggdb", "-o", "build/commands", "example/commands.c") != 0) {
|
CMD("gcc", "-ggdb", "-o", "build/arena", "example/arena.c");
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
RULE("build/commands", "example/commands.c", "gebs.h") {
|
||||||
|
CMD("gcc", "-ggdb", "-o", "build/commands", "example/commands.c");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
3
gebs.h
3
gebs.h
@ -291,6 +291,8 @@ void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv,
|
|||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
#define GEBS_RULE(target, ...) if (needs_rebuild_many(target, __VA_ARGS__))
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Scratch arena
|
// 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 needs_rebuild_many gebs_needs_rebuild_many
|
||||||
#define rebuild_self gebs_rebuild_self
|
#define rebuild_self gebs_rebuild_self
|
||||||
#define make_compile_flags gebs_make_compile_flags
|
#define make_compile_flags gebs_make_compile_flags
|
||||||
|
#define RULE GEBS_RULE
|
||||||
|
|
||||||
#define scratch_arena gebs_scratch_arena
|
#define scratch_arena gebs_scratch_arena
|
||||||
#define fmt gebs_fmt
|
#define fmt gebs_fmt
|
||||||
|
Reference in New Issue
Block a user