GEBS_CMD() convinience macro
This commit is contained in:
1
example/.gitignore
vendored
1
example/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
gebs
|
||||
a.out
|
||||
main
|
||||
|
@ -5,14 +5,9 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
gebs_rebuild_self(argc, argv, "cc", "-o", "gebs", __FILE__);
|
||||
|
||||
Gebs_Cmd cmd = {0};
|
||||
gebs_cmd_append(&cmd, "cc");
|
||||
gebs_cmd_append(&cmd, "main.c");
|
||||
|
||||
int ec = gebs_cmd_run(&cmd);
|
||||
printf("%d\n", ec);
|
||||
|
||||
gebs_cmd_free(&cmd);
|
||||
if (GEBS_CMD("gcc", "-o", "main", "main.c") != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
11
gebs.h
11
gebs.h
@ -182,6 +182,17 @@ typedef Gebs_NString_List Gebs_Cmd;
|
||||
|
||||
int gebs_cmd_run_sync_alloc(Gebs_Allocator *alloc, Gebs_Cmd *cmd);
|
||||
|
||||
#define GEBS_CMD(...) \
|
||||
({ \
|
||||
char *__args[] = { __VA_ARGS__ }; \
|
||||
Gebs_Cmd __cmd = {0}; \
|
||||
defer { gebs_cmd_free(&__cmd); } \
|
||||
for (size_t __i = 0; __i < sizeof(__args)/sizeof(__args[0]); __i++) { \
|
||||
gebs_cmd_append(&__cmd, __args[__i]); \
|
||||
} \
|
||||
gebs_cmd_run(&__cmd); \
|
||||
})
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// The build system
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user