From patchwork Fri Jun 18 16:09:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 30401 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 89DF127BC81; Fri, 18 Jun 2021 17:16:32 +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 19F3E27BC78 for ; Fri, 18 Jun 2021 17:16:32 +0100 (BST) Received: from localhost ([::1]:54028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luHAV-0003QC-5u for patchwork@mira.cbaines.net; Fri, 18 Jun 2021 12:16:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luH4F-0007K5-1L for guix-patches@gnu.org; Fri, 18 Jun 2021 12:10:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luH4E-0001Pt-MK for guix-patches@gnu.org; Fri, 18 Jun 2021 12:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1luH4E-0002oe-93 for guix-patches@gnu.org; Fri, 18 Jun 2021 12:10:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49025] [[PATCH v2 core-updates] 01/37] utils: Define target-linux? predicate. References: <419215938396207999184dafa43afaed6d7a0715.camel@telenet.be> In-Reply-To: <419215938396207999184dafa43afaed6d7a0715.camel@telenet.be> Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 18 Jun 2021 16:10: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 Cc: othacehe@gnu.org, Maxime Devos Received: via spool by 49025-submit@debbugs.gnu.org id=B49025.162403259710806 (code B ref 49025); Fri, 18 Jun 2021 16:10:02 +0000 Received: (at 49025) by debbugs.gnu.org; 18 Jun 2021 16:09:57 +0000 Received: from localhost ([127.0.0.1]:57683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luH49-0002oE-AG for submit@debbugs.gnu.org; Fri, 18 Jun 2021 12:09:57 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:49146) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luH47-0002o5-LN for 49025@debbugs.gnu.org; Fri, 18 Jun 2021 12:09:56 -0400 Received: from localhost.localdomain ([188.188.242.184]) by baptiste.telenet-ops.be with bizsmtp id Jg9t250053zRM2s01g9tHv; Fri, 18 Jun 2021 18:09:54 +0200 From: Maxime Devos Date: Fri, 18 Jun 2021 18:09:00 +0200 Message-Id: <20210618160936.18972-1-maximedevos@telenet.be> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1624032594; bh=KuxsCFQnj4ZbArXRFEqUpWBp+xjAPFA4gW0yO+6p0Uk=; h=From:To:Cc:Subject:Date:Reply-To; b=T01CmRzB5t3B0a+VAFnBuoxxuIRNNzvKJcJP80w2c1U4P7LyYDJ7IaV36t7jh6Q8w DW5KIAn+xLC6mSdtw1up+JQWMmn9rDWhfzM35heNxF+Iop2SpV2dVoztyBO+bOO600 qJFBOke9/ZRE/WP7EDx/KEJKrj46kg6B0BEjfuokftfXsqpFb2uCfwlbi3y6y4MCRH ixmTV7/HgBvJniIOSdxIiMeEVkyOgop8TN7d/ry8X12VTXGzyuPXLsodnVWQD8U6zI x4vCnLYSsP7hYiUDUEH2iH4SUYucRWZAcjRjhFEeU3p+4+9zo36bPT/UsJRqAko2Qd AeK9o4H9NEPzg== 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: 49025@debbugs.gnu.org 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))