From 617c296fe44138016923ff6d520b850bf01104c4 Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 26 Nov 2023 16:17:27 +0300 Subject: [PATCH] More MacOS fixes and stuff --- .gitignore | 2 ++ cbt.c | 21 ++++++++++++++++++--- cbt.h | 1 - 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3c9481a..0bf5858 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ cbt_impl.c state add-impl.py raylib +libraylib.* +extras diff --git a/cbt.c b/cbt.c index 143cb50..65190de 100644 --- a/cbt.c +++ b/cbt.c @@ -2,6 +2,17 @@ #define CBT_IMPLEMENTATION #include "cbt.h" +bool compile_file(const char *input, const char *output) { + return cbt_proc_wait(cbt_proc_new( + CBT_PROC_AUTO, cbt_cc, input, "-o", output, "libraylib.a", "-lm", + "-lpthread", +#ifdef __APPLE__ + "-framework", "CoreVideo", "-framework", "IOKit", "-framework", + "Cocoa", "-framework", "GLUT", "-framework", "OpenGL", +#endif + "-I./raylib/src")) == 0; +} + int main(int argc, char **argv) { CBT_INIT(argc, argv); @@ -15,14 +26,18 @@ int main(int argc, char **argv) { cbt_lib_cflags(&raylib, "-D_GNU_SOURCE", "-DPLATFORM_DESKTOP", "-DGRAPHICS_API_OPENGL_33", "-Wno-missing-braces", "-Werror=pointer-arith", "-fno-strict-aliasing", "-std=c99", - "-fPIC", "-O1", "-Werror=implicit-function-declaration", +#ifndef __APPLE__ + "-fPIC", +#else + "-x", "objective-c", +#endif + "-O1", "-Werror=implicit-function-declaration", "-I./raylib/src", "-I./raylib/src/external/glfw/include", "-I./raylib/src/external/glfw/deps/mingw"); cbt_lib_build(raylib, NULL); cbt_lib_free(raylib); - cbt_proc_wait(cbt_proc_new(CBT_PROC_AUTO, cbt_cc, "clock.c", "-o", "clock", - "libraylib.a", "-lm", "-lpthread")); + CBT_FAIL(compile_file("extras/clock.c", "extras/clock") == false); cbt_cleanup(); return 0; diff --git a/cbt.h b/cbt.h index cfbf984..a6de3a4 100644 --- a/cbt.h +++ b/cbt.h @@ -767,7 +767,6 @@ bool _cbt_binary_build(struct cbt_binary bin, const char *compiler, ...); void cbt_binary_free(struct cbt_binary bin); #undef CBT_TODO -#undef CBT_FAIL //-*- end #endif