From c537cf84e01cef2cbdad808325438925b5ecfd6b Mon Sep 17 00:00:00 2001 From: KxD-Work Date: Thu, 7 Nov 2024 16:16:33 -0400 Subject: [PATCH 1/3] nob_header_path function --- nob.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nob.h b/nob.h index 022a98e..7aba8cb 100644 --- a/nob.h +++ b/nob.h @@ -465,6 +465,8 @@ bool nob_set_current_dir(const char *path); void nob__go_rebuild_urself(const char *source_path, int argc, char **argv); #define NOB_GO_REBUILD_URSELF(argc, argv) nob__go_rebuild_urself(__FILE__, argc, argv) +const char *nob_header_path(void); + typedef struct { size_t count; const char *data; @@ -565,6 +567,8 @@ char *nob_win32_error_message(DWORD err); // Any messages with the level below nob_minimal_log_level are going to be suppressed. Nob_Log_Level nob_minimal_log_level = NOB_INFO; +const char *nob_header_path(void) {return __FILE__;} + #ifdef _WIN32 // Base on https://stackoverflow.com/a/75644008 From d4caa6c6a79f4653929ff1fef3c295614d74f0af Mon Sep 17 00:00:00 2001 From: KxD-Work Date: Thu, 7 Nov 2024 16:19:23 -0400 Subject: [PATCH 2/3] Using nob.h to check if nob.c needs rebuild --- nob.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nob.h b/nob.h index 7aba8cb..14bb75d 100644 --- a/nob.h +++ b/nob.h @@ -621,7 +621,9 @@ void nob__go_rebuild_urself(const char *source_path, int argc, char **argv) } #endif - int rebuild_is_needed = nob_needs_rebuild1(binary_path, source_path); + const char* inputs[] = {source_path, nob_header_path()}; + int rebuild_is_needed = nob_needs_rebuild(binary_path, inputs, NOB_ARRAY_LEN(inputs)); + // int rebuild_is_needed = nob_needs_rebuild1(binary_path, source_path); if (rebuild_is_needed < 0) exit(1); // error if (!rebuild_is_needed) return; // no rebuild is needed From b8403e763be6ed5f7bc1b563392228632b752ab7 Mon Sep 17 00:00:00 2001 From: KxD-Work Date: Tue, 12 Nov 2024 16:40:58 -0400 Subject: [PATCH 3/3] nob_header_path test --- nob.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nob.c b/nob.c index b8c098c..44e0e24 100644 --- a/nob.c +++ b/nob.c @@ -29,6 +29,12 @@ bool build_and_run_test(Cmd *cmd, const char *test_name) int main(int argc, char **argv) { NOB_GO_REBUILD_URSELF(argc, argv); + + const char *nob_header = nob_header_path(); + if(nob_file_exists(nob_header) != 1) + nob_log(NOB_ERROR, "nob.h not found at '%s'", nob_header); + else + nob_log(NOB_INFO, "nob.h found at '%s'", nob_header); Cmd cmd = {0};