From 3873a4cf3c3fc6726a3e0a0043562dbde8858fef Mon Sep 17 00:00:00 2001 From: Macoy Madson Date: Wed, 26 Jan 2022 09:18:45 -0500 Subject: [PATCH] Add Raylib Requested here: https://github.com/makuto/cakelisp/issues/8 --- ReadMe.org | 2 ++ src/Raylib.cake | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/Raylib.cake diff --git a/ReadMe.org b/ReadMe.org index 9405d5d..9911d65 100644 --- a/ReadMe.org +++ b/ReadMe.org @@ -109,6 +109,7 @@ Here are the known compatibility results, where blank means untested/unknown: | OpenGL.cake | Yes | No[1] | Yes | | | ProfilerAutoInstrument.cake | Yes | Yes | Yes | Yes | | ProfilerNull.cake | Yes | Yes | Yes | Yes | +| Raylib.cake | Yes | | | | | SDL.cake | Yes | | Yes | | | STB.cake | Yes | Yes | Yes | Yes | | TaskSystem.cake | Yes | | Yes | | @@ -134,6 +135,7 @@ The following modules will automatically download their dependencies if missing: - Ogre.cake - OgreInitialize.cake - OpenGL.cake +- Raylib.cake - SDL.cake - STB.cake - TaskSystem.cake diff --git a/src/Raylib.cake b/src/Raylib.cake new file mode 100644 index 0000000..f9678f5 --- /dev/null +++ b/src/Raylib.cake @@ -0,0 +1,63 @@ +;; Raylib: a game programming library +(add-cakelisp-search-directory "Dependencies/cakelisp/runtime") +(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake") + +(export-and-evaluate + (add-c-search-directory-module "Dependencies/raylib/src") + (c-import "raylib.h")) + +(comptime-cond + ('auto-test + (defun test--raylib (&return int) + (InitWindow 800 450 "raylib [core] example - basic window") + + (while (not (WindowShouldClose)) + (BeginDrawing) + (ClearBackground RAYWHITE) + (DrawText "Congrats! You created your first window!" 190 200 20 LIGHTGRAY) + (EndDrawing)) + + (CloseWindow) + (return 0)))) + +;; +;; Building +;; + +(defun-comptime build-raylib (manager (& ModuleManager) module (* Module) &return bool) + ;; Already built? + ;; We could enhance this by checking for modifications, but that's pretty rare + (when (and (fileExists "cakelisp_cache/RaylibBuild/raylib/libraylib.a")) + (return true)) + + (Log "Raylib: Building via Configure and Make\n") + + (var raylib-output-dir (* (const char)) "cakelisp_cache/RaylibBuild") + (makeDirectory raylib-output-dir) + + (run-process-sequential-or + ("cmake" "../../Dependencies/raylib" :in-directory raylib-output-dir) + (Log "failed at Raylib configure step. This requires a sh/bash-style shell to execute.") + (return false)) + + (run-process-sequential-or + ("make" "--jobs=8" :in-directory raylib-output-dir) + (Log "failed at Raylib make. This tool requires Makefile support.") + (return false)) + + ;; One final to check to ensure everything's good to go + (unless (fileExists "cakelisp_cache/RaylibBuild/raylib/libraylib.a") + (Log + "error: Raylib build sequence completed, but files are not where expected. Is there an issue + with the configuration?\nFile expected:\n\tcakelisp_cache/RaylibBuild/raylib/libraylib.a\n") + (return false)) + (return true)) +(add-compile-time-hook-module pre-build build-raylib) + +(add-static-link-objects "cakelisp_cache/RaylibBuild/raylib/libraylib.a") + +(add-dependency-git-submodule + clone-raylib + "https://github.com/raysan5/raylib.git" + "Dependencies/raylib") +