Stripping prefixes
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
#define GEBS_NO_PREFIX
|
||||
#define GEBS_IMPLEMENTATION
|
||||
#include "../gebs.h"
|
||||
|
||||
@ -8,19 +9,19 @@ typedef struct {
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Gebs_Arena *arena = gebs_arena_make(sizeof(int));
|
||||
defer { gebs_arena_destroy(arena); }
|
||||
Arena *arena = arena_make(sizeof(int));
|
||||
defer { arena_destroy(arena); }
|
||||
|
||||
Ints ints = {0};
|
||||
defer { gebs_list_free_alloc(arena, &ints); }
|
||||
defer { list_free_alloc(arena, &ints); }
|
||||
for (size_t i = 0; i < 1000; i++) {
|
||||
gebs_list_append_alloc(arena, &ints, i);
|
||||
list_append_alloc(arena, &ints, i);
|
||||
}
|
||||
for (size_t i = 0; i < ints.count; i++) {
|
||||
printf("%zu\n", i);
|
||||
}
|
||||
|
||||
printf("%s\n", gebs_fmt("Hello formatting %d", 124));
|
||||
printf("%s\n", fmt("Hello formatting %d", 124));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,26 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#define GEBS_NO_PREFIX
|
||||
#define GEBS_IMPLEMENTATION
|
||||
#include "../gebs.h"
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
gebs_rebuild_self(argc, argv, "cc", "-o", "commands", __FILE__);
|
||||
rebuild_self(argc, argv, "cc", "-o", "commands", __FILE__);
|
||||
|
||||
int code = GEBS_CMD("ls", "-la");
|
||||
GEBS_LOGI("Exited with %d\n", code);
|
||||
int code = CMD("ls", "-la");
|
||||
LOGI("Exited with %d\n", code);
|
||||
|
||||
Gebs_Cmd cmd = {0};
|
||||
defer { gebs_list_free(&cmd); }
|
||||
gebs_cmd_append(&cmd, "ls");
|
||||
gebs_cmd_append(&cmd, "-la");
|
||||
Cmd cmd = {0};
|
||||
defer { list_free(&cmd); }
|
||||
cmd_append(&cmd, "ls");
|
||||
cmd_append(&cmd, "-la");
|
||||
|
||||
|
||||
Gebs_String_Builder out_sb = {0};
|
||||
defer { gebs_sb_free(&out_sb); }
|
||||
code = gebs_cmd_run_collect(&cmd, &out_sb);
|
||||
String_Builder out_sb = {0};
|
||||
defer { sb_free(&out_sb); }
|
||||
code = cmd_run_collect(&cmd, &out_sb);
|
||||
printf("CAPTURED\n%sCAPTURED\n", out_sb.items);
|
||||
|
||||
GEBS_LOGI("Exited with %d\n", code);
|
||||
LOGI("Exited with %d\n", code);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#define GEBS_NO_PREFIX
|
||||
#define GEBS_IMPLEMENTATION
|
||||
#include "../gebs.h"
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
gebs_rebuild_self(argc, argv, "cc", "-o", "self_rebuild", __FILE__);
|
||||
rebuild_self(argc, argv, "cc", "-o", "self_rebuild", __FILE__);
|
||||
|
||||
printf("Hello world\n");
|
||||
return 0;
|
||||
|
20
gebs.c
20
gebs.c
@ -1,24 +1,26 @@
|
||||
#define GEBS_NO_PREFIX
|
||||
#define GEBS_IMPLEMENTATION
|
||||
#include "gebs.h"
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
gebs_rebuild_self(argc, argv, "cc", "-o", "gebs", __FILE__);
|
||||
rebuild_self(argc, argv, "cc", "-o", "gebs", __FILE__);
|
||||
|
||||
if (!gebs_exists("build")) {
|
||||
gebs_mkdir("build");
|
||||
if (!exists1("build")) {
|
||||
mkdir1("build");
|
||||
}
|
||||
|
||||
if (gebs_needs_rebuild_many("build/self_rebuild", "example/self_rebuild.c", "gebs.h")) {
|
||||
if (GEBS_CMD("gcc", "-ggdb", "-o", "build/self_rebuild", "example/self_rebuild.c") != 0)
|
||||
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 (gebs_needs_rebuild_many("build/arena", "example/arena.c", "gebs.h")) {
|
||||
if (GEBS_CMD("gcc", "-ggdb", "-o", "build/arena", "example/arena.c") != 0)
|
||||
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 (gebs_needs_rebuild_many("build/commands", "example/commands.c", "gebs.h")) {
|
||||
if (GEBS_CMD("gcc", "-ggdb", "-o", "build/commands", "example/commands.c") != 0) {
|
||||
|
||||
if (needs_rebuild_many("build/commands", "example/commands.c", "gebs.h")) {
|
||||
if (CMD("gcc", "-ggdb", "-o", "build/commands", "example/commands.c") != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
72
gebs.h
72
gebs.h
@ -1,6 +1,7 @@
|
||||
#ifndef GEBS_H_
|
||||
#define GEBS_H_
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Platform macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -689,4 +690,75 @@ void gebs_rebuild_self1_alloc(Gebs_Allocator *alloc, int argc, char ** argv,
|
||||
|
||||
#endif // GEBS_IMPLEMENTATION
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Prefixes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef GEBS_NO_PREFIX
|
||||
|
||||
#define SHIFT_CHECK GEBS_SHIFT_CHECK
|
||||
#define SHIFT GEBS_SHIFT
|
||||
|
||||
#define LOGI GEBS_LOGI
|
||||
#define LOGE GEBS_LOGE
|
||||
#define LOGD GEBS_LOGD
|
||||
#define LOGW GEBS_LOGW
|
||||
#define LOGO GEBS_LOGO
|
||||
|
||||
#define Allocator Gebs_Allocator
|
||||
#define default_allocator gebs_default_allocator
|
||||
#define Arena Gebs_Arena
|
||||
#define arena_reset gebs_arena_reset
|
||||
#define arena_destroy gebs_arena_destroy
|
||||
#define arena_make gebs_arena_make
|
||||
#define arena_expand gebs_arena_expand
|
||||
|
||||
#define list_append_alloc gebs_list_append_alloc
|
||||
#define list_append gebs_list_append
|
||||
#define list_free_alloc gebs_list_free_alloc
|
||||
#define list_free gebs_list_free
|
||||
|
||||
#define NString_List Gebs_NString_List
|
||||
#define nsl_join_alloc gebs_nls_join_alloc
|
||||
|
||||
#define String_Builder Gebs_String_Builder
|
||||
#define sb_append_char_alloc gebs_sb_append_char_alloc
|
||||
#define sb_free_alloc gebs_sb_free_alloc
|
||||
#define sb_finish_alloc gebs_sb_finish_alloc
|
||||
#define sb_append_nstr_alloc gebs_sb_append_nstr_alloc
|
||||
#define sb_append_char gebs_sb_append_char
|
||||
#define sb_free gebs_sb_free
|
||||
#define sb_finish gebs_sb_finish
|
||||
#define sb_append_nstr gebs_sb_append_nstr
|
||||
|
||||
#define rename1 gebs_rename
|
||||
#define remove1 gebs_remove
|
||||
#define mkdir1 gebs_mkdir
|
||||
#define exists1 gebs_exists
|
||||
|
||||
#define Cmd Gebs_Cmd
|
||||
#define cmd_append_alloc gebs_cmd_append_alloc
|
||||
#define cmd_free_aloc gebs_cmd_free_alloc
|
||||
#define cmd_append gebs_cmd_append
|
||||
#define cmd_free gebs_cmd_free
|
||||
#define cmd_run_alloc gebs_cmd_run_alloc
|
||||
#define cmd_run gebs_cmd_run
|
||||
#define cmd_run_sync_alloc gebs_cmd_run_sync_alloc
|
||||
#define CMD GEBS_CMD
|
||||
#define cmd_run_sync_collect_alloc gebs_cmd_run_sync_collect_alloc
|
||||
#define cmd_run_collect_alloc gebs_cmd_run_collect_alloc
|
||||
#define cmd_run_collect gebs_cmd_run_collect
|
||||
|
||||
#define needs_rebuild gebs_needs_rebuild
|
||||
#define needs_rebuild_many gebs_needs_rebuild_many
|
||||
#define rebuild_self gebs_rebuild_self
|
||||
#define make_compile_flags gebs_make_compile_flags
|
||||
|
||||
#define scratch_arena gebs_scratch_arena
|
||||
#define fmt gebs_fmt
|
||||
#define scratch_arena_reset gebs_scratch_arena_reset
|
||||
|
||||
#endif
|
||||
|
||||
#endif // GEBS_H_
|
||||
|
Reference in New Issue
Block a user