From 29f5ecf463ce17152af83e3107f3e6ce3b13f298 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Mon, 29 Mar 2021 16:56:45 +0200 Subject: [PATCH 02/10] guix: build-system: gnu: Export canonicalize-reference. This procedure will be used in 'qt-build-system' and 'python-build-system' in a later patch. * guix/build-system/gnu.scm (gnu-build)[canonicalize-reference]: Extract to ... (canonicalize-reference): ... here, and document it. (gnu-cross-build)[canonicalize-reference]: Extract to ... (canonicalize-cross-reference): ... here, and document it. --- guix/build-system/gnu.scm | 77 +++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index 6b481ad45c..cf334292be 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,6 +26,7 @@ #:use-module (guix build-system) #:use-module (guix packages) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (ice-9 match) #:export (%gnu-build-system-modules gnu-build @@ -36,7 +38,9 @@ static-libgcc-package static-package dist-package - package-with-restricted-references)) + package-with-restricted-references + canonicalize-reference + canonicalize-cross-reference)) ;; Commentary: ;; @@ -324,6 +328,43 @@ standard packages used as implicit inputs of the GNU build system." ;; Regexp matching license files. "^(COPYING.*|LICEN[CS]E.*|[Ll]icen[cs]e.*|Copy[Rr]ight(\\.(txt|md))?)$") +(define (canonicalize-reference store system reference) + "Return as a string the store location where the ungrafted +package referred to by REFERENCE and compiled for SYSTEM will +end up. REFERENCE is either a package object or a list of a +package object and an output. Alternatively, REFERENCE can +simply be a string, in which case this string will be returned +as-is." + (match reference + ((? package? p) + (derivation->output-path (package-derivation store p system + #:graft? #f))) + (((? package? p) output) + (derivation->output-path (package-derivation store p system + #:graft? #f) + output)) + ((? string? output) + output))) + +;; XXX why are grafts *not* disabled here, while they are +;; in canonicalize-reference? +(define (canonicalize-cross-reference store target system reference) + "Return as a string the store location where the package +referred to by REFERENCE and cross-compiled on SYSTEM for +TARGET will end up. REFERENCE is either a package object or a +list of a package object and an output. Alternatively, REFERENCE +can simply be a string, in which case this string will be returned." + (match reference + ((? package? p) + (derivation->output-path (package-cross-derivation store p + target system))) + (((? package? p) output) + (derivation->output-path (package-cross-derivation store p + target system) + output)) + ((? string? output) + output))) + (define* (gnu-build store name input-drvs #:key (guile #f) (outputs '("out")) @@ -370,17 +411,8 @@ returned derivations, or whether they should always build it locally. ALLOWED-REFERENCES can be either #f, or a list of packages that the outputs are allowed to refer to. Likewise for DISALLOWED-REFERENCES, which lists packages that must not be referenced." - (define canonicalize-reference - (match-lambda - ((? package? p) - (derivation->output-path (package-derivation store p system - #:graft? #f))) - (((? package? p) output) - (derivation->output-path (package-derivation store p system - #:graft? #f) - output)) - ((? string? output) - output))) + (define specialized-canonicalize-reference + (cut canonicalize-reference store system <>)) (define builder `(begin @@ -433,11 +465,11 @@ packages that must not be referenced." #:allowed-references (and allowed-references - (map canonicalize-reference + (map specialized-canonicalize-reference allowed-references)) #:disallowed-references (and disallowed-references - (map canonicalize-reference + (map specialized-canonicalize-reference disallowed-references)) #:guile-for-build guile-for-build)) @@ -510,17 +542,8 @@ is one of `host' or `target'." "Cross-build NAME for TARGET, where TARGET is a GNU triplet. INPUTS are cross-built inputs, and NATIVE-INPUTS are inputs that run on the build platform." - (define canonicalize-reference - (match-lambda - ((? package? p) - (derivation->output-path (package-cross-derivation store p - target system))) - (((? package? p) output) - (derivation->output-path (package-cross-derivation store p - target system) - output)) - ((? string? output) - output))) + (define specialized-canonicalize-reference + (cut canonicalize-cross-reference store target system <>)) (define builder `(begin @@ -599,11 +622,11 @@ platform." #:allowed-references (and allowed-references - (map canonicalize-reference + (map specialized-canonicalize-reference allowed-references)) #:disallowed-references (and disallowed-references - (map canonicalize-reference + (map specialized-canonicalize-reference disallowed-references)) #:guile-for-build guile-for-build)) -- 2.31.1