GameLib is a collection of libraries for creating applications in Cakelisp.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

99 lines
4.2 KiB

;; Export libraries included? Only if static linked
;; Make sure HotReloading.cake interface can be found by lib
;; TODO: This shouldn't be necessary because the loader can find C++ mangled types for us. I only
;; have to do this here because HotReloadingCodeModifier imports the header with c-linkage on
;; I would need an option to disable c linkage on that file in order to make it work
(set-cakelisp-option use-c-linkage true)
(add-build-config-label "HotLoader")
(set-cakelisp-option executable-output "test/Loader")
;; We only want the shared libraries these use
;; (import "src/Ogre.cake"
;; "src/SDL.cake")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import &comptime-only "Options.cake" "Macros.cake")
;; TODO: Should this happen automatically, because import automatically adds current working dir?
;; Should it add working dir?
(add-c-search-directory module ".")
(import "HotReloading.cake")
(c-import "stdio.h")
(defun main (&return int)
(def-function-signature reload-entry-point-signature (&return bool))
(var hot-reload-entry-point-func reload-entry-point-signature null)
(register-function-pointer (type-cast (addr hot-reload-entry-point-func) (* (* void)))
;; TODO Support name conversion at runtime (conversion requires tokens)
"reloadableEntryPoint")
(unless (do-hot-reload)
(printf "error: failed to load\n")
(hot-reload-clean-up)
(return 1))
(while (hot-reload-entry-point-func)
(unless (do-hot-reload)
(printf "error: failed to hot-reload\n")
(hot-reload-clean-up)
(return 1)))
(hot-reload-clean-up)
(return 0))
;;
;; Libraries
;;
(defun-comptime ogre-link-hook (manager (& ModuleManager)
linkCommand (& ProcessCommand)
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
;; TODO: Expose this option somehow?
(var is-debug-build bool true)
(printf "OgreCore: Adding %s link arguments\n" (? is-debug-build "debug" "release"))
(if is-debug-build
(block
(command-add-string-argument linkCommand "-LDependencies/ogre-next/build/Debug/lib")
(command-add-string-argument linkCommand "-lOgreHlmsPbs_d")
(command-add-string-argument linkCommand "-lOgreHlmsUnlit_d")
(command-add-string-argument linkCommand "-lOgreMain_d")
(command-add-string-argument linkCommand "-lOgreOverlay_d")
(command-add-string-argument linkCommand "-Wl,-rpath,.:../Dependencies/ogre-next/build/Debug/lib"))
(block
(command-add-string-argument linkCommand "-LDependencies/ogre-next/build/Release/lib")
(command-add-string-argument linkCommand "-lOgreHlmsPbs")
(command-add-string-argument linkCommand "-lOgreHlmsUnlit")
(command-add-string-argument linkCommand "-lOgreMain")
(command-add-string-argument linkCommand "-lOgreOverlay")
(command-add-string-argument linkCommand "-Wl,-rpath,.:../Dependencies/ogre-next/build/Release/lib")))
(return true))
(add-compile-time-hook pre-link ogre-link-hook)
(defun-comptime sdl-link-hook (manager (& ModuleManager)
linkCommand (& ProcessCommand)
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
;; TODO: Expose this option somehow?
(var is-debug-build bool true)
(printf "SDL: Adding %s link arguments\n" (? is-debug-build "debug" "release"))
(if is-debug-build
;; TODO: Actually add debug build
(block
(command-add-string-argument linkCommand "-LDependencies/SDL/buildSDLBuild/lib")
(command-add-string-argument linkCommand "-lSDL2")
(command-add-string-argument linkCommand "-Wl,-rpath,.:../Dependencies/SDL/buildSDLBuild/lib"))
(block
(command-add-string-argument linkCommand "-LDependencies/sdl-next/build/Release/lib")
(command-add-string-argument linkCommand "-lSDL2")
(command-add-string-argument linkCommand "-Wl,-rpath,.:../Dependencies/SDL/buildSDLBuild/lib")))
(return true))
(add-compile-time-hook pre-link sdl-link-hook)