Skip to content

Commit

Permalink
Replace single MUSIALIZER_TARGET with a bunch of MUSIALIZER_TARGET_*
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Jun 9, 2024
1 parent 84dc2c9 commit 83d019d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 26 additions & 25 deletions nob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/hotreload.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <stdbool.h>

#include "plug.h"
#include "src_build/targets.h"
#include "build/config.h"

#ifdef MUSIALIZER_HOTRELOAD
Expand Down
2 changes: 1 addition & 1 deletion src/hotreload_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 0 additions & 1 deletion src/plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 12 additions & 12 deletions src_build/nob_configured.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions src_build/targets.h

This file was deleted.

0 comments on commit 83d019d

Please sign in to comment.