Explorar o código

Replace single MUSIALIZER_TARGET with a bunch of MUSIALIZER_TARGET_*

rexim hai 1 ano
pai
achega
83d019df6b
Modificáronse 7 ficheiros con 40 adicións e 50 borrados
  1. 1 1
      README.md
  2. 26 25
      nob.c
  3. 0 1
      src/hotreload.h
  4. 1 1
      src/hotreload_posix.c
  5. 0 1
      src/plug.c
  6. 12 12
      src_build/nob_configured.c
  7. 0 9
      src_build/targets.h

+ 1 - 1
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

+ 26 - 25
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);

+ 0 - 1
src/hotreload.h

@@ -4,7 +4,6 @@
 #include <stdbool.h>
 
 #include "plug.h"
-#include "src_build/targets.h"
 #include "build/config.h"
 
 #ifdef MUSIALIZER_HOTRELOAD

+ 1 - 1
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";

+ 0 - 1
src/plug.c

@@ -6,7 +6,6 @@
 #include <string.h>
 #include <complex.h>
 
-#include "src_build/targets.h"
 #include "build/config.h"
 #include "plug.h"
 #include "ffmpeg.h"

+ 12 - 12
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_<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)

+ 0 - 9
src_build/targets.h

@@ -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_