Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed x86_64-w64-mingw32-ar not found for windows #99

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5c87967
fixed x86_64-w64-mingw32-ar not found for windows
Subhranil-Maity Mar 2, 2024
cd446f2
Merge branch 'tsoding:master' into ar
Subhranil-Maity Mar 3, 2024
416141e
revised fix for x86_64-w64-mingw32-ar not found on windows while usin…
Subhranil-Maity Mar 3, 2024
ce54b42
Merge branch 'ar' of https://github.com/Subhranil-Maity/musializer in…
Subhranil-Maity Mar 3, 2024
c848672
Implement MUSIALIZER_ACT_ON_PRESS feature flag
rexim May 8, 2024
1d229d9
Speed up canceling of ffmpeg rendering
rexim May 8, 2024
0234b37
Put cancel rendering button on the right and add a tooltip for it
rexim May 8, 2024
b135964
Update CHANGELOG
rexim May 8, 2024
28c4fb3
[nob.c] Add missing config options to log_config()
rexim Jun 7, 2024
a60fe17
Simplify asset management
rexim Jun 7, 2024
76062c0
Try to fix build on MacOS
rexim Jun 7, 2024
963b490
Forward declare plug functions for plug.c translation unit
rexim Jun 8, 2024
12048dd
Port some minor nob.h changes from panim
rexim Jun 8, 2024
4b2b84e
Remove duplicates of external deps from raylib
rexim Jun 9, 2024
a602420
__declspec(dllexport) on WIN32 only when it's MUSIALIZER_HOTRELOAD
rexim Jun 9, 2024
36d5d5b
Test hotreload build on WIN32
rexim Jun 9, 2024
592a848
Typo
rexim Jun 9, 2024
a196d54
Proper forward declaration for the plug function
rexim Jun 9, 2024
a9767c2
Typo
rexim Jun 9, 2024
8e7b64e
Merge pull request #112 from tsoding/remove-external-duplicates
rexim Jun 9, 2024
797baf4
Factor out everything related to the buidl to src_build/ folder
rexim Jun 9, 2024
0724c99
Merge pull request #113 from tsoding/src-build
rexim Jun 9, 2024
55c73b6
Factor out src_build/nob_configured.c
rexim Jun 9, 2024
84dc2c9
Merge pull request #114 from tsoding/nob-configured
rexim Jun 9, 2024
83d019d
Replace single MUSIALIZER_TARGET with a bunch of MUSIALIZER_TARGET_*
rexim Jun 9, 2024
9a617af
Merge pull request #115 from tsoding/target
rexim Jun 9, 2024
18ae3d4
Factor out src_build/configurer.c
rexim Jun 10, 2024
3ef7b49
Merge pull request #116 from tsoding/configurer
rexim Jun 10, 2024
b079e10
nob_configured -> nob_stage2
rexim Jun 10, 2024
80a284f
Use genf/fprintf instead of nob_sb_append_cstr
rexim Jun 10, 2024
97c4965
Tuck up some file creation code
rexim Jun 10, 2024
29707fd
[README] Remove a note regarding ./resources/ folder
rexim Jun 11, 2024
2b39dbf
Remove build.zig from the vendored dependencies
rexim Jun 11, 2024
f106c92
Remove raylib-4.5.0
rexim Jun 11, 2024
48fcbf1
fixed x86_64-w64-mingw32-ar not found for windows
Subhranil-Maity Mar 2, 2024
796a71a
revised fix for x86_64-w64-mingw32-ar not found on windows while usin…
Subhranil-Maity Mar 3, 2024
c344287
Merge branch 'ar' of https://github.com/Subhranil-Maity/musializer in…
Subhranil-Maity Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/nob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
path: build/
windows:
runs-on: windows-latest
strategy:
matrix:
hotreload:
- "/DMUSIALIZER_HOTRELOAD"
- ""
steps:
- name: Clone GIT repo
uses: actions/checkout@v4
Expand All @@ -48,7 +53,7 @@ jobs:
# https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#create-your-own-command-prompt-shortcut
run: |
call "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat"
cl.exe -o nob.exe nob.c
cl.exe ${{ matrix.hotreload }} -o nob.exe nob.c
- name: Run nob
shell: cmd
run: |
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Alpha Release 3

