From patchwork Mon Jun 14 15:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 30262 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 003F027BC81; Mon, 14 Jun 2021 17:01:23 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9CB6327BC78 for ; Mon, 14 Jun 2021 17:01:23 +0100 (BST) Received: from localhost ([::1]:38300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsp1e-0000tg-J1 for patchwork@mira.cbaines.net; Mon, 14 Jun 2021 12:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsof5-0008Jh-31 for guix-patches@gnu.org; Mon, 14 Jun 2021 11:38:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35999) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsof4-00077b-PH for guix-patches@gnu.org; Mon, 14 Jun 2021 11:38:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lsof4-0004Di-Nj for guix-patches@gnu.org; Mon, 14 Jun 2021 11:38:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49025] [PATCH core-updates 01/37] utils: Define target-linux? predicate. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 14 Jun 2021 15:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49025 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49025@debbugs.gnu.org Received: via spool by 49025-submit@debbugs.gnu.org id=B49025.162368503916035 (code B ref 49025); Mon, 14 Jun 2021 15:38:02 +0000 Received: (at 49025) by debbugs.gnu.org; 14 Jun 2021 15:37:19 +0000 Received: from localhost ([127.0.0.1]:47503 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsoeN-0004AZ-2R for submit@debbugs.gnu.org; Mon, 14 Jun 2021 11:37:19 -0400 Received: from michel.telenet-ops.be ([195.130.137.88]:41494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsoeL-0004AR-Gm for 49025@debbugs.gnu.org; Mon, 14 Jun 2021 11:37:18 -0400 Received: from butterfly.local ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by michel.telenet-ops.be with bizsmtp id H3dG250020mfAB4063dGr2; Mon, 14 Jun 2021 17:37:16 +0200 Message-ID: <1006ad56f7750b41a6566edc2310105b80434aef.camel@telenet.be> From: Maxime Devos Date: Mon, 14 Jun 2021 17:37:16 +0200 In-Reply-To: References: User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1623685036; bh=O3dLFRNgrcLOgQ05ElriE16zWpQ323uQya/Y3etXMcg=; h=Subject:From:To:Date:In-Reply-To:References; b=Y0PBhrUQRLo5Fx/mqii8n9z21RomunWGj/BeBWtt1tx24htP+WrFhBqi2zieNnQk8 1IEcfYBxZFDfoR53uYrf8NqLjkMWmY1ev1pCw/bi088qxeUn63BSRdptRKgFC0BerD QuuwDPRlNzwnSx7pFE+WOkrn2Dvpxo+fJehtm1e5zkZmKW0tsnNEyCsp9pKmIOppsl VI4YAanrSV0wkpUAVWDmoxPobGtmMBxKEnNWuWcOtZRCYvF2Sq0JVYxBzp+5ejS/fc e1Z2eq2odUHFLjmFJZNeD5gnakgdwdX/5meObBNq0WNI5sgswTzbZ+q4DMl80ajAxJ 2ZdoMt5dblG6w== 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/utils.scm (target-linux?): New predicate. * tests/utils.scm ("target-linux?"): Test it. ("target-mingw?"): Also test ‘target-mingw?’. --- guix/utils.scm | 6 ++++++ tests/utils.scm | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/guix/utils.scm b/guix/utils.scm index 19990ceb8a..4ff2602e23 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2020 Maxim Cournoyer ;;; Copyright © 2021 Simon Tournier ;;; Copyright © 2021 Chris Marusich +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -81,6 +82,7 @@ %current-system %current-target-system package-name->name+version + target-linux? target-mingw? target-arm32? target-aarch64? @@ -543,6 +545,10 @@ a character other than '@'." (idx (values (substring spec 0 idx) (substring spec (1+ idx)))))) +(define* (target-linux? #:optional (target (or (%current-target-system) + (%current-system)))) + (string-contains target "linux")) + (define* (target-mingw? #:optional (target (%current-target-system))) (and target (string-suffix? "-mingw32" target))) diff --git a/tests/utils.scm b/tests/utils.scm index 7fcbb25552..80a0e669a4 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2016 Mathieu Lirzin ;;; Copyright © 2021 Simon Tournier +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -289,6 +290,22 @@ skip these tests." (string-closest "hello" '("kikoo" "helo" "hihihi" "halo")) (string-closest "hello" '("aaaaa" "12345" "hellohello" "h")))) +(test-equal "target-linux?" + '(#t #f #f #t) + (map (compose ->bool target-linux?) + '("i686-linux-gnu" "i686-w64-mingw32" + ;; Checking that "gnu" is present is not sufficient, + ;; as GNU/Hurd exists. + "i686-pc-gnu" + ;; Some targets have a suffix. + "arm-linux-gnueabihf"))) + +(test-equal "target-mingw?" + '(#f #f #t) + (map (compose ->bool target-mingw?) + '("i686-linux-gnu" "i686-pc-gnu" + "i686-w64-mingw32"))) + (test-end) (false-if-exception (delete-file temp-file))