Browse Source

Update cakelisp for stable comptime builds

* Building each app separately was causing rebuilds of comptime
definitions, which I have now fixed in Cakelisp
* Moved some SDL stuff around and added a initialize function which
should support using SDL for drawing
master
Macoy Madson 2 months ago
parent
commit
c4a60112e7
7 changed files with 46 additions and 164 deletions
  1. +19
    -5
      Build_Debug.sh
  2. +1
    -1
      Dependencies/cakelisp
  3. +0
    -3
      Jamfile
  4. +0
    -146
      Jamrules
  5. +2
    -0
      ReadMe.org
  6. +0
    -3
      src/Jamfile
  7. +24
    -6
      src/SDL.cake

+ 19
- 5
Build_Debug.sh View File

@ -4,9 +4,23 @@
# ./Dependencies/cakelisp/bin/cakelisp src/OgreCore.cake || exit $?
# ./Dependencies/cakelisp/bin/cakelisp --verbose-processes test/OgreApp.cake
# ./Dependencies/cakelisp/bin/cakelisp --verbose-processes src/SDL.cake
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects test/SDLOgreApp.cake \
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects test/SDLOgreApp.cake
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects src/AutoTest.cake src/SDL.cake src/Tracy.cake
echo "\n\nOgre\n\n"
./Dependencies/cakelisp/bin/cakelisp --verbose-processes test/OgreApp.cake
echo "\n\nSDL Ogre\n\n"
./Dependencies/cakelisp/bin/cakelisp --verbose-processes test/SDLOgreApp.cake
echo "\n\nAuto Test\n\n"
./Dependencies/cakelisp/bin/cakelisp --verbose-processes src/AutoTest.cake src/SDL.cake src/Tracy.cake
# echo "\n\nOgre\n\n"
# ../cakelisp/bin/cakelisp --verbose-processes test/OgreApp.cake
# echo "\n\nSDL Ogre\n\n"
# ../cakelisp/bin/cakelisp --verbose-processes test/SDLOgreApp.cake
# echo "\n\nAuto Test\n\n"
# ../cakelisp/bin/cakelisp --verbose-processes src/AutoTest.cake src/SDL.cake src/Tracy.cake
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects test/SDLOgreApp.cake
# && echo "\n\nRUNTIME\n" && cd test && ./SDLOgreApp
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects src/Tracy.cake
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects src/AutoTest.cake src/Tracy.cake
./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects src/AutoTest.cake src/SDL.cake src/Tracy.cake

+ 1
- 1
Dependencies/cakelisp

@ -1 +1 @@
Subproject commit 1283eff806c1dca16472fe6d931e66da6c2fc522
Subproject commit cd480d3522ad4a4accf55c02ec6e817807979cc8

+ 0
- 3
Jamfile View File

@ -1,3 +0,0 @@
SubDir . ;
SubInclude . src ;

+ 0
- 146
Jamrules View File

@ -1,146 +0,0 @@
##
## Compilation
##
C++ = clang++ ;
LINK = clang++ ;
# C++ = g++ ;
# LINK = g++ ;
if $(UNIX) { SUFSHR = .so ; }
else if $(NT) { SUFSHR = .dll ; }
if $(CROSS_COMPILE_WINDOWS)
{
C++ = x86_64-w64-mingw32-g++ ;
LINK = x86_64-w64-mingw32-g++ ;
AR = x86_64-w64-mingw32-ar ;
SUFEXE = .exe ;
OS_DEPENDENT_C++FLAGS = -DWINDOWS ;
OS_DEPENDENT_LINKLIBS = ;
OS_DEPENDENT_LINKFLAGS = --export-all-symbols ;
MINGW_LIB_PATH = /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32 ;
OS_DEPENDENT_DLLS =
$(MINGW_LIB_PATH)/libgcc_s_seh-1.dll
$(MINGW_LIB_PATH)/libstdc++-6.dll ;
}
else if $(UNIX)
{
OS_DEPENDENT_C++FLAGS = -DUNIX ;
# For dynamic loading: ldl loads, export-dynamic lets the loaded code resolve its symbols to the loader's code
OS_DEPENDENT_LINKLIBS = -ldl ;
OS_DEPENDENT_LINKFLAGS = --export-dynamic ;
OS_DEPENDENT_DLLS = ;
}
else if $(NT)
{
OS_DEPENDENT_C++FLAGS = -DWINDOWS ;
# TODO: Windows support
OS_DEPENDENT_LINKLIBS = ;
OS_DEPENDENT_LINKFLAGS = ;
OS_DEPENDENT_DLLS = ;
}
if $(DEBUG_BUILD)
{
OGRE_BUILD_DIR = Dependencies/ogre-next/build/Debug ;
OGRE_C++FLAGS = -DOGRE_DEBUG_MODE=1 ;
OGRE_HDRS = Dependencies/ogre-next/OgreMain/include
Dependencies/ogre-next/Components/Hlms/Common/include
Dependencies/ogre-next/Components/Hlms/Pbs/include
Dependencies/ogre-next/Components/Hlms/Unlit/include
Dependencies/ogre-next/build/Debug/include
# Ogre overlay
Dependencies/ogre-next/Components/Overlay/include ;
OGRE_LINKLIBS =
-lOgreHlmsPbs_d
-lOgreHlmsUnlit_d
-lOgreMain_d
# Ogre 2D overlays
-lOgreOverlay_d ;
}
else
{
OGRE_BUILD_DIR = Dependencies/ogre-next/build/Release ;
OGRE_C++FLAGS = -DOGRE_DEBUG_MODE=0 ;
OGRE_HDRS = Dependencies/ogre-next/OgreMain/include
Dependencies/ogre-next/Components/Hlms/Common/include
Dependencies/ogre-next/Components/Hlms/Pbs/include
Dependencies/ogre-next/Components/Hlms/Unlit/include
Dependencies/ogre-next/build/Release/include
# Ogre overlay
Dependencies/ogre-next/Components/Overlay/include ;
OGRE_LINKLIBS = -lOgreHlmsPbs
-lOgreHlmsUnlit
-lOgreMain
# Ogre 2D overlays
-lOgreOverlay ;
}
HDRS = src
$(OGRE_HDRS) ;
# Arguments used on all projects, regardless of any variables
C++FLAGS = -std=c++11 -Wall -Wextra -Wno-unused-parameter
# Only for profiling, i.e. not release builds
# -DTRACY_ENABLE
-g
# Needed for dynamic linking
-fPIC
$(OGRE_C++FLAGS)
$(OS_DEPENDENT_C++FLAGS)
;
# TODO: Make base hold all this weirdness?
# if $(DEBUG_BUILD)
# {
# SFML_LINKLIBS = -lsfml-audio-d -lsfml-graphics-d -lsfml-window-d -lsfml-system-d ;
# }
# else
# {
# SFML_LINKLIBS = -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system ;
# }
OPTIM = -O0 ;
##
## Linking
##
LINKLIBS =
# Standard (e.g. for Tracy)
-lpthread
# Functions for dynamically loading libraries (UNIX)
$(OS_DEPENDENT_LINKLIBS)
-L$(OGRE_BUILD_DIR)/lib
$(OGRE_LINKLIBS)
;
LINKFLAGS = -g
# -Wl = pass to linker
# --export-dynamic = Export all symbols so dynamically loaded code can resolve their symbols to ours
-Wl,-rpath,.,$(OS_DEPENDENT_LINKFLAGS):$(OGRE_BUILD_DIR)/lib
;
##
## Jam stuff
##
# Fix for unnecessary rebuilding any Jam project
KEEPOBJS = true ; # This doesn't actually fix anything, though it seems like it should
NOARSCAN = true ; # This actually fixes the problem
#AR = ar rUu ; # I was thinking maybe the AR command was wrong (always outputting deterministically)
# It doesn't seem like this is the problem though
AR = ar cr ;
# Some helpful Jam commands
# -q : stop on failed target
# -jN : use N cores
# -sVAR=VAL : Set VAR to VAL. Note that setting WINDOWS=false is the same as setting WINDOWS=true,
# frustratingly (as if it's an ifdef not an if x = y
# -dx : print commands being used
# -n : don't actually run commands

