Skip to content

Commit

Permalink
don't use prefix for ar on windows hosts
Browse files Browse the repository at this point in the history
The prefixed `x86_64-w64-mingw32-ar` doesn't exist on windows. Since this is a common issue with mingw utilities on windows distributions I have created a macro `MAYBE_PREFIXED` to prefix binaries when running on non windows hosts.
  • Loading branch information
Markos-Th09 committed Aug 21, 2024
1 parent f106c92 commit 55c9436
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src_build/nob_win64_mingw.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#define MUSIALIZER_TARGET_NAME "win64-mingw"

// On windows, mingw doesn't have the `x86_64-w64-mingw32-` prefix for tools such as `windres` or `ar`.
// For gcc, you can use both `x86_64-w64-mingw32-gcc` and just `gcc`
#ifdef _WIN32
#define MAYBE_PREFIXED(x) x
#else
#define MAYBE_PREFIXED(x) "x86_64-w64-mingw32-"x
#endif // _WIN32

bool build_musializer(void)
{
bool result = true;
Nob_Cmd cmd = {0};
Nob_Procs procs = {0};

cmd.count = 0;
#ifdef _WIN32
// On windows, mingw doesn't have the `x86_64-w64-mingw32-` prefix for windres.
// For gcc, you can use both `x86_64-w64-mingw32-gcc` and just `gcc`
nob_cmd_append(&cmd, "windres");
#else
nob_cmd_append(&cmd, "x86_64-w64-mingw32-windres");
#endif // _WIN32
nob_cmd_append(&cmd, MAYBE_PREFIXED("windres"));
nob_cmd_append(&cmd, "./src/musializer.rc");
nob_cmd_append(&cmd, "-O", "coff");
nob_cmd_append(&cmd, "-o", "./build/musializer.res");
Expand Down Expand Up @@ -132,7 +134,8 @@ bool build_raylib()
const char *libraylib_path = nob_temp_sprintf("%s/libraylib.a", build_path);

if (nob_needs_rebuild(libraylib_path, object_files.items, object_files.count)) {
nob_cmd_append(&cmd, "x86_64-w64-mingw32-ar", "-crs", libraylib_path);
nob_cmd_append(&cmd, MAYBE_PREFIXED("ar"));
nob_cmd_append(&cmd, "-crs", libraylib_path);
for (size_t i = 0; i < NOB_ARRAY_LEN(raylib_modules); ++i) {
const char *input_path = nob_temp_sprintf("%s/%s.o", build_path, raylib_modules[i]);
nob_cmd_append(&cmd, input_path);
Expand Down

0 comments on commit 55c9436

Please sign in to comment.