GameLib is a collection of libraries for creating applications in Cakelisp.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

64 lines
4.3 KiB

(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import "ComptimeHelpers.cake" "BuildTools.cake" "CHelpers.cake")
;; Use Zig's bundled toolchain to compile our Cakelisp app
;; Note that it's too late to use this for compile-time. You'd need to already have zig extracted
(defun-comptime download-set-zig (manager (& ModuleManager) module (* Module) &return bool)
(var zig-name ([] 1024 char) "zig-linux-x86_64-0.9.0-dev.1733+8f1e41775")
(var archive-url ([] 1024 char) (array 0))
(PrintfBuffer archive-url "https://ziglang.org/builds/%s.tar.xz" zig-name)
(var zig-archive ([] 1024 char) (array 0))
(PrintfBuffer zig-archive "cakelisp_cache/%s.tar.xz" zig-name)
(var extracted-zig-executable ([] 1024 char) (array 0))
(PrintfBuffer extracted-zig-executable "cakelisp_cache/%s/zig" zig-name)
(unless (fileExists extracted-zig-executable)
(unless (fileExists zig-archive)
(Logf "Downloading Zig from %s via curl\n" archive-url)
(run-process-sequential-or
("curl" archive-url "--output" zig-archive)
(Logf "error: failed to download Zig from %s via curl\n" archive-url)
(return false)))
(unless (fileExists extracted-zig-executable)
(var input-archive-arg ([] 1024 char) (array 0))
(PrintfBuffer input-archive-arg "--file=%s" zig-archive)
(Logf "Extracting Zig from %s\n" zig-archive)
(run-process-sequential-or
("tar" "--xz" "--extract" input-archive-arg "--one-top-level=cakelisp_cache")
(Logf "error: failed to extract Zig from %s\n" zig-archive)
(return false)))
(remove zig-archive))
(var zig-build-command ProcessCommand)
(set (field zig-build-command fileToExecute) extracted-zig-executable)
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_String "c++"))
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_String "-g"))
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_String "-c"))
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_SourceInput EmptyString))
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_String "-o"))
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_ObjectOutput EmptyString))
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_String "-fPIC"))
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_IncludeSearchDirs EmptyString))
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_AdditionalOptions EmptyString))
;; TODO Remove this by fixing the writer
(call-on push_back (field zig-build-command arguments) (array ProcessCommandArgumentType_String "-Wno-parentheses-equality"))
(set (field manager environment buildTimeBuildCommand) zig-build-command)
(var zig-link-command ProcessCommand)
(set (field zig-link-command fileToExecute) extracted-zig-executable)
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_String "c++"))
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_AdditionalOptions EmptyString))
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_String "-o"))
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_ExecutableOutput EmptyString))
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_ObjectInput EmptyString))
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_LibrarySearchDirs EmptyString))
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_Libraries EmptyString))
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_LibraryRuntimeSearchDirs EmptyString))
(call-on push_back (field zig-link-command arguments) (array ProcessCommandArgumentType_LinkerArguments EmptyString))
(set (field manager environment buildTimeLinkCommand) zig-link-command)
(return true))
(add-compile-time-hook-module pre-build download-set-zig :priority-increase 9)