Browse Source

SDL now built by pre-build hook

* Need to specify platform on most projects now
* Fix unnecessary rebuilds by renaming hook copies in Loader
pitch-detection
Macoy Madson 1 year ago
parent
commit
f2c94e6a7c
  1. 15
      BuildDependencies_Debug.sh
  2. 10
      Build_Debug.sh
  3. 2
      Dependencies/cakelisp
  4. 81
      src/SDL.cake
  5. 20
      test/src/Loader.cake

15
BuildDependencies_Debug.sh

@ -4,14 +4,15 @@ echo "Building Cakelisp..."
cd Dependencies/cakelisp && jam -j4 && cd ../
echo "done!"
# Now built by SDL.cake itself!
# http://wiki.libsdl.org/Installation
echo "Building SDL"
cd SDL
mkdir -p build
cd build
# mkdir -p SDLBuild
../configure --prefix=$(pwd)SDLBuild && make && make install || exit $?
cd ../
# echo "Building SDL"
# cd SDL
# mkdir -p build
# cd build
# # mkdir -p SDLBuild
# ../configure --prefix=$(pwd)SDLBuild && make && make install || exit $?
# cd ../
# See the official script at
# https://raw.githubusercontent.com/OGRECave/ogre-next/master/Scripts/BuildScripts/output/build_ogre_linux_c%2B%2Blatest.sh

10
Build_Debug.sh

@ -1,21 +1,21 @@
#!/bin/sh
echo "\n\nOgre\n\n"
./Dependencies/cakelisp/bin/cakelisp test/src/OgreApp.cake || exit $?
./Dependencies/cakelisp/bin/cakelisp test/src/Config_Linux.cake test/src/OgreApp.cake || exit $?
echo "\n\nSDL Ogre\n\n"
./Dependencies/cakelisp/bin/cakelisp test/src/SDLOgreApp.cake || exit $?
./Dependencies/cakelisp/bin/cakelisp test/src/Config_Linux.cake test/src/SDLOgreApp.cake || exit $?
echo "\n\nAuto Test\n\n"
./Dependencies/cakelisp/bin/cakelisp src/AutoTest.cake src/Math.cake src/SDL.cake src/Tracy.cake || exit $?
./Dependencies/cakelisp/bin/cakelisp test/src/Config_Linux.cake src/AutoTest.cake src/Math.cake src/SDL.cake src/Tracy.cake || exit $?
echo "\n\nVocal Game (hot reload)\n\n"
./Dependencies/cakelisp/bin/cakelisp test/src/Config_Linux.cake test/src/MakeHotReload.cake test/src/VocalGame.cake || exit $?
echo "\n\nLoader\n\n"
./Dependencies/cakelisp/bin/cakelisp test/src/Config_Linux.cake test/src/Loader.cake || exit $?
./Dependencies/cakelisp/bin/cakelisp --verbose-processes --verbose-build-reasons test/src/Config_Linux.cake test/src/Loader.cake || exit $?
echo "\n\nVocal Game (no reload)\n\n"
./Dependencies/cakelisp/bin/cakelisp \
test/src/NoHotReload.cake test/src/VocalGame.cake || exit $?
test/src/Config_Linux.cake test/src/NoHotReload.cake test/src/VocalGame.cake || exit $?
# TESTING

2
Dependencies/cakelisp

@ -1 +1 @@
Subproject commit 3c8825cc7d2ff9353d2e39ce986a994e13762348
Subproject commit e7e6bd2839c56c215495fb3850b6ec168f9f27f1

