diff --git a/Build_Debug.sh b/Build_Debug.sh index d9023a7..4139c0b 100755 --- a/Build_Debug.sh +++ b/Build_Debug.sh @@ -1,8 +1,6 @@ #!/bin/sh -./Dependencies/cakelisp/bin/cakelisp src/OgreCore.cake \ - && jam -j4 -sDEBUG_BUILD=true libGameLib.a || exit $? +# ./Dependencies/cakelisp/bin/cakelisp src/OgreCore.cake || exit $? # TODO: Figure out how to remove clean by teaching jam about libGameLib.a (dyn link instead?) -./Dependencies/cakelisp/bin/cakelisp test/OgreApp.cake && cd test \ - && jam clean && jam -j4 -sDEBUG_BUILD=true || exit $? +./Dependencies/cakelisp/bin/cakelisp test/OgreApp.cake diff --git a/Dependencies/cakelisp b/Dependencies/cakelisp index 5e094a4..9f38739 160000 --- a/Dependencies/cakelisp +++ b/Dependencies/cakelisp @@ -1 +1 @@ -Subproject commit 5e094a4b270f3ed9572de6a06a671bffc48d41e2 +Subproject commit 9f387399030f946bd75a8f92c5ec7295b8345b70 diff --git a/Jamrules b/Jamrules index 26834aa..c627b43 100644 --- a/Jamrules +++ b/Jamrules @@ -54,7 +54,8 @@ if $(DEBUG_BUILD) Dependencies/ogre-next/build/Debug/include # Ogre overlay Dependencies/ogre-next/Components/Overlay/include ; - OGRE_LINKLIBS = -lOgreHlmsPbs_d + OGRE_LINKLIBS = + -lOgreHlmsPbs_d -lOgreHlmsUnlit_d -lOgreMain_d # Ogre 2D overlays diff --git a/src/OgreCore.cake b/src/OgreCore.cake index 305e35d..97dd6a1 100644 --- a/src/OgreCore.cake +++ b/src/OgreCore.cake @@ -153,3 +153,69 @@ ;; (getNextArgument tokens current-index end-invocation-index)) (incr current-index)) (return true)) + +;; +;; Building +;; + +;; TODO: Relative vs. absolute paths +(import &comptime-only "../Dependencies/cakelisp/runtime/Macros.cake") +(add-cpp-build-dependency "OgreInitialize.cpp") + +(set-module-option build-time-compiler "/usr/bin/clang++") +;; Include cakelisp source for DynamicLoader.hpp +(set-module-option build-time-compile-arguments + "-std=c++11" "-Wall" "-Wextra" "-Wno-unused-parameter" + "-g" "-c" 'source-input "-o" 'object-output "-fPIC" + ;; Ogre options + "-DOGRE_DEBUG_MODE=1" + "-IDependencies/ogre-next/OgreMain/include" + "-IDependencies/ogre-next/Components/Hlms/Common/include" + "-IDependencies/ogre-next/Components/Hlms/Pbs/include" + "-IDependencies/ogre-next/Components/Hlms/Unlit/include" + "-IDependencies/ogre-next/build/Debug/include" + "-IDependencies/ogre-next/Components/Overlay/include") + +;; (defun-comptime ogre-pre-build-hook () +;; (unless (fileExists "Dependencies/ogre-next/build/Debug/lib") +;; (printf "error: Ogre is not built yet. Please run ./BuildDependencies_Debug.sh\n") +;; (return false)) +;; (return true)) +;; (add-compile-time-hook-module pre-build ogre-pre-build-hook) + +(defmacro command-add-string-argument () + (destructure-arguments new-argument-index) + (quick-token-at new-argument new-argument-index) + (tokenize-push output (on-call (field linkCommand arguments) push_back + (array ProcessCommandArgumentType_String + (token-splice (addr new-argument))))) + (return true)) + +(defun-comptime ogre-link-hook (manager (& ModuleManager) + linkCommand (& ProcessCommand) + linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int + &return bool) + ;; TODO: Expose this option somehow? + (var debug bool true) + + (printf "OgreCore: Adding %s link arguments\n" (? debug "debug" "release")) + + (if debug + (block + (command-add-string-argument "-LDependencies/ogre-next/build/Debug/lib") + (command-add-string-argument "-lOgreHlmsPbs_d") + (command-add-string-argument "-lOgreHlmsUnlit_d") + (command-add-string-argument "-lOgreMain_d") + (command-add-string-argument "-lOgreOverlay_d") + (command-add-string-argument "-Wl,-rpath,.:../Dependencies/ogre-next/build/Debug/lib")) + (block + (command-add-string-argument "-LDependencies/ogre-next/build/Release/lib") + (command-add-string-argument "-lOgreHlmsPbs") + (command-add-string-argument "-lOgreHlmsUnlit") + (command-add-string-argument "-lOgreMain") + (command-add-string-argument "-lOgreOverlay") + (command-add-string-argument "-Wl,-rpath,.:../Dependencies/ogre-next/build/Release/lib"))) + + (return true)) +(add-compile-time-hook pre-link ogre-link-hook) + diff --git a/test/OgreApp.cake b/test/OgreApp.cake index f5bbddb..ec15dc9 100644 --- a/test/OgreApp.cake +++ b/test/OgreApp.cake @@ -26,3 +26,6 @@ (when exit-reason (printf "Exit reason: %s\n" exit-reason)) (return 0)) + +;; We need to place the executable relative to our data folders and such +(set-cakelisp-option executable-output "test/ogreApp")