|
|
@ -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 |
|
|
|