RULE_ARRAY() to define deps with a static array

This commit is contained in:
kamkow1
2025-06-27 20:09:30 +02:00
parent 595b7d06f1
commit 596bb1ef76

17
gebs.h
View File

@ -400,6 +400,21 @@ void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv,
__ok; \
})
#define gebs_needs_rebuild_many_array(out, array) \
({ \
bool __ok = false; \
if (sizeof((array))/sizeof((array)[0]) == 0) { \
__ok = true; \
} \
for (size_t __i = 0; __i < sizeof((array))/sizeof((array)[0]); __i++) { \
if (gebs_needs_rebuild((out), (array)[__i])) { \
__ok = true; \
break; \
} \
} \
__ok; \
})
#define gebs_make_compile_flags(...) \
do { \
if (gebs_needs_rebuild("compile_flags.txt", __FILE__)) { \
@ -419,6 +434,7 @@ 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__))
#define GEBS_RULE_ARRAY(target, array) if (gebs_needs_rebuild_many_array(target, (array)))
// ----------------------------------------------------------------------------
// Scratch arena
@ -1004,6 +1020,7 @@ void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv,
#define rebuild_self gebs_rebuild_self
#define make_compile_flags gebs_make_compile_flags
#define RULE GEBS_RULE
#define RULE_ARRAY GEBS_RULE_ARRAY
#define scratch_arena gebs_scratch_arena
#define fmt gebs_fmt