Browse Source

Cakelisp search dirs, NoHotReload fix

* Update Cakelisp for add-cakelisp-search-directory
* NoHotReload now works thanks to a custom generator
pitch-detection
Macoy Madson 2 years ago
parent
commit
f661d22065
  1. 4
      .gitignore
  2. 2
      Dependencies/cakelisp
  3. 1
      src/AutoTest.cake
  4. 3
      src/Macros.cake
  5. 4
      src/Ogre.cake
  6. 2
      src/SDL.cake
  7. 1
      src/Tracy.cake
  8. 7
      test/src/Loader.cake
  9. 41
      test/src/NoHotReload.cake
  10. 9
      test/src/Options.cake
  11. 8
      test/src/VocalGame.cake

4
.gitignore

@ -51,4 +51,6 @@ Dependencies/SDL/
test/100000000PixelShader_ps.glsl
test/100000000VertexShader_vs.glsl
test/SDLOgreApp
test/out.dat
test/out.dat
test/converted.dat
test/Loader

2
Dependencies/cakelisp

@ -1 +1 @@
Subproject commit e6f5f033061e8411a5e3e62f838d168ce704d994
Subproject commit 62dff2b9c27ac285075a0e1fcb7832c960b6b7bb

1
src/AutoTest.cake

@ -2,6 +2,7 @@
;; It will call any function starting with "test--" and report the results
;; e.g. (defun test--SDL (&return int) (return -1)) will show up as a failure
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import &comptime-only "Macros.cake")
;; This is completely replaced by find-add-tests

3
src/Macros.cake

@ -1,3 +0,0 @@
(skip-build)
(import &comptime-only "../Dependencies/cakelisp/runtime/Macros.cake")

4
src/Ogre.cake

@ -1,4 +1,5 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import
"OgreInitialize.cake"
@ -110,9 +111,6 @@
;; Building
;;
;; TODO: Relative vs. absolute paths
(import &comptime-only "../Dependencies/cakelisp/runtime/Macros.cake")
(add-build-options "-DOGRE_DEBUG_MODE=1")
(add-c-search-directory module
"Dependencies/ogre-next/OgreMain/include"

2
src/SDL.cake

@ -1,7 +1,7 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import &comptime-only "Macros.cake")
(import &comptime-only "Dependencies/cakelisp/runtime/Macros.cake")
(c-import "stdio.h"
"SDL.h"

1
src/Tracy.cake

@ -1,4 +1,5 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import &comptime-only "Macros.cake")

7
test/src/Loader.cake

@ -1,7 +1,6 @@
;; Export libraries included?
;; Export libraries included? Only if static linked
;; (set-cakelisp-option use-c-linkage true)
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(set-cakelisp-option executable-output "test/Loader")
;; We only want the shared libraries these use
@ -9,7 +8,7 @@
;; "src/SDL.cake")
(import &comptime-only "Dependencies/cakelisp/runtime/Macros.cake")
(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 ".")
@ -17,7 +16,7 @@
;; So HotReloading.cake can find DynamicLoader.hpp
(add-c-search-directory global "Dependencies/cakelisp/src")
(import "Dependencies/cakelisp/runtime/HotReloading.cake")
(import "HotReloading.cake")
(c-import "stdio.h")
(defun main (&return int)

41
test/src/NoHotReload.cake

@ -1,3 +1,44 @@
(declare-extern-function
reloadableEntryPoint bool)
(defun main (&return int)
(reloadableEntryPoint)
(return 0))
;; TODO: This should parse the function signature properly, but it doesn't understand arguments
;; Given
;; (declare-extern-function my-func (i int &return bool))
;; Output
;; bool myFunc(int i);
;; This is useful for forward declarations of functions or declaring functions linked dynamically
(defgenerator declare-extern-function ()
(destructure-arguments name-index signature-index)
(quick-token-at name-token name-index)
(quick-token-at signature-token signature-index)
(var return-type-start int -1)
(var arguments (<> std::vector FunctionArgumentTokens))
(unless (parseFunctionSignature tokens signature-index arguments return-type-start)
(return false))
(var end-signature-index int (FindCloseParenTokenIndex tokens signature-index))
(unless (outputFunctionReturnType tokens output return-type-start startTokenIndex
end-signature-index
true ;; Output to source
false) ;; Output to header
(return false))
(addStringOutput (path output . source) (field name-token contents)
StringOutMod_ConvertFunctionName
(addr name-token))
(addLangTokenOutput (field output source) StringOutMod_OpenParen (addr signature-token))
(unless (outputFunctionArguments tokens output arguments
true ;; Output to source
false) ;; Output to header
(return false))
(addLangTokenOutput (field output source) StringOutMod_CloseParen (addr signature-token))
(addLangTokenOutput (field output source) StringOutMod_EndStatement (addr signature-token))
(return true))

9
test/src/Options.cake

@ -0,0 +1,9 @@
(skip-build)
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "src")
(add-c-search-directory global "src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(add-c-search-directory global "Dependencies/cakelisp/runtime")

8
test/src/VocalGame.cake

@ -1,9 +1,8 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(set-cakelisp-option executable-output "test/VocalGame")
(import "src/Ogre.cake"
"src/SDL.cake"
&comptime-only "Dependencies/cakelisp/runtime/Macros.cake")
(import &comptime-only "Options.cake" "Macros.cake")
(import "Ogre.cake" "SDL.cake")
;; TODO: Should this happen automatically, because import automatically adds current working dir?
;; Should it add working dir?
(add-c-search-directory module ".")
@ -321,6 +320,7 @@
;; Audio needs to be re-initialized due to reload removing callbacks
;; TODO: Some way to avoid the big wait time required when initializing audio would be good
;; It actually seems pretty quick now
(when enable-audio
(unless (initialize-audio (addr g-output-device) (addr g-input-device)
(addr g-output-device-spec) (addr g-input-device-spec))

Loading…
Cancel
Save