From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id INIeIdxpwmGYRAAAgWs5BA (envelope-from ) for ; Wed, 22 Dec 2021 00:57:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KAn9HNxpwmE5WAAA1q6Kng (envelope-from ) for ; Tue, 21 Dec 2021 23:57:16 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F102AA2E6 for ; Wed, 22 Dec 2021 00:57:15 +0100 (CET) Received: from localhost ([::1]:53312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzp0N-0001ZP-3c for larch@yhetil.org; Tue, 21 Dec 2021 18:57:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzp0B-0001Z0-2M for guix-patches@gnu.org; Tue, 21 Dec 2021 18:57:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzp0A-0002rz-Po for guix-patches@gnu.org; Tue, 21 Dec 2021 18:57:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mzp0A-0005rS-Pk for guix-patches@gnu.org; Tue, 21 Dec 2021 18:57:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#48952] [PATCH v2 1/6] build-system: Add godot-build-system. Resent-From: Vinicius Monego Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 21 Dec 2021 23:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48952 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48952@debbugs.gnu.org Cc: Vinicius Monego Received: via spool by 48952-submit@debbugs.gnu.org id=B48952.164013099122413 (code B ref 48952); Tue, 21 Dec 2021 23:57:02 +0000 Received: (at 48952) by debbugs.gnu.org; 21 Dec 2021 23:56:31 +0000 Received: from localhost ([127.0.0.1]:56198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzozf-0005pQ-2A for submit@debbugs.gnu.org; Tue, 21 Dec 2021 18:56:31 -0500 Received: from mout02.posteo.de ([185.67.36.66]:33925) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzozc-0005pB-WA for 48952@debbugs.gnu.org; Tue, 21 Dec 2021 18:56:29 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 14CA4240104 for <48952@debbugs.gnu.org>; Wed, 22 Dec 2021 00:56:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1640130983; bh=DMchcAjLaYbFFmCqvh8tdSGXr5Vy7LQ6AGMKVZofWXY=; h=From:To:Cc:Subject:Date:From; b=chg7XCFm+dKkIn2yA+iKDEqCbSeY+8ExF+OtWoXdbBSVbjb+dNugNOh0QfAX+AzJh ezGOFb3CUckJkorUYw4ZfIPj0G8fLjSRIRHk9aucfZHOl9gb4YMi1NozHvomdu+0c/ 6whZOctiJGKTFI86jX0JG/PsF/U1gDKQyORjnm/q1t2OAJ3P9j9dKGrKyzMj/LXM7P OwBe4AWstC7mpLFBHhBAnbF+MvkKq9qsD0OBu0aakmgp1Qk4W2g8al4Kf7NRkAJnRH fylFLC3A02wl4QEMRN74hXiDtGdDK7pziWDgO42aMD/bkfpgmEpjdwPNmj/8nPHWRb PP2wTfNw82zJA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JJYJQ0sDhz9rwg; Wed, 22 Dec 2021 00:56:21 +0100 (CET) From: Vinicius Monego Date: Tue, 21 Dec 2021 23:55:43 +0000 Message-Id: <20211221235548.130808-2-monego@posteo.net> In-Reply-To: <20211221235548.130808-1-monego@posteo.net> References: <20211221235548.130808-1-monego@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640131036; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=pCdjJGxORySL84u0Aeco6WbW8PF+pO8e+4elWMl8aY0=; b=L8Sj8+dvn1OHb9qWeDjGt7mtdHacargefPOsUImgM6+2zuigG93LDyOTbnpLlRFRfwcnHD /9it+q4XdY3QZAQhu/YSVHwESOVIsNICk8wwMHupy3vllHLkgK10Pq0nHZaluHnR2Lnw2D 9hsn4Srb8/IKOy/rGEoVuDrM4x4KVM53dZ+Sp7kc8KkHbTqk8gyKmq/8Z1bD7toLcn3Vp/ V37Ec8c6NG/ZpZiXaGDP4mifL4NznwJhwJj8i6heB6OGuQvCCr2G8aVreb98m2TMBclTCj WgbhujV8KuesAmk3gZh1HjSRymhFod0dWh0HnsCvvizHHaxVAtB/ieUqN4auLQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640131036; a=rsa-sha256; cv=none; b=uhuF9EFEJ+gd+koCyrmnEalO5W+CX2nwQBUszrCZ1wMcJdtMLnCRuE3CzmQyzm+4Wfvbep NYFNBs6c/EzDdceKvh/TsQ4XzVgTf9xXgvVkvelE51KeqHtZO9+ffUGYt4EJqiG7h8v/p7 UGhrr+0WVpn7qSvLOrNKl9m9y3pgno8HTo2b6nuQ5gxesM0EziNY/2dNznwfZc3J8qtBh+ of1cFMkCpfPlH4/RsYLwuHgr2FEc9mhJZ0A2l+Z+cmChgqUzPLIGZIuLoZOIpIrE28PZgF acFjvqs9aQMeeqmEkPt8alQoj6OWesmxTa/89O+N5gD1uVHUdz/c9qIGlM2k/Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=chg7XCFm; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=chg7XCFm; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: F102AA2E6 X-Spam-Score: -1.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: XIvfK1m/UtWc * guix/build/godot-build-system.scm: New file. * guix/build-system/godot.scm: New file. * Makefile.am (MODULES): Add them here. * doc/guix.texi (Build Systems): Document godot-build-system. --- Makefile.am | 3 + doc/guix.texi | 19 +++++ guix/build-system/godot.scm | 122 +++++++++++++++++++++++++++++ guix/build/godot-build-system.scm | 123 ++++++++++++++++++++++++++++++ 4 files changed, 267 insertions(+) create mode 100644 guix/build-system/godot.scm create mode 100644 guix/build/godot-build-system.scm diff --git a/Makefile.am b/Makefile.am index c4ccee65f1..283e2d7b7f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,6 +16,7 @@ # Copyright © 2019 Efraim Flashner # Copyright © 2021 Chris Marusich # Copyright © 2021 Andrew Tropin +# Copyright © 2021 Vinicius Monego # # This file is part of GNU Guix. # @@ -148,6 +149,7 @@ MODULES = \ guix/build-system/copy.scm \ guix/build-system/glib-or-gtk.scm \ guix/build-system/gnu.scm \ + guix/build-system/godot.scm \ guix/build-system/guile.scm \ guix/build-system/haskell.scm \ guix/build-system/julia.scm \ @@ -204,6 +206,7 @@ MODULES = \ guix/build/gnu-bootstrap.scm \ guix/build/gnu-build-system.scm \ guix/build/gnu-dist.scm \ + guix/build/godot-build-system.scm \ guix/build/guile-build-system.scm \ guix/build/maven-build-system.scm \ guix/build/minetest-build-system.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 34e75156eb..d1b5a365ea 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -100,6 +100,7 @@ Copyright @copyright{} 2021 Josselin Poiret@* Copyright @copyright{} 2021 Andrew Tropin@* Copyright @copyright{} 2021 Sarah Morgensen@* Copyright @copyright{} 2021 Josselin Poiret@* +Copyright @copyright{} 2021 Vinicius Monego@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -8324,6 +8325,24 @@ specified with the @code{#:glib} parameter. Both phases are executed after the @code{install} phase. @end defvr +@defvr {Scheme Variable} godot-build-system +This variable is exported by @code{(guix build-system godot)}. It implements +the more or less standard build procedure used by Godot games. + +Projects may place @file{project.godot} in a subdirectory. This can be passed +to @code{#:project-directory}. It defaults to the source root. + +Many projects do not ship with @file{exports_preset.cfg}. In that case, a +custom template is created. If that file exists already, it is preferred. +The name of the target preset is variable and can be specified with +@code{#:export-name}. Defaults to ``Linux/X11'' which is used in the custom +template. + +It further creates a wrapper script in @code{bin/} which can be used to launch +the game. The filename is configured by @code{#:game} and should be set to +the name of the package. Desktop files must be created or copied manually. +@end defvr + @defvr {Scheme Variable} guile-build-system This build system is for Guile packages that consist exclusively of Scheme code and that are so lean that they don't even have a makefile, let alone a diff --git a/guix/build-system/godot.scm b/guix/build-system/godot.scm new file mode 100644 index 0000000000..510d33c86e --- /dev/null +++ b/guix/build-system/godot.scm @@ -0,0 +1,122 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Vinicius Monego +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix 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. +;;; +;;; GNU Guix 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 GNU Guix. If not, see . + +(define-module (guix build-system godot) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix memoization) + #:use-module (guix packages) + #:use-module (guix gexp) + #:use-module (guix monads) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (%godot-build-system-modules + default-godot + godot-build + godot-build-system)) + +(define (default-godot) + "Return the default Godot package." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((module (resolve-interface '(gnu packages game-development)))) + (module-ref module 'godot))) + +(define %godot-build-system-modules + ;; Build-side modules imported by default. + `((guix build godot-build-system) + ,@%gnu-build-system-modules)) + +(define* (lower name + #:key source inputs native-inputs outputs system target + (godot (default-godot)) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:target #:godot #:inputs #:native-inputs)) + + (and (not target) ;XXX: no cross-compilation + (bag + (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source) + ("godot-headless" ,godot "headless")) + '()) + ,@inputs + + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (build-inputs `(("godot" ,godot) + ,@native-inputs)) + (outputs outputs) + (build godot-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define* (godot-build name inputs + #:key + source + (phases '%standard-phases) + (configure-flags ''()) + (game "Game") + (project-directory ".") + (export-name "Linux/X11") + (outputs '("out")) + (output "out") + (search-paths '()) + (system (%current-system)) + (guile #f) + (imported-modules %godot-build-system-modules) + (modules '((guix build godot-build-system) + (guix build utils)))) + "Build SOURCE using GODOT, and with INPUTS." + (define builder + (with-imported-modules imported-modules + #~(begin + (use-modules #$@(sexp->gexp modules)) + (godot-build #:name #$name + #:source #+source + #:configure-flags #$configure-flags + #:game #$game + #:project-directory #$project-directory + #:export-name #$export-name + #:system #$system + #:phases #$phases + #:outputs #$(outputs->gexp outputs) + #:output #$output + #:game #$game + #:search-paths '#$(sexp->gexp + (map search-path-specification->sexp + search-paths)) + #:inputs #$(input-tuples->gexp inputs))))) + + (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) + system #:graft? #f))) + (gexp->derivation name builder + #:system system + #:guile-for-build guile))) + +(define godot-build-system + (build-system + (name 'godot) + (description "The Godot build system") + (lower lower))) diff --git a/guix/build/godot-build-system.scm b/guix/build/godot-build-system.scm new file mode 100644 index 0000000000..5c25111540 --- /dev/null +++ b/guix/build/godot-build-system.scm @@ -0,0 +1,123 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Vinicius Monego +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix 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. +;;; +;;; GNU Guix 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 GNU Guix. If not, see . + +(define-module (guix build godot-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build utils) + #:use-module (ice-9 match) + #:use-module (ice-9 format) + #:use-module (ice-9 ftw) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (%standard-phases + godot-build)) + +(define* (configure #:key project-directory #:allow-other-keys) + + ;; Projects may have the 'project.godot' file in different directories. The + ;; project-directory key contains the path string to the directory where it + ;; is located. + + (chdir project-directory) + (setenv "HOME" (getcwd)) + + ;; Not all projects ship with export_presets.cfg because it may contain + ;; confidential information such as CI keys. In that case, we check if + ;; this file exists, and if it doesn't we use this generic template below. + ;; There is ongoing effort to separate the keys from that file. See: + ;; https://github.com/godotengine/godot-demo-projects/issues/329 and + ;; https://github.com/godotengine/godot/pull/35930. Until that is fixed and + ;; developers start to provide the file, we have to use our own template. + + (let ((export-presets "export_presets.cfg")) + (when (not (file-exists? export-presets)) + (with-output-to-file export-presets + (lambda () + (display + "[preset.0] + +name=\"Linux/X11\" +platform=\"Linux/X11\" +runnable=true +custom_features=\"\" +export_filter=\"all_resources\" +include_filter=\"\" +exclude_filter=\"\" +export_path=\"\" +patch_list=PoolStringArray( ) +script_export_mode=1 +script_encryption_key=\"\" + +[preset.0.options] + +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +texture_format/no_bptc_fallbacks=true +binary_format/64_bits=false +binary_format/embed_pck=false +custom_template/release=\"\" +custom_template/debug=\"\"")))))) + +(define* (build #:key inputs game export-name #:allow-other-keys) + (let ((godot (assoc-ref inputs "godot-headless"))) + (invoke (string-append godot "/bin/godot_server") + "--export-pack" export-name (string-append game ".pck") + "project.godot"))) + +(define* (install #:key inputs outputs game #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (share (string-append out "/share")) + (data (string-append share "/" game)) + (desktop (string-append share "/applications"))) + + ;; Install the binary file. + (install-file (string-append game ".pck") data) + (mkdir-p bin) + (call-with-output-file (string-append bin "/" game) + (lambda (port) + (format port + "#!/bin/sh~@ + exec ~a/bin/godot --main-pack ~a/~a.pck~%" + (assoc-ref inputs "godot") data game) + (chmod port #o755))) + + ;; Install desktop file[s]. + (mkdir-p desktop) + (for-each (lambda (file) + (display file) + (copy-file file (string-append + desktop "/" + (car (last-pair + (string-split file #\/)))))) + (find-files "." "\\.desktop$")))) + +(define %standard-phases + (modify-phases gnu:%standard-phases + (delete 'bootstrap) + (replace 'configure configure) + (replace 'build build) + (delete 'check) + (replace 'install install))) + +(define* (godot-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given Godot package, applying all of PHASES in order." + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) -- 2.30.2