cgen, stb_truetype defines

This commit is contained in:
Krzosa Karol
2025-01-18 09:18:57 +01:00
parent 63dda7bf13
commit 7e52440e18
7 changed files with 121 additions and 48 deletions

View File

@@ -8,59 +8,20 @@
#include "src/meta/build_tool.c"
#include "src/meta/parser.c"
#include "src/meta/serialize.c"
#include "src/meta/cgen.c"
#include "src/app/app.meta.c"
#include "src/wasm_app/ui.meta.c"
void list_files_recursive(sb8_t *sb, s8_t path) {
for (OS_FileIter iter = OS_IterateFiles(&Perm, path); OS_IsValid(iter); OS_Advance(&iter)) {
if (iter.is_directory) {
list_files_recursive(sb, iter.absolute_path);
} else {
sb8_append(sb, iter.absolute_path);
}
}
}
typedef struct c_file_t c_file_t;
struct c_file_t {
c_file_t *next;
s8_t path;
s8_t content;
};
typedef struct c_files_t c_files_t;
struct c_files_t {
c_file_t *first;
c_file_t *last;
};
int main(int argc, char **argv) {
cache_init(&Perm, s8_lit("cache_build_file"));
int ok = 0;
ma_arena_t *arena = ma_create(ma_default_reserve_size);
sb8_t *include_paths = sb8(arena);
sb8_append(include_paths, OS_GetAbsolutePath(&Perm, s8_lit("../src")));
c_files_t files = {0};
{
sb8_t *c = &(sb8_t){.arena = arena};
list_files_recursive(c, s8_lit(".."));
for (sb8_node_t *it = c->first; it; it = it->next) {
s8_t abs = it->string;
b32 is_c_file = s8_ends_with(abs, s8_lit(".c"), true) || s8_ends_with(abs, s8_lit(".cpp"), true) || s8_ends_with(abs, s8_lit(".h"), true) || s8_ends_with(abs, s8_lit(".hpp"), true);
b32 is_build_file = s8_ends_with(abs, s8_lit("build_file.c"), true);
if (!is_c_file) continue;
if (is_build_file) continue;
c_file_t *file = ma_push_type(arena, c_file_t);
file->path = abs;
file->content = OS_ReadFile(&Perm, abs);
SLLQ_APPEND(files.first, files.last, file);
lex_tokens(arena, file->path.str, file->content);
}
}
cg_files_t files = cg_lex_files(arena, s8_lit("../src/wasm_app/main.c"), include_paths);
meta_app(arena);
meta_ui(arena);
@@ -70,15 +31,14 @@ int main(int argc, char **argv) {
os_set_working_dir("../../build");
}
b32 execute_python_snippets = false; // make sure to not abuse just for quick maths
b32 execute_python_snippets = false; // make sure to not abuse, just for quick maths
b32 run_server = false;
b32 core_test_target = false;
b32 win32_target = true;
b32 wasm_target = false;
if (execute_python_snippets) {
for (c_file_t *it = files.first; it; it = it->next) {
for (cg_file_t *it = files.first; it; it = it->next) {
i64 idx = s8_find(it->content, s8_lit("/*#"), 0);
if (idx != -1) os_systemf("\"D:\\dev\\apps\\bin\\pyorun.bat\" %s", it->path.str);
}