81
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 "Macros.cake" "BuildTools.cake")
(c-import "stdio.h"
"SDL.h"
@ -86,6 +86,83 @@
;; Building
;;
(defun-comptime build-sdl-on-failure (failure-message (* (const char)))
(Logf "error: SDL build: %s\n
Note that you can also build SDL manually. This can be useful if you are porting to a new platform
and do not want to try to automate it yet.\n
The build step will automatically detect your build, as long as it is installed to
Dependencies/SDL/buildSDLBuild/[include | lib].\n
See http://wiki.libsdl.org/Installation for how to build manually.\n"
failure-message))
(defun-comptime build-sdl (manager (& ModuleManager) module (* Module) &return bool)
(comptime-cond
('Windows
(comptime-error "SDL build needs to be ported to Windows.
See http://wiki.libsdl.org/Installation"))
('Unix
;; Already built?
;; We could enhance this by checking for modifications, but that's pretty rare
(when (and (fileExists "Dependencies/SDL/buildSDLBuild/include/SDL2/SDL.h")
(fileExists "Dependencies/SDL/buildSDLBuild/lib/libSDL2.so"))
(return true))
(Log "SDL: Building via Configure and Make\n")
(var sdl-working-dir (* (const char)) "Dependencies/SDL/build")
(makeDirectory sdl-working-dir)
(var sdl-output-dir (* (const char)) "Dependencies/SDL/buildSDLBuild")
(makeDirectory sdl-output-dir)
(var configure-output-prefix ([] MAX_PATH_LENGTH char) (array 0))
(scope ;; Output must be absolute directory
(var absolute-output-path (* (const char))
(makeAbsolutePath_Allocated null sdl-output-dir))
(unless absolute-output-path
(Logf "error: failed to make SDL output directory '%s'\n" sdl-output-dir)
(return false))
(PrintfBuffer configure-output-prefix "--prefix=%s" absolute-output-path)
(free (type-cast absolute-output-path (* void))))
(run-process-make-arguments configure-command "sh" "../configure" configure-output-prefix
:in-directory sdl-working-dir)
(unless (!= 0 (run-process-wait-for-completion (addr configure-command)))
(build-sdl-on-failure
"failed at SDL configure step. This requires a sh/bash-style shell to execute.")
(return false))
(run-process-make-arguments make-command "make"
:in-directory sdl-working-dir)
(unless (= 0 (run-process-wait-for-completion (addr make-command)))
(build-sdl-on-failure "failed at SDL make. This tool requires Makefile support.")
(return false))
(run-process-make-arguments make-install-command "make" "install"
:in-directory sdl-working-dir)
(unless (= 0 (run-process-wait-for-completion (addr make-install-command)))
(build-sdl-on-failure
"failed at SDL make install. Was there a configuration issue with --prefix?.")
(return false))
;; One final to check to ensure everything's good to go
(unless (and (fileExists "Dependencies/SDL/buildSDLBuild/include/SDL2/SDL.h")
(fileExists "Dependencies/SDL/buildSDLBuild/lib/libSDL2.so"))
(build-sdl-on-failure
"error: SDL build sequence completed, but files are not where expected. Is there an issue
with the configuration?\nFiles are expected in:\n\tDependencies/SDL/buildSDLBuild/include
\n\tDependencies/SDL/buildSDLBuild/lib\n")
(return false)))
(true
(comptime-error "need to define platform, e.g. (comptime-define-symbol 'Unix)")))
(Log "SDL: Successfully built\n")
(return true))
(add-compile-time-hook-module pre-build build-sdl)
;; For now, an easy way to build files which include SDL headers
(defmacro module-use-sdl-build-options ()
(tokenize-push output
@ -110,7 +187,7 @@
(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 "-LDependencies/SDL/buildSDLBuild/lib")
(command-add-string-argument linkCommand "-lSDL2")
(command-add-string-argument linkCommand "-Wl,-rpath,.:../Dependencies/SDL/buildSDLBuild/lib")))

20
test/src/Loader.cake

@ -46,10 +46,10 @@
;;
;; Libraries
;;
(defun-comptime ogre-link-hook (manager (& ModuleManager)
linkCommand (& ProcessCommand)
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
(defun-comptime ogre-link-hook-copy (manager (& ModuleManager)
linkCommand (& ProcessCommand)
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
;; TODO: Expose this option somehow?
(var is-debug-build bool true)
@ -72,12 +72,12 @@
(command-add-string-argument linkCommand "-Wl,-rpath,.:../Dependencies/ogre-next/build/Release/lib")))
(return true))
(add-compile-time-hook pre-link ogre-link-hook)
(add-compile-time-hook pre-link ogre-link-hook-copy)
(defun-comptime sdl-link-hook (manager (& ModuleManager)
linkCommand (& ProcessCommand)
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
(defun-comptime sdl-link-hook-copy (manager (& ModuleManager)
linkCommand (& ProcessCommand)
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
;; TODO: Expose this option somehow?
(var is-debug-build bool true)
@ -96,4 +96,4 @@
(return true))
(add-compile-time-hook pre-link sdl-link-hook)
(add-compile-time-hook pre-link sdl-link-hook-copy)

Loading…
Cancel
Save