3 changed files with 101 additions and 5 deletions
@ -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") |
Loading…
Reference in new issue