Browse Source

Licenses are now automatically registered

master
Macoy Madson 1 year ago
parent
commit
5aab242f8b
  1. 5
      src/Compression.cake
  2. 5
      src/Curl.cake
  3. 6
      src/ImGui.cake
  4. 129
      src/Licenses.cake
  5. 5
      src/Math.cake
  6. 5
      src/Oniguruma.cake
  7. 5
      src/OpenGL.cake
  8. 5
      src/OpenSSL.cake
  9. 5
      src/SDL.cake
  10. 5
      src/STB.cake
  11. 5
      src/TaskSystem.cake

5
src/Compression.cake

@ -4,7 +4,10 @@
(add-cakelisp-search-directory "src")
(import "CHelpers.cake" "BuildTools.cake"
"Dependencies.cake")
"Dependencies.cake"
&defs-only "Licenses.cake")
(register-module-license "miniz" g-miniz-license-string)
(c-import "miniz.h" &with-decls "<stddef.h>")

5
src/Curl.cake

@ -8,7 +8,8 @@
(import "CHelpers.cake" "BuildTools.cake"
"Dependencies.cake"
;; For download-into-dynarray
"DynamicArray.cake")
"DynamicArray.cake"
&defs-only "Licenses.cake")
(export-and-evaluate
(comptime-cond
@ -25,6 +26,8 @@
;; From gamelib
"OpenSSL.cake" "Curl.cake")
(register-module-license "curl" g-curl-license-string)
;;
;; Helpers
;;

6
src/ImGui.cake

@ -1,7 +1,11 @@
(import "Dependencies.cake" "CHelpers.cake" "ComptimeHelpers.cake")
(import "Dependencies.cake" "CHelpers.cake" "ComptimeHelpers.cake"
&defs-only "Licenses.cake")
(c-import "imgui.h")
(register-module-license "dear imgui" g-imgui-license-string)
(register-module-license "Ubuntu font" g-ubuntu-font-license-string)
;; The main interface into imgui.
(defmacro imgui-call (function symbol &rest &optional arguments any)
(if arguments

129
src/Licenses.cake

@ -1,38 +1,42 @@
;; Licenses.cake: A collection of all the licenses modules in gamelib provide. These are all in one
;; rather than per-dependency because it's more likely you want to recompile the module, so
;; separating the license should optimize for that.
;;
;; Use g-licenses and g-license-count to automatically list all the licenses your application uses.
;; Importing a module is enough to add that module's license to the list.
(import "ComptimeHelpers.cake")
(defmacro register-module-license (module-name string license symbol)
(get-or-create-comptime-var module-licenses
(<> (in std vector)
(<> (in std pair) (in std string) (* (const Token)))))
(<> (in std pair) (* (const Token)) (* (const Token)))))
(call-on-ptr push_back module-licenses
(call (in std make_pair) (path module-name > contents) license))
(call (in std make_pair) module-name license))
(return true))
(defun-comptime sorted-module-comparison (a (& (const (* (<> (in std pair)
(in std string)
(* (const Token))))))
b (& (const (* (<> (in std pair)
(in std string)
(* (const Token))))))
(defun-comptime sorted-module-comparison (a (& (const (<> (in std pair)
(* (const Token))
(* (const Token)))))
b (& (const (<> (in std pair)
(* (const Token))
(* (const Token)))))
&return bool)
(return (> 0 (call-on compare (path a > first)
(path b > first)))))
(return (> 0 (call-on compare (path a . first > contents)
(path b . first > contents)))))
(defun-comptime update-module-licenses (environment (& EvaluatorEnvironment)
&return bool)
(get-or-create-comptime-var num-licenses int 0)
(get-or-create-comptime-var module-licenses
(<> (in std vector)
(<> (in std pair) (in std string) (* (const Token)))))
(unless (< (deref num-licenses) (call-on-ptr module-licenses size))
(<> (in std pair) (* (const Token)) (* (const Token)))))
(unless (< (deref num-licenses) (call-on-ptr size module-licenses))
(return true))
(set (deref num-licenses) (call-on-ptr size module-licenses))
;; Sort to ensure stable order
(unless (call-on-ptr empty sorted-modules)
(unless (call-on-ptr empty module-licenses)
;; TODO: This is a HACK: Invoke the sort function once so it's registered as a reference on
;; this definition, which will pull it into the comptime compilation
(sorted-module-comparison (deref (call-on-ptr begin module-licenses))
@ -41,19 +45,35 @@
(call-on-ptr end module-licenses) sorted-module-comparison))
(var module-licenses-list-tokens (<> std::vector Token))
(for-in module-license-pair (& (const (<> (in std pair) (in std string)
(for-in module-license-pair (& (const (<> (in std pair) (* (const Token))
(* (const Token)))))
(deref module-licenses)
(tokenize-push module-licenses-list-tokens
(token-splice (call-on second module-license-pair))))
(array
(token-splice (field module-license-pair first))
(token-splice (field module-license-pair second)))))
(var module-licenses-list-variable-tokens (* (<> std::vector Token)) (new (<> std::vector Token)))
(call-on push_back (field environment comptimeTokens) module-licenses-list-variable-tokens)
(tokenize-push (deref module-licenses-list-variable-tokens)
(var-global g-licenses ([] module-license) (token-splice-array module-licenses-list-tokens)))
(var-global g-licenses ([] module-license)
(array (token-splice-array module-licenses-list-tokens))))
(unless (ReplaceAndEvaluateDefinition
environment
"g-licenses"
module-licenses-list-variable-tokens)
(deref module-licenses-list-variable-tokens))
(return false))
(var module-num-licenses-tokens (* (<> std::vector Token)) (new (<> std::vector Token)))
(call-on push_back (field environment comptimeTokens) module-num-licenses-tokens)
(var num-licenses-token Token (deref (path (call-on-ptr begin module-licenses) > first)))
(token-contents-snprintf num-licenses-token "%d" (deref num-licenses))
(set (field num-licenses-token type) TokenType_Symbol)
(tokenize-push (deref module-num-licenses-tokens)
(var-global g-licenses-count int (token-splice-addr num-licenses-token)))
(unless (ReplaceAndEvaluateDefinition
environment
"g-licenses-count"
(deref module-num-licenses-tokens))
(return false))
(return true))
@ -65,6 +85,11 @@
;; Populated at compile-time
(var-global g-licenses ([] module-license) (array 0))
(var-global g-licenses-count int 0)
;; These need to go somewhere, so we might as well have Licenses register them
(register-module-license "GameLib" g-gamelib-copyright-string)
(register-module-license "Cakelisp" g-cakelisp-copyright-string)
;; g-gamelib-copyright-string
;; g-gnu-gpl-license-string
@ -95,6 +120,25 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GameLib. If not, see <https://www.gnu.org/licenses/>.#"#)
(var-global g-cakelisp-copyright-string (* (const char))
#"#Cakelisp
Created by Macoy Madson <macoy@macoy.me>.
https://macoy.me/code/macoy/gamelib
Copyright (c) 2022 Macoy Madson.
Cakelisp is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Cakelisp is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Cakelisp. If not, see <https://www.gnu.org/licenses/>.#"#)
(var-global g-gnu-gpl-license-string (* (const char))
#"#GNU GENERAL PUBLIC LICENSE
@ -820,8 +864,7 @@ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
DEALINGS IN THE FONT SOFTWARE.#"#)
(var-global g-galogen-license-string (* (const char)) #"#
Apache License
(var-global g-apache-license-string (* (const char)) #"# Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
@ -1276,6 +1319,54 @@ https://creativecommons.org/licenses/by/3.0/
Copied from https://github.com/mixaal/imageprocessor.
Modified by converting to Cakelisp by Macoy Madson.#"#)
(var-global g-miniz-license-string (* (const char))
#"#Copyright 2013-2014 RAD Game Tools and Valve Software
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.#"#)
(var-global g-curl-license-string (* (const char))
#"#COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1996 - 2022, Daniel Stenberg, <daniel@haxx.se>, and many
contributors, see the THANKS file.
All rights reserved.
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright
notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization of the copyright holder.#"#)
(var-global g-gnu-glib-license (* (const char))
#"# GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999

5
src/Math.cake

@ -9,7 +9,8 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(import "Dependencies.cake" "CHelpers.cake")
(import "Dependencies.cake" "CHelpers.cake"
&defs-only "Licenses.cake")
(c-import "<stdio.h>")
@ -20,6 +21,8 @@
;; Must also include in source file so HANDMADE_MATH_IMPLEMENTATION is output here
&with-defs "HandmadeMath.h")
(register-module-license "Handmade Math" g-handmade-math-license-string)
;;
;; Fundamental
;;

5
src/Oniguruma.cake

@ -1,6 +1,9 @@
;; Oniguruma: a regular expression engine with multiple encodings supported
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake"
&defs-only "Licenses.cake")
(register-module-license "Oniguruma" g-oniguruma-license-string)
(export-and-evaluate
(add-c-search-directory-module "Dependencies/oniguruma/src")

5
src/OpenGL.cake

@ -1,11 +1,14 @@
;; Windowing and OpenGL access are provided by SDL
(import "SDL.cake")
(import "SDL.cake"
&defs-only "Licenses.cake")
(c-import "stdio.h"
"SDL_syswm.h"
;; Use galogen-generated header. See (generate-gl-header)
&with-decls "gl46.h") ;; "GL/gl.h"
(register-module-license "Galogen" g-apache-license-string)
(def-type-alias-global gl-id (unsigned int))
(defun opengl-shader-was-compiled-sucessfully (shader gl-id &return bool)

5
src/OpenSSL.cake

@ -1,6 +1,9 @@
;; OpenSSL.cake: Access openssl
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake"
&defs-only "Licenses.cake")
(register-module-license "OpenSSL" g-apache-license-string)
;; (export-and-evaluate
;; (add-c-search-directory-module "Dependencies/openssl/src")

5
src/SDL.cake

@ -1,13 +1,16 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(add-cakelisp-search-directory "Dependencies/cakelisp/runtime")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake")
(import "CHelpers.cake" "BuildTools.cake" "Dependencies.cake"
&defs-only "Licenses.cake")
(export-and-evaluate
(c-import "SDL.h" "SDL_syswm.h"))
(c-import "<stdio.h>" &with-decls "<stddef.h>" "<stdbool.h>")
(register-module-license "SDL" g-sdl-license-string)
;;
;; Core/windowing
;;

5
src/STB.cake

@ -1,4 +1,7 @@
(import "Dependencies.cake")
(import "Dependencies.cake"
&defs-only "Licenses.cake")
(register-module-license "STB" g-stb-license-string)
;; Add all the necessary includes, defines, download the repo, etc.
(defmacro use-stb-ds ()

5
src/TaskSystem.cake

@ -1,5 +1,6 @@
;; TaskSystem.cake: Interface into task-based multithreading
(import "ComptimeHelpers.cake" "CHelpers.cake")
(import "ComptimeHelpers.cake" "CHelpers.cake"
&defs-only "Licenses.cake")
(c-import "stdlib.h" ;; malloc, free
"string.h") ;; memset
@ -7,6 +8,8 @@
(add-c-search-directory-module "Dependencies/enkiTS/src")
(c-import "TaskScheduler_c.h"))
(register-module-license "EnkiTS" g-enkits-license-string)
(forward-declare
(struct enkiCompletionAction)
(struct enkiTaskSet)

Loading…
Cancel
Save