From patchwork Tue Apr 22 16:52:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Ziltener X-Patchwork-Id: 41944 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DB38827BC4B; Tue, 22 Apr 2025 17:55:29 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1A3C627BC4A for ; Tue, 22 Apr 2025 17:55:28 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u7Gtp-0001Jf-W5; Tue, 22 Apr 2025 12:55:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u7Gtj-0001Go-8u for guix-patches@gnu.org; Tue, 22 Apr 2025 12:55:04 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u7Gti-0002LS-1k for guix-patches@gnu.org; Tue, 22 Apr 2025 12:55:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=eNUlOyq2ovqSowLA42cIluhduwbJkTL6OU7VjlhRZwQ=; b=cnyvwV1AVfgRRnraa2WbN+1fjKHvpZECe2iZtVpoU6h51zVK+aaLts89lmKFN15bzukSN1gWMzmFHa5FByfGAjOhDidHYLTyTEOpuekUG+45XsWZqvJmYLp7dam9JFKndlKjOu3BNmlZkyKwAkZtHMQzr5H5ffMzyOarZaR2eSGTACwW/4up/p3ADjC9hH5vEdCciJJH+21kn0B5gfBBR8FGDJrn9yRaDNHVOUeBtpEGbLTDb1wZA44zBY7uvXFs0xFbiAaKYfynJ+vkYJqQMLeT/bdM0XtEyyjBUk4cStrB529rt9Yn4Vy7vdfODn2fOdiiSa9qQTBtY0Mw5mz+qQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u7Gth-00059x-QK for guix-patches@gnu.org; Tue, 22 Apr 2025 12:55:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77877] [PATCH] build-system: fix and future-proof Chicken build system. References: <20250417203400.29123-1-dziltener@lyrion.ch> In-Reply-To: <20250417203400.29123-1-dziltener@lyrion.ch> Resent-From: Daniel Ziltener Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 22 Apr 2025 16:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77877 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77877@debbugs.gnu.org Cc: Daniel Ziltener Received: via spool by 77877-submit@debbugs.gnu.org id=B77877.174534088519806 (code B ref 77877); Tue, 22 Apr 2025 16:55:01 +0000 Received: (at 77877) by debbugs.gnu.org; 22 Apr 2025 16:54:45 +0000 Received: from localhost ([127.0.0.1]:49667 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u7GtQ-00059N-MS for submit@debbugs.gnu.org; Tue, 22 Apr 2025 12:54:45 -0400 Received: from 195-15-242-23.dc3-a.pub1.etik-cloud.com ([195.15.242.23]:62737 helo=lyrion.ch) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u7GtN-000598-5z for 77877@debbugs.gnu.org; Tue, 22 Apr 2025 12:54:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyrion.ch; s=20230702; t=1745340876; h=from:from: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; bh=eNUlOyq2ovqSowLA42cIluhduwbJkTL6OU7VjlhRZwQ=; b=IVFNgua6GtQw0bbWgY52ucX9RwPdx9v1Ct/xclWaWXTphW4IqR+vWmTKD9fa5dNoFb6EXq HdllF4R/i4lsos8rTUiIOP/vsezDf220K1WPncknXdQMOX38QHZt4osueX7NeoOdkwV9i6 L5ir/iwkzVWxCFlkeKT4J0zNn4zNrbxF3eLIRaM+J4Ymd4IANmd/huQUV+tWJWy52AWaEi 5cQkNCrZPlFe8V7Mt8Nv3Fry3h94A37oZmduJa60GivDneePjZ1YkTsKL9o26CHMwMtRDd zALsBE1GX7Ej40ANcfYgDxslJLMH8NG94Qlzzso7obsqX6HvRsHhLHGSdm4jFA== Received: from localhost (cf597899.dynamic.tele-ag.de [207.89.120.153]) by lyrion.ch (OpenSMTPD) with ESMTPSA id 309bc6a4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 22 Apr 2025 16:54:36 +0000 (UTC) Date: Tue, 22 Apr 2025 18:52:55 +0200 Message-ID: <20250422165430.11287-1-dziltener@lyrion.ch> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 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: , Reply-to: Daniel Ziltener X-ACL-Warn: , Daniel Ziltener via Guix-patches X-Patchwork-Original-From: Daniel Ziltener via Guix-patches via From: Daniel Ziltener Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This amendment removes the unused "chicken-package?" procedure. --- guix/build-system/chicken.scm | 87 +++++++++++++++++++---------- guix/build/chicken-build-system.scm | 54 ++++++++++++------ 2 files changed, 94 insertions(+), 47 deletions(-) diff --git a/guix/build-system/chicken.scm b/guix/build-system/chicken.scm index e6fcfa7ee3..c5705018d1 100644 --- a/guix/build-system/chicken.scm +++ b/guix/build-system/chicken.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2020 raingloom ;;; Copyright © 2021 Ludovic Courtès ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2025 zilti ;;; ;;; This file is part of GNU Guix. ;;; @@ -23,9 +24,12 @@ (define-module (guix build-system chicken) #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix monads) + #:use-module (guix download) #: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 (guix packages) #:export (%chicken-build-system-modules chicken-build @@ -45,10 +49,10 @@ (define %chicken-build-system-modules ,@%default-gnu-imported-modules)) (define (default-chicken) + "Return the default Chicken package." ;; Lazily resolve the binding to avoid a circular dependency. - ;; TODO is this actually needed in every build system? (let ((chicken (resolve-interface '(gnu packages chicken)))) - (module-ref chicken 'chicken))) + (module-ref chicken 'chicken))) (define* (lower name #:key source inputs native-inputs outputs system target @@ -57,38 +61,55 @@ (define* (lower name #:rest arguments) "Return a bag for NAME." (define private-keywords - '(#:target #:chicken #:inputs #:native-inputs)) + '(#:target #:inputs #:native-inputs #:outputs)) ;; TODO: cross-compilation support (and (not target) (bag (name name) (system system) - (host-inputs `(,@(if source - `(("source" ,source)) - '()) - ,@inputs + (host-inputs + `(,@(if source + `(("source" ,source)) + '()) + ,@inputs - ;; Keep the standard inputs of 'gnu-build-system', since - ;; Chicken compiles Scheme by using C as an intermediate - ;; language. - ,@(standard-packages))) + ;; Keep the standard inputs of 'gnu-build-system', since + ;; Chicken compiles Scheme by using C as an intermediate + ;; language. + ,@(standard-packages))) (build-inputs `(("chicken" ,chicken) ,@native-inputs)) (outputs outputs) (build chicken-build) - (arguments (strip-keyword-arguments private-keywords arguments))))) + (arguments + (substitute-keyword-arguments + (strip-keyword-arguments private-keywords arguments) + ((#:extra-directories extra-directories) + `(list + ,@(append-map + (lambda (name) + (match (assoc name inputs) + ((_ pkg) + (match (package-transitive-propagated-inputs pkg) + (((propagated-names . _) ...) + (cons name propagated-names)))))) + extra-directories)))))))) (define* (chicken-build name inputs #:key + (chicken (default-chicken)) source + (tests? #t) + (parallel-build? #f) + (build-flags ''()) + (configure-flags ''()) + (extra-directories ''()) (phases '%standard-phases) - (outputs '("out")) + (outputs '("out" "static")) (search-paths '()) (egg-name "") (unpack-path "") - (build-flags ''()) - (tests? #t) (system (%current-system)) (guile #f) (imported-modules %chicken-build-system-modules) @@ -99,22 +120,28 @@ (define builder (with-imported-modules imported-modules #~(begin (use-modules #$@(sexp->gexp modules)) - (chicken-build #:name #$name - #:source #+source - #:system #$system - #:phases #$phases - #:outputs #$(outputs->gexp outputs) - #:search-paths '#$(sexp->gexp - (map search-path-specification->sexp - search-paths)) - #:egg-name #$egg-name - #:unpack-path #$unpack-path - #:build-flags #$build-flags - #:tests? #$tests? - #:inputs #$(input-tuples->gexp inputs))))) + (chicken-build + #:name #$name + #:chicken #$chicken + #:source #+source + #:system #$system + #:phases #$phases + #:configure-flags #$configure-flags + #:extra-directories #$extra-directories + #:parallel-build? #$parallel-build? + #:outputs #$(outputs->gexp outputs) + #:search-paths '#$(sexp->gexp + (map search-path-specification->sexp + search-paths)) + #:egg-name #$egg-name + #:unpack-path #$unpack-path + #:build-flags #$build-flags + #:tests? #$tests? + #:inputs #$(input-tuples->gexp inputs))))) - (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) - system #:graft? #f))) + (mlet %store-monad ((guile (package->derivation + (or guile (default-guile)) + system #:graft? #f))) (gexp->derivation name builder #:system system #:guile-for-build guile))) diff --git a/guix/build/chicken-build-system.scm b/guix/build/chicken-build-system.scm index fd5a33fd22..6b1826ac5a 100644 --- a/guix/build/chicken-build-system.scm +++ b/guix/build/chicken-build-system.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 raingloom +;;; Copyright © 2025 zilti ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,6 +22,8 @@ (define-module (guix build chicken-build-system) #:use-module (guix build utils) #:use-module (ice-9 match) #:use-module (ice-9 ftw) + #:use-module (ice-9 rdelim) + #:use-module (ice-9 popen) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (rnrs io ports) @@ -32,25 +35,42 @@ (define-module (guix build chicken-build-system) ;; CHICKEN_INSTALL_REPOSITORY is where dependencies are looked up ;; its first component is also where new eggs are installed. -;; TODO: deduplicate with go-build-system.scm ? -;; TODO: the binary version should be defined in one of the relevant modules -;; instead of being hardcoded everywhere. Tried to do that but got undefined -;; variable errors. +(define (chicken-binary-version chicken) + (let* ((port (open-pipe* + OPEN_READ + (string-append chicken "/bin/csi") + "-p" + "(begin (import (chicken pathname) (chicken platform)) (pathname-file (car (repository-path))))")) + (str (read-line port))) + (close-pipe port) + str)) -(define (chicken-package? name) - (string-prefix? "chicken-" name)) +(define (chicken-lib-dir chicken) + (string-append + chicken "/var/lib/chicken/" + (chicken-binary-version chicken) "/")) -(define* (setup-chicken-environment #:key inputs outputs #:allow-other-keys) - (setenv "CHICKEN_INSTALL_REPOSITORY" - (string-concatenate - ;; see TODO item about binary version above - (append (list (assoc-ref outputs "out") "/var/lib/chicken/11/") - (let ((oldenv (getenv "CHICKEN_INSTALL_REPOSITORY"))) - (if oldenv - (list ":" oldenv) - '()))))) - (setenv "CHICKEN_EGG_CACHE" (getcwd)) - #t) +(define (egg-lib-dir chicken outputs) + (string-append + (assoc-ref outputs "out") "/var/lib/chicken/" + (chicken-binary-version chicken) "/")) + +(define* (setup-chicken-environment #:key inputs outputs chicken #:allow-other-keys) + (let ((chickenlibdir (chicken-lib-dir chicken)) + (egglibdir (egg-lib-dir chicken outputs))) + (setenv "CHICKEN_INSTALL_REPOSITORY" + (string-concatenate + (append `(,egglibdir) + (let ((oldenv (getenv "CHICKEN_INSTALL_REPOSITORY"))) + (if oldenv (list ":" oldenv) '()))))) + (setenv "CHICKEN_INSTALL_PREFIX" (assoc-ref outputs "out")) + (setenv "CHICKEN_REPOSITORY_PATH" + (string-concatenate + (append `(,egglibdir ":" ,chickenlibdir) + (let ((oldenv (getenv "CHICKEN_REPOSITORY_PATH"))) + (if oldenv (list ":" oldenv) '()))))) + (setenv "CHICKEN_EGG_CACHE" (getcwd)) + #t)) ;; This is copied from go-build-system.scm so it could probably be simplified. ;; I used it because the source of the egg needs to be unpacked into a directory