From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id GJENEjK1kGO7fwAAbAwnHQ (envelope-from ) for ; Wed, 07 Dec 2022 16:45:54 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4N1cEjK1kGNxKgAA9RJhRA (envelope-from ) for ; Wed, 07 Dec 2022 16:45:54 +0100 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 CC18A388E4 for ; Wed, 7 Dec 2022 16:45:53 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2wbf-00036C-8Q; Wed, 07 Dec 2022 10:45:11 -0500 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 1p2wbX-00032G-So for guix-patches@gnu.org; Wed, 07 Dec 2022 10:45:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2wbW-0003dg-VD for guix-patches@gnu.org; Wed, 07 Dec 2022 10:45:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2wbW-00027X-ED for guix-patches@gnu.org; Wed, 07 Dec 2022 10:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59885] [PATCH] gnu: cross-base: Standardize API to use keyword arguments. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 07 Dec 2022 15:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59885 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59885@debbugs.gnu.org Cc: Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16704278868120 (code B ref -1); Wed, 07 Dec 2022 15:45:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Dec 2022 15:44:46 +0000 Received: from localhost ([127.0.0.1]:50783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2wbF-00026u-GZ for submit@debbugs.gnu.org; Wed, 07 Dec 2022 10:44:45 -0500 Received: from lists.gnu.org ([209.51.188.17]:41132) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2wbC-00026o-SG for submit@debbugs.gnu.org; Wed, 07 Dec 2022 10:44:43 -0500 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 1p2wbC-0002dN-IW for guix-patches@gnu.org; Wed, 07 Dec 2022 10:44:42 -0500 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2wbA-0003Vq-Ir for guix-patches@gnu.org; Wed, 07 Dec 2022 10:44:42 -0500 Received: by mail-qv1-xf32.google.com with SMTP id d13so12894965qvj.8 for ; Wed, 07 Dec 2022 07:44:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hGw2W7ppMahb9TuT9Noysto5Sx4s0mfVPGITLHKMT5Q=; b=F92q+IOjoFOraRQUz32NzseFk3wmFB+dhFnaps3w5l8kUF3AsGU9KVphtpLpDbzREI UMKQKK+9nXE5cNOvoEPAkCD2qx0bXCjy9624jgOPStMs5t1clZYfkAcztKBk6JWRHhQc mMaW7vOqcVPy1YyEvDPha7RiNsKNs4Pm0XTHoCnxywdC+L1WtaUwSciNkYMmHejA76HP jbec0NtIarvCbsMH/oNkQSqTc1mFiUYEwn6VcGNtoO8sDBqxom+GGWAbfP2wRhTmcQYi O9dDoZtmk0EPoTLui6CZEcY138fFfjrG6/YK017H94/iBCLnzcBV5D/aQWEySpJGplNd kwGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hGw2W7ppMahb9TuT9Noysto5Sx4s0mfVPGITLHKMT5Q=; b=7xzSBbcZpRtUqOWzPsIeRrgoE1560/XWulu7hAy2Gj4vb1opHrMtoA6BxSP6ZMyP8Q g2R4mWhkAWdBzz+Mibh4ihq8dRpYYhHBiHWMHRDlnr0sM5ZgJL/lAb9M7loa2cIE0ZJ1 V/iH0h9QUc7nxZateimWj4Uj+mefvhhQ0SpbX1vC2mSTHyPzZR4zl9hXGgIfdmXBbiIt b5M4iUyP/UMe1YcOqdqTiIPBRXL+g7SbqSPXq4cNOgPTU+DpIWal+ksdAOUYD90Rq2kR I/EY6Co0HH9RmKAgh7Nwjj0Yf/H080OWo8N2f9zBXwiayuM651aBSZ1mnWFURCRqjbc7 E9pQ== X-Gm-Message-State: ANoB5pmd8lEmTFgdlla7X1ioCDuUv0fBclFHLBpifsmmsCKEwpubxODA yLoxzLmYC+2dR/YebiMLPWJMMWEtTVg= X-Google-Smtp-Source: AA0mqf7s9RbbfXfchh4Vfeufc3PQqZw6LKZhUJL6NrXoTNU74zcas8/0v2Cph0M1tBgXskRcOKwn+Q== X-Received: by 2002:a05:6214:3312:b0:4c7:4896:eceb with SMTP id mo18-20020a056214331200b004c74896ecebmr921108qvb.21.1670427878984; Wed, 07 Dec 2022 07:44:38 -0800 (PST) Received: from localhost.localdomain (dsl-205-233-124-140.b2b2c.ca. [205.233.124.140]) by smtp.gmail.com with ESMTPSA id v13-20020a05620a0f0d00b006fb8239db65sm17736176qkl.43.2022.12.07.07.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 07:44:38 -0800 (PST) From: Maxim Cournoyer Date: Wed, 7 Dec 2022 10:44:33 -0500 Message-Id: <20221207154433.17992-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qv1-xf32.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+larch=yhetil.org@gnu.org 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=1670427953; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=hGw2W7ppMahb9TuT9Noysto5Sx4s0mfVPGITLHKMT5Q=; b=eCxQkorfSaFyNZkwpvLdKwUTz4uhPiap0FcTprzXO+1+WTAx3ldhuw/3kEiM8wgN/oaSp6 NnFyKS5xsMY+oteF9G4oVXUqwMNuQ3y5Y7vgm/OAc0JbGUHqSGeXV1pZsgy/fCPWtE1+XW 0elBUPJsPAw3M7wQ3956mvhX7P0uCLfezWtzFPN8PXl0HjScH5d//6rbIqMDYnUSbBPFDF tRYGnzw46dwZJaCevpjclzMKakD755cw9FwD1FBwQLjJqAwg0OH8y75IZyiCpvarYjNso0 ESkVLeM4KROgscbtg4yQB6JU+8nqQqPBRHJ6ZXz/Wco4BSYgWSPHHNQ5B0jUmg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1670427953; a=rsa-sha256; cv=none; b=UrKA4gd0V81xPKJ7tKJ8LwNw1vLp+wbuFia0Gtj8YHrTZsaw9THnb33gzPkQb2RFJVpcxn 5Iu5P+u5XSi28fIy9WfhM+yuCXGOp7Sv6UrFi6pnCIsY9ZylrJtetdJtVuR1+3/wrlvMA2 3bfFpwKUgtGBrhN45gb+4dQOL+v7nrEc1FvQA7ivhup7GN11gPNDURMt+RTQY6RGWrWEIV jucShJF2Y4JiN+4OXq65omuG6f/WI6mFwG90b7QarqKBz2YsMeWCPQqp2ZWNZOTPi2uX/5 dS9llGa/KGaWM6gjf3qXFV5oQJHKY7dWmzcF/zN9OuU0CbkJig5wAxuw5IsRZg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=F92q+IOj; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: 7.04 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=F92q+IOj; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: CC18A388E4 X-Spam-Score: 7.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: tsO3yymfp1ev This makes it possible to invoke the procedures with a single or fewer optional arguments. * gnu/packages/cross-base.scm (contains-keyword?): New procedure. (cross-binutils): Dispatch to either... (cross-binutils/deprecated): ... this renamed procedure or ... (cross-binutils*): ... this new procedure. (cross-kernel-headers, cross-libc/deprecated): Likewise. --- gnu/packages/cross-base.scm | 74 +++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 12 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 44c1bb0ef2..add9a2f901 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -7,6 +7,7 @@ ;;; Copyright © 2019, 2020, 2021 Marius Bakke ;;; Copyright © 2019 Carl Dong ;;; Copyright © 2020 Mathieu Othacehe +;;; Copyright © 2022 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -32,7 +33,9 @@ (define-module (gnu packages cross-base) #:use-module (gnu packages mingw) #:use-module (guix platform) #:use-module (guix packages) + #:use-module (guix diagnostics) #:use-module (guix download) + #:use-module (guix i18n) #:use-module (guix utils) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) @@ -74,7 +77,20 @@ (define (cross p target) `(cons ,(string-append "--target=" target) ,flags)))))) -(define* (cross-binutils target #:optional (binutils binutils)) +(define (contains-keyword? args) + "Check if ARGS contains a keyword object." + (find keyword? args)) + +(define* (cross-binutils . args) + (if (or (= (length args) 1) (contains-keyword? args)) + (apply cross-binutils* args) + (apply cross-binutils/deprecated args))) + +(define* (cross-binutils/deprecated target #:optional (binutils binutils)) + (warning (G_ "'cross-binutils' must be used with keyword arguments~%")) + (cross-binutils* target #:binutils binutils)) + +(define* (cross-binutils* target #:key (binutils binutils)) "Return a cross-Binutils for TARGET using BINUTILS." (let ((binutils (package (inherit binutils) @@ -333,11 +349,27 @@ (define* (cross-gcc target %gcc-cross-include-paths))) (native-search-paths '()))) -(define* (cross-kernel-headers target - #:optional - (linux-headers linux-libre-headers) - (xgcc (cross-gcc target)) - (xbinutils (cross-binutils target))) +(define* (cross-kernel-headers . args) + (if (or (= (length args) 1) (contains-keyword? args)) + (apply cross-kernel-headers* args) + (apply cross-kernel-headers/deprecated args))) + +(define* (cross-kernel-headers/deprecated target + #:optional + (linux-headers linux-libre-headers) + (xgcc (cross-gcc target)) + (xbinutils (cross-binutils target))) + (warning (G_ "'cross-kernel-headers' must be used with keyword arguments~%")) + (cross-kernel-headers* target + #:linux-headers linux-headers + #:xgcc xgcc + #:xbinutils xbinutils)) + +(define* (cross-kernel-headers* target + #:key + (linux-headers linux-libre-headers) + (xgcc (cross-gcc target)) + (xbinutils (cross-binutils target))) "Return headers depending on TARGET." (define xlinux-headers @@ -491,12 +523,30 @@ (define xhurd-core-headers ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers) (_ xlinux-headers))) -(define* (cross-libc target - #:optional - (libc glibc) - (xgcc (cross-gcc target)) - (xbinutils (cross-binutils target)) - (xheaders (cross-kernel-headers target))) +(define* (cross-libc . args) + (if (or (= (length args) 1) (contains-keyword? args)) + (apply cross-libc* args) + (apply cross-libc/deprecated args))) + +(define* (cross-libc/deprecated target + #:optional + (libc glibc) + (xgcc (cross-gcc target)) + (xbinutils (cross-binutils target)) + (xheaders (cross-kernel-headers target))) + (warning (G_ "'cross-libc' must be used with keyword arguments~%")) + (cross-libc* target + #:libc libc + #:xgcc xgcc + #:xbinutils xbinutils + #:xheaders xheaders)) + +(define* (cross-libc* target + #:key + (libc glibc) + (xgcc (cross-gcc target)) + (xbinutils (cross-binutils target)) + (xheaders (cross-kernel-headers target))) "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS and the cross tool chain." (if (target-mingw? target) base-commit: dfc6957a5af7d179d4618eb19d4f555c519bc6f2 prerequisite-patch-id: 660177fb9eee55d11983ea9360c072730d0d21a5 prerequisite-patch-id: 776778c03bce9b7ad3ab94a120f42b764c00fcae prerequisite-patch-id: eeb2523a77c9c422a5785549dbd29ec0220118d7 prerequisite-patch-id: fd4074fb4cf068ccac3122c19138f098a610542a -- 2.38.1