Browse Source

Added WIP FreeType library

I want this for various reasons.
master
Macoy Madson 10 months ago
parent
commit
6ecb6e08d7
  1. 96
      src/FreeType.cake
  2. 6
      src/TinyCCompiler.cake
  3. 4
      test/src/GameLibTests.cake

96
src/FreeType.cake

@ -0,0 +1,96 @@
(comptime-cond
('auto-test
(defun test--freetype (&return int)
(return 1))))
;;
;; Building
;;
(defun-comptime build-freetype (manager (& ModuleManager) module (* Module) &return bool)
(comptime-cond
('Windows
(comptime-error "Need to add Windows support to FreeType"))
('Unix
(var freetype-build-dir (* (const char)) "cakelisp_cache/FreeTypeBuildDir")
(var freetype-install-dir ([] 1024 char) (array 0))
(SafeSnprintf freetype-install-dir (array-size freetype-install-dir)
"%s/install" freetype-build-dir)
(var freetype-expect-file ([] 1024 char) (array 0))
(SafeSnprintf freetype-expect-file (array-size freetype-expect-file) "%s/lib/libfreetype.a"
freetype-install-dir)
;; Add dependency
(call-on push_back (field manager environment additionalStaticLinkObjects) freetype-expect-file)
;; Already built?
;; We could enhance this by checking for modifications, but that's pretty rare
(when (fileExists freetype-expect-file)
(return true))
(Log "FreeType: Building via Configure and Make\n")
(makeDirectory freetype-build-dir)
(makeDirectory freetype-install-dir)
(run-process-sequential-or
("sh" "autogen.sh" :in-directory "Dependencies/FreeType")
(Log
"failed at FreeType autogen step. This requires a sh/bash-style shell to execute.\n")
(return false))
(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 freetype-install-dir))
(unless absolute-output-path
(Logf "error: failed to make FreeType install directory '%s'\n" freetype-install-dir)
(return false))
(PrintfBuffer configure-output-prefix "--prefix=%s" absolute-output-path)
(free (type-cast absolute-output-path (* void))))
(run-process-sequential-or
("sh" "../../Dependencies/FreeType/configure"
;; Somewhat arbitrary. If I end up needing these, I'll add them back in
"--with-zlib=no"
"--with-bzip2=no"
"--with-png=no"
"--with-harfbuzz=no"
"--with-brotli=no"
configure-output-prefix
:in-directory freetype-build-dir)
(Log
"failed at FreeType configure step. This requires a sh/bash-style shell to execute.\n")
(return false))
(run-process-sequential-or
("make" "--jobs=8" :in-directory freetype-build-dir)
(Log "failed at FreeType make. This tool requires Makefile support.")
(return false))
(run-process-sequential-or
("make" "install" :in-directory freetype-build-dir)
(Log "failed at FreeType make install. This tool requires Makefile support.")
(return false))
;; One final to check to ensure everything's good to go
(unless (fileExists freetype-expect-file)
(Log
"error: FreeType build sequence completed, but files are not where expected. Is there an issue
with the configuration?\n")
(return false)))
(true
(comptime-error "need to define platform, e.g. (comptime-define-symbol 'Unix), or your platform
has not been implemented yet.")))
(Log "FreeType: Successfully built\n")
(return true))
(add-compile-time-hook-module pre-build build-freetype)
(add-dependency-git-submodule
clone-freetype
"https://gitlab.freedesktop.org/freetype/freetype.git"
"Dependencies/FreeType")

6
src/TinyCCompiler.cake

@ -78,19 +78,19 @@ void test(void)
(run-process-sequential-or
("sh" "../../Dependencies/TinyCC/configure" :in-directory tinycc-build-dir)
(Log
"failed at TinyCC configure step. This requires a sh/bash-style shell to execute.")
"failed at TinyCC configure step. This requires a sh/bash-style shell to execute.\n")
(return false))
(run-process-sequential-or
("make" :in-directory tinycc-build-dir)
(Log "failed at TinyCC make. This tool requires Makefile support.")
(Log "failed at TinyCC make. This tool requires Makefile support.\n")
(return false))
;; One final to check to ensure everything's good to go
(unless (fileExists tinycc-expect-file)
(Log
"error: TinyCC build sequence completed, but files are not where expected. Is there an issue
with the configuration?")
with the configuration?\n")
(return false)))
(true
(comptime-error "need to define platform, e.g. (comptime-define-symbol 'Unix), or your platform

4
test/src/GameLibTests.cake

@ -54,7 +54,7 @@
"../src/AutoTest.cake" "../src/Introspection.cake"
"../src/Dictionary.cake" "../src/DynamicArray.cake"
"../src/TaskSystem.cake" "../src/Image.cake" "../src/DataBundle.cake"
"../src/TinyCCompiler.cake")))
"../src/TinyCCompiler.cake" "../src/FreeType.cake")))
(test-opengl-only
(gamelib-run-test
@ -70,7 +70,7 @@
"../src/Aubio.cake" "../src/ImGui.cake" "../src/Dictionary.cake"
"../src/DynamicArray.cake" "../src/Introspection.cake" "../src/OpenGL.cake"
"../src/Tracy.cake" "../src/TaskSystem.cake" "../src/Image.cake"
"../src/DataBundle.cake" "../src/TinyCCompiler.cake"
"../src/DataBundle.cake" "../src/TinyCCompiler.cake" "../src/FreeType.cake"
"../src/ProfilerAutoInstrument.cake"))
(when test-ogre

Loading…
Cancel
Save