|
@@ -11,181 +11,175 @@
|
|
bool build_musializer(void)
|
|
bool build_musializer(void)
|
|
{
|
|
{
|
|
bool result = true;
|
|
bool result = true;
|
|
- Nob_Cmd cmd = {0};
|
|
|
|
- Nob_Procs procs = {0};
|
|
|
|
-
|
|
|
|
- cmd.count = 0;
|
|
|
|
- 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");
|
|
|
|
- if (!nob_cmd_run_sync(cmd)) nob_return_defer(false);
|
|
|
|
|
|
+ Cmd cmd = {0};
|
|
|
|
+ Procs procs = {0};
|
|
|
|
+
|
|
|
|
+ cmd_append(&cmd, MAYBE_PREFIXED("windres"));
|
|
|
|
+ cmd_append(&cmd, "./src/musializer.rc");
|
|
|
|
+ cmd_append(&cmd, "-O", "coff");
|
|
|
|
+ cmd_append(&cmd, "-o", "./build/musializer.res");
|
|
|
|
+ if (!cmd_run(&cmd)) return_defer(false);
|
|
|
|
+
|
|
#ifdef MUSIALIZER_HOTRELOAD
|
|
#ifdef MUSIALIZER_HOTRELOAD
|
|
- procs.count = 0;
|
|
|
|
- cmd.count = 0;
|
|
|
|
- nob_cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
- nob_cmd_append(&cmd, "-mwindows", "-Wall", "-Wextra", "-ggdb");
|
|
|
|
- nob_cmd_append(&cmd, "-I.");
|
|
|
|
- nob_cmd_append(&cmd, "-I"RAYLIB_SRC_FOLDER);
|
|
|
|
- nob_cmd_append(&cmd, "-fPIC", "-shared");
|
|
|
|
- nob_cmd_append(&cmd, "-static-libgcc");
|
|
|
|
- nob_cmd_append(&cmd, "-o", "./build/libplug.dll");
|
|
|
|
- nob_cmd_append(&cmd,
|
|
|
|
- "./src/plug.c",
|
|
|
|
- "./src/ffmpeg_windows.c",
|
|
|
|
- "./thirdparty/tinyfiledialogs.c");
|
|
|
|
- nob_cmd_append(&cmd,
|
|
|
|
- "-L./build",
|
|
|
|
- "-l:raylib.dll");
|
|
|
|
- nob_cmd_append(&cmd, "-lwinmm", "-lgdi32", "-lole32");
|
|
|
|
- nob_da_append(&procs, nob_cmd_run_async(cmd));
|
|
|
|
-
|
|
|
|
- cmd.count = 0;
|
|
|
|
- nob_cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
- nob_cmd_append(&cmd, "-mwindows", "-Wall", "-Wextra", "-ggdb");
|
|
|
|
- nob_cmd_append(&cmd, "-I.");
|
|
|
|
- nob_cmd_append(&cmd, "-I"RAYLIB_SRC_FOLDER);
|
|
|
|
- nob_cmd_append(&cmd, "-o", "./build/musializer");
|
|
|
|
- nob_cmd_append(&cmd,
|
|
|
|
- "./src/musializer.c",
|
|
|
|
- "./src/hotreload_windows.c");
|
|
|
|
- nob_cmd_append(&cmd,
|
|
|
|
- "-Wl,-rpath=./build/",
|
|
|
|
- "-Wl,-rpath=./",
|
|
|
|
- nob_temp_sprintf("-Wl,-rpath=./build/raylib/%s", MUSIALIZER_TARGET_NAME),
|
|
|
|
- // NOTE: just in case somebody wants to run musializer from within the ./build/ folder
|
|
|
|
- nob_temp_sprintf("-Wl,-rpath=./raylib/%s", MUSIALIZER_TARGET_NAME));
|
|
|
|
- nob_cmd_append(&cmd,
|
|
|
|
- "-L./build",
|
|
|
|
- "-l:raylib.dll");
|
|
|
|
- nob_cmd_append(&cmd, "-lwinmm", "-lgdi32");
|
|
|
|
- nob_da_append(&procs, nob_cmd_run_async(cmd));
|
|
|
|
- if (!nob_procs_wait(procs)) nob_return_defer(false);
|
|
|
|
|
|
+ cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
+ cmd_append(&cmd, "-mwindows", "-Wall", "-Wextra", "-ggdb");
|
|
|
|
+ cmd_append(&cmd, "-I.");
|
|
|
|
+ cmd_append(&cmd, "-I"RAYLIB_SRC_FOLDER);
|
|
|
|
+ cmd_append(&cmd, "-fPIC", "-shared");
|
|
|
|
+ cmd_append(&cmd, "-static-libgcc");
|
|
|
|
+ cmd_append(&cmd, "-o", "./build/libplug.dll");
|
|
|
|
+ cmd_append(&cmd,
|
|
|
|
+ "./src/plug.c",
|
|
|
|
+ "./src/ffmpeg_windows.c",
|
|
|
|
+ "./thirdparty/tinyfiledialogs.c");
|
|
|
|
+ cmd_append(&cmd,
|
|
|
|
+ "-L./build",
|
|
|
|
+ "-l:raylib.dll");
|
|
|
|
+ cmd_append(&cmd, "-lwinmm", "-lgdi32", "-lole32");
|
|
|
|
+ if (!cmd_run(&cmd, .async = &procs)) return_defer(false);
|
|
|
|
+
|
|
|
|
+ cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
+ cmd_append(&cmd, "-mwindows", "-Wall", "-Wextra", "-ggdb");
|
|
|
|
+ cmd_append(&cmd, "-I.");
|
|
|
|
+ cmd_append(&cmd, "-I"RAYLIB_SRC_FOLDER);
|
|
|
|
+ cmd_append(&cmd, "-o", "./build/musializer");
|
|
|
|
+ cmd_append(&cmd,
|
|
|
|
+ "./src/musializer.c",
|
|
|
|
+ "./src/hotreload_windows.c");
|
|
|
|
+ cmd_append(&cmd,
|
|
|
|
+ "-Wl,-rpath=./build/",
|
|
|
|
+ "-Wl,-rpath=./",
|
|
|
|
+ temp_sprintf("-Wl,-rpath=./build/raylib/%s", MUSIALIZER_TARGET_NAME),
|
|
|
|
+ // NOTE: just in case somebody wants to run musializer from within the ./build/ folder
|
|
|
|
+ temp_sprintf("-Wl,-rpath=./raylib/%s", MUSIALIZER_TARGET_NAME));
|
|
|
|
+ cmd_append(&cmd,
|
|
|
|
+ "-L./build",
|
|
|
|
+ "-l:raylib.dll");
|
|
|
|
+ cmd_append(&cmd, "-lwinmm", "-lgdi32");
|
|
|
|
+ if (!cmd_run(&cmd, .async = &procs)) return_defer(false);
|
|
|
|
+
|
|
|
|
+ if (!procs_flush(&procs)) return_defer(false);
|
|
#else
|
|
#else
|
|
- cmd.count = 0;
|
|
|
|
- nob_cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
- nob_cmd_append(&cmd, "-mwindows", "-Wall", "-Wextra", "-ggdb");
|
|
|
|
- nob_cmd_append(&cmd, "-I.");
|
|
|
|
- nob_cmd_append(&cmd, "-I"RAYLIB_SRC_FOLDER);
|
|
|
|
- nob_cmd_append(&cmd, "-o", "./build/musializer");
|
|
|
|
- nob_cmd_append(&cmd,
|
|
|
|
- "./src/plug.c",
|
|
|
|
- "./src/ffmpeg_windows.c",
|
|
|
|
- "./src/musializer.c",
|
|
|
|
- "./thirdparty/tinyfiledialogs.c",
|
|
|
|
- "./build/musializer.res"
|
|
|
|
- );
|
|
|
|
- nob_cmd_append(&cmd,
|
|
|
|
- nob_temp_sprintf("-L./build/raylib/%s", MUSIALIZER_TARGET_NAME),
|
|
|
|
- "-l:libraylib.a");
|
|
|
|
- nob_cmd_append(&cmd, "-lwinmm", "-lgdi32", "-lole32");
|
|
|
|
- nob_cmd_append(&cmd, "-static");
|
|
|
|
- if (!nob_cmd_run_sync(cmd)) nob_return_defer(false);
|
|
|
|
|
|
+ cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
+ cmd_append(&cmd, "-mwindows", "-Wall", "-Wextra", "-ggdb");
|
|
|
|
+ cmd_append(&cmd, "-I.");
|
|
|
|
+ cmd_append(&cmd, "-I"RAYLIB_SRC_FOLDER);
|
|
|
|
+ cmd_append(&cmd, "-o", "./build/musializer");
|
|
|
|
+ cmd_append(&cmd,
|
|
|
|
+ "./src/plug.c",
|
|
|
|
+ "./src/ffmpeg_windows.c",
|
|
|
|
+ "./src/musializer.c",
|
|
|
|
+ "./thirdparty/tinyfiledialogs.c",
|
|
|
|
+ "./build/musializer.res"
|
|
|
|
+ );
|
|
|
|
+ cmd_append(&cmd,
|
|
|
|
+ temp_sprintf("-L./build/raylib/%s", MUSIALIZER_TARGET_NAME),
|
|
|
|
+ "-l:libraylib.a");
|
|
|
|
+ cmd_append(&cmd, "-lwinmm", "-lgdi32", "-lole32");
|
|
|
|
+ cmd_append(&cmd, "-static");
|
|
|
|
+ if (!cmd_run(&cmd)) return_defer(false);
|
|
#endif // MUSIALIZER_HOTRELOAD
|
|
#endif // MUSIALIZER_HOTRELOAD
|
|
|
|
|
|
defer:
|
|
defer:
|
|
- nob_cmd_free(cmd);
|
|
|
|
- nob_da_free(procs);
|
|
|
|
|
|
+ cmd_free(cmd);
|
|
|
|
+ da_free(procs);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
bool build_raylib()
|
|
bool build_raylib()
|
|
{
|
|
{
|
|
bool result = true;
|
|
bool result = true;
|
|
- Nob_Cmd cmd = {0};
|
|
|
|
- Nob_File_Paths object_files = {0};
|
|
|
|
|
|
+ Cmd cmd = {0};
|
|
|
|
+ File_Paths object_files = {0};
|
|
|
|
|
|
- if (!nob_mkdir_if_not_exists("./build/raylib")) {
|
|
|
|
- nob_return_defer(false);
|
|
|
|
|
|
+ if (!mkdir_if_not_exists("./build/raylib")) {
|
|
|
|
+ return_defer(false);
|
|
}
|
|
}
|
|
|
|
|
|
- Nob_Procs procs = {0};
|
|
|
|
|
|
+ Procs procs = {0};
|
|
|
|
|
|
- const char *build_path = nob_temp_sprintf("./build/raylib/%s", MUSIALIZER_TARGET_NAME);
|
|
|
|
|
|
+ const char *build_path = temp_sprintf("./build/raylib/%s", MUSIALIZER_TARGET_NAME);
|
|
|
|
|
|
- if (!nob_mkdir_if_not_exists(build_path)) {
|
|
|
|
- nob_return_defer(false);
|
|
|
|
|
|
+ if (!mkdir_if_not_exists(build_path)) {
|
|
|
|
+ return_defer(false);
|
|
}
|
|
}
|
|
|
|
|
|
- for (size_t i = 0; i < NOB_ARRAY_LEN(raylib_modules); ++i) {
|
|
|
|
- const char *input_path = nob_temp_sprintf(RAYLIB_SRC_FOLDER"%s.c", raylib_modules[i]);
|
|
|
|
- const char *output_path = nob_temp_sprintf("%s/%s.o", build_path, raylib_modules[i]);
|
|
|
|
- output_path = nob_temp_sprintf("%s/%s.o", build_path, raylib_modules[i]);
|
|
|
|
-
|
|
|
|
- nob_da_append(&object_files, output_path);
|
|
|
|
-
|
|
|
|
- if (nob_needs_rebuild(output_path, &input_path, 1)) {
|
|
|
|
- cmd.count = 0;
|
|
|
|
- nob_cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
- nob_cmd_append(&cmd, "-ggdb", "-DPLATFORM_DESKTOP", "-fPIC", "-DSUPPORT_FILEFORMAT_FLAC=1");
|
|
|
|
- nob_cmd_append(&cmd, "-DPLATFORM_DESKTOP");
|
|
|
|
- nob_cmd_append(&cmd, "-fPIC");
|
|
|
|
- nob_cmd_append(&cmd, "-I"RAYLIB_SRC_FOLDER"external/glfw/include");
|
|
|
|
- nob_cmd_append(&cmd, "-c", input_path);
|
|
|
|
- nob_cmd_append(&cmd, "-o", output_path);
|
|
|
|
-
|
|
|
|
- Nob_Proc proc = nob_cmd_run_async(cmd);
|
|
|
|
- nob_da_append(&procs, proc);
|
|
|
|
|
|
+ for (size_t i = 0; i < ARRAY_LEN(raylib_modules); ++i) {
|
|
|
|
+ const char *input_path = temp_sprintf(RAYLIB_SRC_FOLDER"%s.c", raylib_modules[i]);
|
|
|
|
+ const char *output_path = temp_sprintf("%s/%s.o", build_path, raylib_modules[i]);
|
|
|
|
+ output_path = temp_sprintf("%s/%s.o", build_path, raylib_modules[i]);
|
|
|
|
+
|
|
|
|
+ da_append(&object_files, output_path);
|
|
|
|
+
|
|
|
|
+ if (needs_rebuild(output_path, &input_path, 1)) {
|
|
|
|
+ cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
+ cmd_append(&cmd, "-ggdb", "-DPLATFORM_DESKTOP", "-fPIC", "-DSUPPORT_FILEFORMAT_FLAC=1");
|
|
|
|
+ cmd_append(&cmd, "-DPLATFORM_DESKTOP");
|
|
|
|
+ cmd_append(&cmd, "-fPIC");
|
|
|
|
+ cmd_append(&cmd, "-I"RAYLIB_SRC_FOLDER"external/glfw/include");
|
|
|
|
+ cmd_append(&cmd, "-c", input_path);
|
|
|
|
+ cmd_append(&cmd, "-o", output_path);
|
|
|
|
+
|
|
|
|
+ if (!cmd_run(&cmd, .async = &procs)) return_defer(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- cmd.count = 0;
|
|
|
|
|
|
|
|
- if (!nob_procs_wait(procs)) nob_return_defer(false);
|
|
|
|
|
|
+ if (!procs_flush(&procs)) return_defer(false);
|
|
|
|
|
|
#ifndef MUSIALIZER_HOTRELOAD
|
|
#ifndef MUSIALIZER_HOTRELOAD
|
|
- 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, 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);
|
|
|
|
|
|
+ const char *libraylib_path = temp_sprintf("%s/libraylib.a", build_path);
|
|
|
|
+
|
|
|
|
+ if (needs_rebuild(libraylib_path, object_files.items, object_files.count)) {
|
|
|
|
+ cmd_append(&cmd, MAYBE_PREFIXED("ar"));
|
|
|
|
+ cmd_append(&cmd, "-crs", libraylib_path);
|
|
|
|
+ for (size_t i = 0; i < ARRAY_LEN(raylib_modules); ++i) {
|
|
|
|
+ const char *input_path = temp_sprintf("%s/%s.o", build_path, raylib_modules[i]);
|
|
|
|
+ cmd_append(&cmd, input_path);
|
|
}
|
|
}
|
|
- if (!nob_cmd_run_sync(cmd)) nob_return_defer(false);
|
|
|
|
|
|
+ if (!cmd_run(&cmd)) return_defer(false);
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
// it cannot load the raylib dll if it not in the same folder as the executable
|
|
// it cannot load the raylib dll if it not in the same folder as the executable
|
|
const char *libraylib_path = "./build/raylib.dll";
|
|
const char *libraylib_path = "./build/raylib.dll";
|
|
|
|
|
|
- if (nob_needs_rebuild(libraylib_path, object_files.items, object_files.count)) {
|
|
|
|
- nob_cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
- nob_cmd_append(&cmd, "-shared");
|
|
|
|
- nob_cmd_append(&cmd, "-o", 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);
|
|
|
|
|
|
+ if (needs_rebuild(libraylib_path, object_files.items, object_files.count)) {
|
|
|
|
+ cmd_append(&cmd, "x86_64-w64-mingw32-gcc");
|
|
|
|
+ cmd_append(&cmd, "-shared");
|
|
|
|
+ cmd_append(&cmd, "-o", libraylib_path);
|
|
|
|
+ for (size_t i = 0; i < ARRAY_LEN(raylib_modules); ++i) {
|
|
|
|
+ const char *input_path = temp_sprintf("%s/%s.o", build_path, raylib_modules[i]);
|
|
|
|
+ cmd_append(&cmd, input_path);
|
|
}
|
|
}
|
|
- nob_cmd_append(&cmd, "-lwinmm", "-lgdi32");
|
|
|
|
- if (!nob_cmd_run_sync(cmd)) nob_return_defer(false);
|
|
|
|
|
|
+ cmd_append(&cmd, "-lwinmm", "-lgdi32");
|
|
|
|
+ if (!cmd_run(&cmd)) return_defer(false);
|
|
}
|
|
}
|
|
#endif // MUSIALIZER_HOTRELOAD
|
|
#endif // MUSIALIZER_HOTRELOAD
|
|
|
|
|
|
defer:
|
|
defer:
|
|
- nob_cmd_free(cmd);
|
|
|
|
- nob_da_free(object_files);
|
|
|
|
|
|
+ cmd_free(cmd);
|
|
|
|
+ da_free(object_files);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
bool build_dist(void)
|
|
bool build_dist(void)
|
|
{
|
|
{
|
|
#ifdef MUSIALIZER_HOTRELOAD
|
|
#ifdef MUSIALIZER_HOTRELOAD
|
|
- nob_log(NOB_ERROR, "We do not ship with hotreload enabled");
|
|
|
|
|
|
+ nob_log(ERROR, "We do not ship with hotreload enabled");
|
|
return false;
|
|
return false;
|
|
#else
|
|
#else
|
|
- if (!nob_mkdir_if_not_exists("./musializer-win64-mingw/")) return false;
|
|
|
|
- if (!nob_copy_file("./build/musializer.exe", "./musializer-win64-mingw/musializer.exe")) return false;
|
|
|
|
- if (!nob_copy_directory_recursively("./resources/", "./musializer-win64-mingw/resources/")) return false;
|
|
|
|
- if (!nob_copy_file("musializer-logged.bat", "./musializer-win64-mingw/musializer-logged.bat")) return false;
|
|
|
|
|
|
+ if (!mkdir_if_not_exists("./musializer-win64-mingw/")) return false;
|
|
|
|
+ if (!copy_file("./build/musializer.exe", "./musializer-win64-mingw/musializer.exe")) return false;
|
|
|
|
+ if (!copy_directory_recursively("./resources/", "./musializer-win64-mingw/resources/")) return false;
|
|
|
|
+ if (!copy_file("musializer-logged.bat", "./musializer-win64-mingw/musializer-logged.bat")) return false;
|
|
// TODO: pack ffmpeg.exe with windows build
|
|
// TODO: pack ffmpeg.exe with windows build
|
|
- //if (!nob_copy_file("ffmpeg.exe", "./musializer-win64-mingw/ffmpeg.exe")) return false;
|
|
|
|
- Nob_Cmd cmd = {0};
|
|
|
|
|
|
+ //if (!copy_file("ffmpeg.exe", "./musializer-win64-mingw/ffmpeg.exe")) return false;
|
|
|
|
+ Cmd cmd = {0};
|
|
const char *dist_path = "./musializer-win64-mingw.zip";
|
|
const char *dist_path = "./musializer-win64-mingw.zip";
|
|
- nob_cmd_append(&cmd, "zip", "-r", dist_path, "./musializer-win64-mingw/");
|
|
|
|
- bool ok = nob_cmd_run_sync(cmd);
|
|
|
|
- nob_cmd_free(cmd);
|
|
|
|
|
|
+ cmd_append(&cmd, "zip", "-r", dist_path, "./musializer-win64-mingw/");
|
|
|
|
+ bool ok = cmd_run(&cmd);
|
|
|
|
+ cmd_free(cmd);
|
|
if (!ok) return false;
|
|
if (!ok) return false;
|
|
- nob_log(NOB_INFO, "Created %s", dist_path);
|
|
|
|
|
|
+ nob_log(INFO, "Created %s", dist_path);
|
|
return true;
|
|
return true;
|
|
#endif // MUSIALIZER_HOTRELOAD
|
|
#endif // MUSIALIZER_HOTRELOAD
|
|
}
|
|
}
|