- Added FLAC support

- Added Cancel Rendering button

Windows Alpha Release 2
----------------------------------------------------------------------

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ $ ./nob
$ ./build/musializer
```

Keep in mind that the application needs [./resources/](./resources/) to be present in the folder it is ran from.

If the build fails because of missing header files, you may need to install the X11 dev packages.

On Debian, Ubuntu, etc, do this:
Expand All @@ -77,7 +75,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
305 changes: 14 additions & 291 deletions nob.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,296 +7,22 @@
#include <errno.h>

#define NOB_IMPLEMENTATION
#include "./src/nob.h"

#define CONFIG_PATH "./build/config.h"

#ifdef CONFIGURED

#include "./src/targets.h"
#include CONFIG_PATH

#define RAYLIB_VERSION "5.0"

#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",
"rglfw",
"rmodels",
"rshapes",
"rtext",
"rtextures",
"utils",
};

#if MUSIALIZER_TARGET == TARGET_LINUX
#include "src/nob_linux.c"
#elif MUSIALIZER_TARGET == TARGET_MACOS
#include "src/nob_macos.c"
#elif MUSIALIZER_TARGET == TARGET_WIN64_MINGW
#include "src/nob_win64_mingw.c"
#elif MUSIALIZER_TARGET == TARGET_WIN64_MSVC
#include "src/nob_win64_msvc.c"
#elif MUSIALIZER_TARGET == TARGET_OPENBSD
#include "src/nob_openbsd.c"
#endif // MUSIALIZER_TARGET

void log_available_subcommands(const char *program, Nob_Log_Level level)
{
nob_log(level, "Usage: %s [subcommand]", program);
nob_log(level, "Subcommands:");
nob_log(level, " build (default)");
nob_log(level, " dist");
nob_log(level, " svg");
nob_log(level, " help");
}

void log_config(Nob_Log_Level level)
{
nob_log(level, "Target: %s", MUSIALIZER_TARGET_NAME);
#ifdef MUSIALIZER_HOTRELOAD
nob_log(level, "Hotreload: ENABLED");
#else
nob_log(level, "Hotreload: DISABLED");
#endif // MUSIALIZER_HOTRELOAD
#ifdef MUSIALIZER_MICROPHONE
nob_log(level, "Microphone: ENABLED");
#else
nob_log(level, "Microphone: DISABLED");
#endif // MUSIALIZER_MICROPHONE
}

#define genf(out, ...) \
do { \
fprintf((out), __VA_ARGS__); \
fprintf((out), " // %s:%d\n", __FILE__, __LINE__); \
} while(0)

typedef struct {
const char *file_path;
size_t offset;
size_t size;
} Resource;

Resource resources[] = {
{ .file_path = "./resources/logo/logo-256.png" },
{ .file_path = "./resources/shaders/glsl330/circle.fs" },
{ .file_path = "./resources/shaders/glsl120/circle.fs" },
{ .file_path = "./resources/icons/volume.png" },
{ .file_path = "./resources/icons/play.png" },
{ .file_path = "./resources/icons/render.png" },
{ .file_path = "./resources/icons/fullscreen.png" },
{ .file_path = "./resources/icons/microphone.png" },
{ .file_path = "./resources/fonts/Alegreya-Regular.ttf" },
};

bool generate_resource_bundle(void)
{
bool result = true;
Nob_String_Builder bundle = {0};
Nob_String_Builder content = {0};
FILE *out = NULL;

// bundle = [aaaaaaaaabbbbb]
// ^ ^
// content = []
// 0, 9

for (size_t i = 0; i < NOB_ARRAY_LEN(resources); ++i) {
content.count = 0;
if (!nob_read_entire_file(resources[i].file_path, &content)) nob_return_defer(false);
resources[i].offset = bundle.count;
resources[i].size = content.count;
nob_da_append_many(&bundle, content.items, content.count);
nob_da_append(&bundle, 0);
}

const char *bundle_h_path = "./build/bundle.h";
out = fopen(bundle_h_path, "wb");
if (out == NULL) {
nob_log(NOB_ERROR, "Could not open file %s for writing: %s", bundle_h_path, strerror(errno));
nob_return_defer(false);
}

genf(out, "#ifndef BUNDLE_H_");
genf(out, "#define BUNDLE_H_");
genf(out, "typedef struct {");
genf(out, " const char *file_path;");
genf(out, " size_t offset;");
genf(out, " size_t size;");
genf(out, "} Resource;");
genf(out, "size_t resources_count = %zu;", NOB_ARRAY_LEN(resources));
genf(out, "Resource resources[] = {");
for (size_t i = 0; i < NOB_ARRAY_LEN(resources); ++i) {
genf(out, " {.file_path = \"%s\", .offset = %zu, .size = %zu},",
resources[i].file_path, resources[i].offset, resources[i].size);
}
genf(out, "};");

genf(out, "unsigned char bundle[] = {");
size_t row_size = 20;
for (size_t i = 0; i < bundle.count; ){
fprintf(out, " ");
for (size_t col = 0; col < row_size && i < bundle.count; ++col, ++i) {
fprintf(out, "0x%02X, ", (unsigned char)bundle.items[i]);
}
genf(out, "");
}
genf(out, "};");
genf(out, "#endif // BUNDLE_H_");

nob_log(NOB_INFO, "Generated %s", bundle_h_path);

defer:
if (out) fclose(out);
free(content.items);
free(bundle.items);
return result;
}

int main(int argc, char **argv)
{
nob_log(NOB_INFO, "--- STAGE 2 ---");
log_config(NOB_INFO);
nob_log(NOB_INFO, "---");

const char *program = nob_shift_args(&argc, &argv);

const char *subcommand = NULL;
if (argc <= 0) {
subcommand = "build";
} else {
subcommand = nob_shift_args(&argc, &argv);
}

if (strcmp(subcommand, "build") == 0) {
if (!build_raylib()) return 1;
#ifndef MUSIALIZER_UNBUNDLE
if (!generate_resource_bundle()) return 1;
#endif // MUSIALIZER_UNBUNDLE
if (!build_musializer()) return 1;
} else if (strcmp(subcommand, "dist") == 0) {
if (!build_dist()) return 1;
} else if (strcmp(subcommand, "config") == 0) {
nob_log(NOB_ERROR, "The `config` command does not exist anymore!");
nob_log(NOB_ERROR, "Edit %s to configure the build!", CONFIG_PATH);
return 1;
} else if (strcmp(subcommand, "svg") == 0) {
Nob_Procs procs = {0};

Nob_Cmd cmd = {0};

typedef struct {
const char *in_path;
const char *out_path;
int resize;
} Svg;

Svg svgs[] = {
{.out_path = "./resources/logo/logo-256.ico", .in_path = "./resources/logo/logo.svg", .resize = 256, },
{.out_path = "./resources/logo/logo-256.png", .in_path = "./resources/logo/logo.svg", .resize = 256, },
{.out_path = "./resources/icons/fullscreen.png", .in_path = "./resources/icons/fullscreen.svg" },
{.out_path = "./resources/icons/volume.png", .in_path = "./resources/icons/volume.svg" },
{.out_path = "./resources/icons/play.png", .in_path = "./resources/icons/play.svg" },
{.out_path = "./resources/icons/render.png", .in_path = "./resources/icons/render.svg" },
{.out_path = "./resources/icons/microphone.png", .in_path = "./resources/icons/microphone.svg" },
};

for (size_t i = 0; i < NOB_ARRAY_LEN(svgs); ++i) {
if (nob_needs_rebuild1(svgs[i].out_path, svgs[i].in_path)) {
cmd.count = 0;
nob_cmd_append(&cmd, "convert");
nob_cmd_append(&cmd, "-background", "None");
nob_cmd_append(&cmd, svgs[i].in_path);
if (svgs[i].resize) {
nob_cmd_append(&cmd, "-resize", nob_temp_sprintf("%d", svgs[i].resize));
}
nob_cmd_append(&cmd, svgs[i].out_path);
nob_da_append(&procs, nob_cmd_run_async(cmd));
} else {
nob_log(NOB_INFO, "%s is up to date", svgs[i].out_path);
}
}

if (!nob_procs_wait(procs)) return 1;
} else if (strcmp(subcommand, "help") == 0){
log_available_subcommands(program, NOB_INFO);
} else {
nob_log(NOB_ERROR, "Unknown subcommand %s", subcommand);
log_available_subcommands(program, NOB_ERROR);
}
// TODO: it would be nice to check for situations like building TARGET_WIN64_MSVC on Linux and report that it's not possible.
return 0;
}

#else

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");
# 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");
# 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");
#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");
#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");
#endif

nob_sb_append_cstr(content, "\n");
nob_sb_append_cstr(content, "//// Moves everything in src/plug.c to a separate \"DLL\" so it can be hotreloaded. Works only for Linux right now\n");
nob_sb_append_cstr(content, "// #define MUSIALIZER_HOTRELOAD\n");
nob_sb_append_cstr(content, "\n");
nob_sb_append_cstr(content, "//// Don't bundle resources/ folder with the executable and load the resources directly from the folder.\n");
nob_sb_append_cstr(content, "// #define MUSIALIZER_UNBUNDLE\n");
nob_sb_append_cstr(content, "\n");
nob_sb_append_cstr(content, "//// Unfinished feature that enables capturing sound from the mic.\n");
nob_sb_append_cstr(content, "// #define MUSIALIZER_MICROPHONE\n");
}
#include "./nob.h"
#include "./src_build/configurer.c"

int main(int argc, char **argv)
{
NOB_GO_REBUILD_URSELF(argc, argv);

const char *program = nob_shift_args(&argc, &argv);
const char *build_conf_path = "./build/build.conf";
int build_conf_exists = nob_file_exists(build_conf_path);

const char *old_build_conf_path = "./build/build.conf";
int build_conf_exists = nob_file_exists(old_build_conf_path);
if (build_conf_exists < 0) return 1;
if (build_conf_exists) {
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);
// @backcomp
nob_log(NOB_ERROR, "We found %s. That means your build folder has an old schema.", old_build_conf_path);
nob_log(NOB_ERROR, "Instead of %s you are suppose to use %s to configure the build now.", old_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);
return 1;
}
Expand All @@ -308,25 +34,22 @@ int main(int argc, char **argv)
int config_exists = nob_file_exists(CONFIG_PATH);
if (config_exists < 0) return 1;
if (config_exists == 0) {
nob_log(NOB_INFO, "Generating %s", CONFIG_PATH);
Nob_String_Builder content = {0};
generate_default_config(&content);
if (!nob_write_entire_file(CONFIG_PATH, content.items, content.count)) return 1;
if (!generate_default_config(CONFIG_PATH)) return 1;
} else {
nob_log(NOB_INFO, "file `%s` already exists", CONFIG_PATH);
}

if (!generate_config_logger("build/config_logger.c")) return 1;

Nob_Cmd cmd = {0};
const char *configured_binary = "build/nob.configured";
nob_cmd_append(&cmd, NOB_REBUILD_URSELF(configured_binary, "nob.c"), "-DCONFIGURED");
const char *stage2_binary = "build/nob_stage2";
nob_cmd_append(&cmd, NOB_REBUILD_URSELF(stage2_binary, "./src_build/nob_stage2.c"));
if (!nob_cmd_run_sync(cmd)) return 1;

cmd.count = 0;
nob_cmd_append(&cmd, configured_binary);
nob_cmd_append(&cmd, stage2_binary);
nob_da_append_many(&cmd, argv, argc);
if (!nob_cmd_run_sync(cmd)) return 1;

return 0;
}

#endif // CONFIGURED
Loading