+ 2
- 0
ReadMe.org View File

@ -2,6 +2,8 @@
GameLib is my library for making games. It is the successor to [[https://macoy.me/code/macoy/base2.0][base2.0]].
GameLib is written in [[https://macoy.me/code/macoy/cakelisp/][Cakelisp]].
* Setup
Clone the repository and its dependencies:
#+BEGIN_SRC sh


+ 0
- 3
src/Jamfile View File

@ -1,3 +0,0 @@
SubDir . src ;
Library libGameLib : OgreCore.cake.cpp OgreInitialize.cpp ;

+ 24
- 6
src/SDL.cake View File

@ -7,18 +7,36 @@
"SDL.h"
"SDL_syswm.h")
(defun-local print-sdl-error ()
(defun-local sdl-print-error ()
(printf "SDL_Error: %s\n" (SDL_GetError)))
(forward-declare (struct SDL_Window))
;; I'm not sure SDL won't use OpenGL under the hood. This supports drawing using SDL functions
(defun sdl-initialize-nogl (window-out (* (* SDL_Window)) &return bool)
(when (< (SDL_Init (bit-or SDL_INIT_VIDEO SDL_INIT_TIMER)) 0)
(sdl-print-error)
(return false))
(set (deref window-out)
(SDL_CreateWindow "Gamelib"
SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED 1920 1080
(bit-or SDL_WINDOW_RESIZABLE)))
(unless (deref window-out)
(sdl-print-error)
(return false))
(return true))
;; This is the OpenGL version, which may not support SDL drawing functions, only OpenGL
(defun sdl-initialize (window-out (* (* SDL_Window)) &return bool)
(when (< (SDL_Init (bit-or SDL_INIT_VIDEO SDL_INIT_TIMER)) 0)
(print-sdl-error)
(sdl-print-error)
(return false))
;; This is necessary to make sure the context is created using a newer version. I mainly did this
;; because RenderDoc said it needed it
;; because RenderDoc said it needed it. This version comes from my current machine's version, and
;; isn't a requirement to be this high
(SDL_GL_SetAttribute SDL_GL_CONTEXT_MAJOR_VERSION 4)
(SDL_GL_SetAttribute SDL_GL_CONTEXT_MINOR_VERSION 6)
@ -27,12 +45,12 @@
SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED 1920 1080
(bit-or SDL_WINDOW_RESIZABLE SDL_WINDOW_OPENGL)))
(unless (deref window-out)
(print-sdl-error)
(sdl-print-error)
(return false))
;; Must explicitly create the GL context for Ogre
(unless (SDL_GL_CreateContext (deref window-out))
(print-sdl-error)
(sdl-print-error)
(return false))
(return true))
@ -44,7 +62,7 @@
(defun test--sdl-main (&return int)
(printf "Hello, SDL!\n")
(var window (* SDL_Window) null)
(unless (sdl-initialize (addr window)) (return 1))
(unless (sdl-initialize-nogl (addr window)) (return 1))
;; (var window-surface (* SDL_Surface) (SDL_GetWindowSurface window))


Loading…
Cancel
Save