diff options
author | grm <grm@eyesin.space> | 2025-03-02 13:53:54 +0200 |
---|---|---|
committer | grm <grm@eyesin.space> | 2025-03-02 13:53:54 +0200 |
commit | 9847614871e861c216425b95a8300dba37b0f6e6 (patch) | |
tree | f319cc5ebd58d2247d546a3c2149ce85559be6d8 /src/b.h | |
parent | d5e9beaf5cc38c0e57bbc555a6e3054f3bf000d8 (diff) | |
download | synth-project-9847614871e861c216425b95a8300dba37b0f6e6.tar.gz synth-project-9847614871e861c216425b95a8300dba37b0f6e6.tar.bz2 synth-project-9847614871e861c216425b95a8300dba37b0f6e6.zip |
Also improve midi and add tt for templating
Diffstat (limited to 'src/b.h')
-rw-r--r-- | src/b.h | 35 |
1 files changed, 20 insertions, 15 deletions
@@ -50,7 +50,8 @@ typedef enum { B_INFO, B_CMD, - B_BUILDING, + B_COMPILE, + B_TEMPLATE, B_CHANGE, B_WARNING, B_ERROR, @@ -195,8 +196,8 @@ void b_temp_rewind(size_t checkpoint); int is_path1_modified_after_path2(const char *path1, const char *path2); bool b_rename(const char *old_path, const char *new_path); -int b_needs_rebuild(const char *output_path, const char **input_paths, size_t input_paths_count); -int b_needs_rebuild1(const char *output_path, const char *input_path); +int b_needs_rebuild(B_Log_Level log, const char *output_path, const char **input_paths, size_t input_paths_count); +int b_needs_rebuild1(B_Log_Level log, const char *output_path, const char *input_path); int b_file_exists(const char *file_path); // TODO: add MinGW support for Go Rebuild Urself™ Technology @@ -246,7 +247,7 @@ int b_file_exists(const char *file_path); assert(argc >= 1); \ const char *binary_path = argv[0]; \ \ - int rebuild_is_needed = b_needs_rebuild(binary_path, &source_path, 1); \ + int rebuild_is_needed = b_needs_rebuild(B_COMPILE, binary_path, &source_path, 1); \ if (rebuild_is_needed < 0) exit(1); \ if (rebuild_is_needed) { \ B_String_Builder sb = {0}; \ @@ -506,22 +507,25 @@ void b_log(B_Log_Level level, const char *fmt, ...) { switch (level) { case B_INFO: - fprintf(stderr, "[INFO] "); + fprintf(stderr, " [INFO] "); break; case B_CMD: - fprintf(stderr, "[CMD] "); + fprintf(stderr, " [CMD] "); break; - case B_BUILDING: - fprintf(stderr, "[BUILDING] "); + case B_COMPILE: + fprintf(stderr, " [COMPILE] "); + break; + case B_TEMPLATE: + fprintf(stderr, "[TEMPLATE] "); break; case B_CHANGE: - fprintf(stderr, "[CHANGE] "); + fprintf(stderr, " [CHANGE] "); break; case B_WARNING: - fprintf(stderr, "[WARNING] "); + fprintf(stderr, " [WARNING] "); break; case B_ERROR: - fprintf(stderr, "[ERROR] "); + fprintf(stderr, " [ERROR] "); break; default: B_ASSERT(0 && "unreachable"); @@ -734,14 +738,14 @@ const char *b_temp_sv_to_cstr(B_String_View sv) return result; } -int b_needs_rebuild(const char *output_path, const char **input_paths, size_t input_paths_count) +int b_needs_rebuild(B_Log_Level log, const char *output_path, const char **input_paths, size_t input_paths_count) { struct stat statbuf = {0}; if (stat(output_path, &statbuf) < 0) { // NOTE: if output does not exist it 100% must be rebuilt if (errno == ENOENT) { - b_log(B_BUILDING, "%s", output_path); + b_log(log, "%s", output_path); return 1; } b_log(B_ERROR, "could not stat %s: %s", output_path, strerror(errno)); @@ -760,6 +764,7 @@ int b_needs_rebuild(const char *output_path, const char **input_paths, size_t in // NOTE: if even a single input_path is fresher than output_path that's 100% rebuild if (input_path_time > output_path_time) { b_log(B_CHANGE, "%s", input_path); + b_log(log, "%s", output_path); return 1; } } @@ -767,9 +772,9 @@ int b_needs_rebuild(const char *output_path, const char **input_paths, size_t in return 0; } -int b_needs_rebuild1(const char *output_path, const char *input_path) +int b_needs_rebuild1(B_Log_Level log, const char *output_path, const char *input_path) { - return b_needs_rebuild(output_path, &input_path, 1); + return b_needs_rebuild(log, output_path, &input_path, 1); } bool b_rename(const char *old_path, const char *new_path) |