From 83d019df6bd89a28a60ae422d99059dff4ba258d Mon Sep 17 00:00:00 2001 From: rexim Date: Sun, 9 Jun 2024 13:56:29 +0700 Subject: [PATCH] Replace single MUSIALIZER_TARGET with a bunch of MUSIALIZER_TARGET_* --- README.md | 2 +- nob.c | 51 +++++++++++++++++++------------------- src/hotreload.h | 1 - src/hotreload_posix.c | 2 +- src/plug.c | 1 - src_build/nob_configured.c | 24 +++++++++--------- src_build/targets.h | 9 ------- 7 files changed, 40 insertions(+), 50 deletions(-) delete mode 100644 src_build/targets.h diff --git a/README.md b/README.md index 28da2dd..64bce05 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ From within `vcvarsall.bat` do Install [MinGW-w64](https://www.mingw-w64.org/) from your distro repository. -Edit `./build/config.h` and set `MUSIALIZER_TARGET` to `TARGET_WIN64_MINGW`. +Edit `./build/config.h` and set `MUSIALIZER_TARGET_WIN64_MINGW` instead of `MUSIALIZER_TARGET_LINUX`. ```console $ ./nob diff --git a/nob.c b/nob.c index 37b3741..931ab5c 100644 --- a/nob.c +++ b/nob.c @@ -16,36 +16,36 @@ void generate_default_config(Nob_String_Builder *content) nob_sb_append_cstr(content, "//// Build target. Pick only one!\n"); #ifdef _WIN32 # if defined(_MSC_VER) - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_LINUX\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_WIN64_MINGW\n"); - nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET TARGET_WIN64_MSVC\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_MACOS\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_OPENBSD\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_LINUX\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_WIN64_MINGW\n"); + nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET_WIN64_MSVC\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_MACOS\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_OPENBSD\n"); # else - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_LINUX\n"); - nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET TARGET_WIN64_MINGW\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_WIN64_MSVC\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_MACOS\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_OPENBSD\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_LINUX\n"); + nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET_WIN64_MINGW\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_WIN64_MSVC\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_MACOS\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_OPENBSD\n"); # endif #elif defined (__APPLE__) || defined (__MACH__) - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_LINUX\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_WIN64_MINGW\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_WIN64_MSVC\n"); - nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET TARGET_MACOS\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_OPENBSD\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_LINUX\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_WIN64_MINGW\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_WIN64_MSVC\n"); + nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET_MACOS\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_OPENBSD\n"); #elif defined(__OpenBSD__) - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_LINUX\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_WIN64_MINGW\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_WIN64_MSVC\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_MACOS\n"); - nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET TARGET_OPENBSD\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_LINUX\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_WIN64_MINGW\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_WIN64_MSVC\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_MACOS\n"); + nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET_OPENBSD\n"); #else - nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET TARGET_LINUX\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_WIN64_MINGW\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_WIN64_MSVC\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_MACOS\n"); - nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET TARGET_OPENBSD\n"); + nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET_LINUX\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_WIN64_MINGW\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_WIN64_MSVC\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_MACOS\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_TARGET_OPENBSD\n"); #endif nob_sb_append_cstr(content, "\n"); @@ -76,6 +76,7 @@ int main(int argc, char **argv) int build_conf_exists = nob_file_exists(build_conf_path); if (build_conf_exists < 0) return 1; if (build_conf_exists) { + // @backcomp nob_log(NOB_ERROR, "We found %s. That means your build folder has an old schema.", build_conf_path); nob_log(NOB_ERROR, "Instead of %s you are suppose to use %s to configure the build now.", build_conf_path, CONFIG_PATH); nob_log(NOB_ERROR, "Remove your ./build/ folder and run %s again to regenerate the folder with the new schema.", program); diff --git a/src/hotreload.h b/src/hotreload.h index 5ac06c7..84c0dec 100644 --- a/src/hotreload.h +++ b/src/hotreload.h @@ -4,7 +4,6 @@ #include #include "plug.h" -#include "src_build/targets.h" #include "build/config.h" #ifdef MUSIALIZER_HOTRELOAD diff --git a/src/hotreload_posix.c b/src/hotreload_posix.c index 9e757a9..73b14d3 100644 --- a/src/hotreload_posix.c +++ b/src/hotreload_posix.c @@ -5,7 +5,7 @@ #include "hotreload.h" -#if MUSIALIZER_TARGET == TARGET_MACOS +#if defined(MUSIALIZER_TARGET_MACOS) static const char *libplug_file_name = "libplug.dylib"; #else static const char *libplug_file_name = "libplug.so"; diff --git a/src/plug.c b/src/plug.c index c79f8e1..55ed61d 100644 --- a/src/plug.c +++ b/src/plug.c @@ -6,7 +6,6 @@ #include #include -#include "src_build/targets.h" #include "build/config.h" #include "plug.h" #include "ffmpeg.h" diff --git a/src_build/nob_configured.c b/src_build/nob_configured.c index effac2a..b263701 100644 --- a/src_build/nob_configured.c +++ b/src_build/nob_configured.c @@ -3,17 +3,10 @@ #define NOB_IMPLEMENTATION #include "../nob.h" #include "../build/config.h" -#include "targets.h" #define RAYLIB_VERSION "5.0" #define CONFIG_PATH "./build/config.h" -#define TARGET_LINUX 0 -#define TARGET_WIN64_MINGW 1 -#define TARGET_WIN64_MSVC 2 -#define TARGET_MACOS 3 -#define TARGET_OPENBSD 4 - static const char *raylib_modules[] = { "rcore", "raudio", @@ -25,16 +18,23 @@ static const char *raylib_modules[] = { "utils", }; -#if MUSIALIZER_TARGET == TARGET_LINUX +// @backcomp +#if defined(MUSIALIZER_TARGET) +#error "We recently replaced a single MUSIALIZER_TARGET macro with a bunch of MUSIALIZER_TARGET_ macros instead. Since MUSIALIZER_TARGET is still defined your ./build/ is probably old. Please remove it so ./build/config.h gets regenerated." +#endif // MUSIALIZER_TARGET + +#if defined(MUSIALIZER_TARGET_LINUX) #include "nob_linux.c" -#elif MUSIALIZER_TARGET == TARGET_MACOS +#elif defined(MUSIALIZER_TARGET_MACOS) #include "nob_macos.c" -#elif MUSIALIZER_TARGET == TARGET_WIN64_MINGW +#elif defined(MUSIALIZER_TARGET_WIN64_MINGW) #include "nob_win64_mingw.c" -#elif MUSIALIZER_TARGET == TARGET_WIN64_MSVC +#elif defined(MUSIALIZER_TARGET_WIN64_MSVC) #include "nob_win64_msvc.c" -#elif MUSIALIZER_TARGET == TARGET_OPENBSD +#elif defined(MUSIALIZER_TARGET_OPENBSD) #include "nob_openbsd.c" +#else +#error "No Musializer Target is defined. Check your ./build/config.h." #endif // MUSIALIZER_TARGET void log_available_subcommands(const char *program, Nob_Log_Level level) diff --git a/src_build/targets.h b/src_build/targets.h deleted file mode 100644 index 7ee13a9..0000000 --- a/src_build/targets.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef TARGETS_H_ -#define TARGETS_H_ - -#define TARGET_LINUX 0 -#define TARGET_WIN64_MINGW 1 -#define TARGET_WIN64_MSVC 2 -#define TARGET_MACOS 3 - -#endif // TARGETS_H_