From patchwork Mon May 2 11:18:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 39053 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 DA25B27BBEA; Mon, 2 May 2022 12:29:11 +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=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable 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 911B227BBE9 for ; Mon, 2 May 2022 12:29:11 +0100 (BST) Received: from localhost ([::1]:40564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlUEo-0007jP-Ou for patchwork@mira.cbaines.net; Mon, 02 May 2022 07:29:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlU63-0001gc-2H for guix-patches@gnu.org; Mon, 02 May 2022 07:20:21 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlU5z-0005Zu-Ge for guix-patches@gnu.org; Mon, 02 May 2022 07:20:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nlU5z-0005jZ-BX for guix-patches@gnu.org; Mon, 02 May 2022 07:20:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55220] [PATCH 2/4] platform: Add discovery support. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 02 May 2022 11:20:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55220 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55220@debbugs.gnu.org Cc: Mathieu Othacehe Received: via spool by 55220-submit@debbugs.gnu.org id=B55220.165149038321980 (code B ref 55220); Mon, 02 May 2022 11:20:03 +0000 Received: (at 55220) by debbugs.gnu.org; 2 May 2022 11:19:43 +0000 Received: from localhost ([127.0.0.1]:35014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlU5f-0005iP-5k for submit@debbugs.gnu.org; Mon, 02 May 2022 07:19:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlU5d-0005iB-4u for 55220@debbugs.gnu.org; Mon, 02 May 2022 07:19:41 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlU5X-0005YR-Uq for 55220@debbugs.gnu.org; Mon, 02 May 2022 07:19:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=FZ4gFvIl1e/fnCuOMWnJZYiycebBzWcidNNNtN37/Pc=; b=b5YVHvl2zcS6+jn5/lyR Rgt1jwNdg79w+1PJcfCN5Urac0t1w6HqCKvQWHDuGkMTZ7JWLq5W5bnG0C0SJmgrqytlUHSwqLdbc eS1+BKyuv97XWN1/fUgNurZNvgeo1btnTKe7pCZ0Ga4cL2ojv5a2endPfnI9G+xaNSg7WeHV/PMbp MbiwqDGj7h5CnRW0mHwIMftgwwyBvtR9ExARszFT/rqjoB4WyXdu3Ht2YsaD3cwRP0lqP1Dov+E0k 5sgx5fKf1S3/orApkk+Jps74TL5Mr7RRX5AmFyuCZVSrhhPNnMA+6RkaidvpS97pSy5uUqS4cAc81 Jprg5wVlAwJhNA==; Received: from 71.125.192.77.rev.sfr.net ([77.192.125.71]:33768 helo=localhost.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlU5L-0004xO-0o; Mon, 02 May 2022 07:19:26 -0400 From: Mathieu Othacehe Date: Mon, 2 May 2022 13:18:57 +0200 Message-Id: <20220502111859.13605-2-othacehe@gnu.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220502111859.13605-1-othacehe@gnu.org> References: <20220502111859.13605-1-othacehe@gnu.org> 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: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/platform.scm (platform-modules, systems, targets): New procedures. (%platforms): New variable. Signed-off-by: Mathieu Othacehe --- gnu/platform.scm | 62 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/gnu/platform.scm b/gnu/platform.scm index bb6519c71a..481467086a 100644 --- a/gnu/platform.scm +++ b/gnu/platform.scm @@ -17,22 +17,78 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu platform) + #:use-module (guix discovery) #:use-module (guix records) + #:use-module (guix ui) + #:use-module (srfi srfi-1) #:export (platform platform? platform-target platform-system - platform-linux-architecture)) + platform-linux-architecture + + platform-modules + %platforms + + systems + targets)) ;;; ;;; Platform record. ;;; -;; Description of a platform supported by the GNU system. +;; Description of a platform supported by GNU Guix. +;; +;; The 'target' field must be a valid GNU triplet as defined here: +;; https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/Specifying-Target-Triplets.html. +;; It is used for cross-compilation purposes. +;; +;; The 'system' field is the name of the corresponding system as defined in +;; the (gnu packages bootstrap) module. It can be for instance +;; "aarch64-linux" or "armhf-linux". It is used to emulate a different host +;; architecture, for instance i686-linux on x86_64-linux-gnu, or armhf-linux +;; on x86_64-linux, using the QEMU binfmt transparent emulation mechanism. +;; +;; The 'linux-architecture' is only relevant if the kernel is Linux. In that +;; case, it corresponds to the ARCH variable used when building Linux. (define-record-type* platform make-platform platform? (target platform-target) ;"x86_64-linux-gnu" (system platform-system) ;"x86_64-linux" - (linux-architecture platform-linux-architecture ;"amd64" + (linux-architecture platform-linux-architecture ;"x86" (default #f))) + +;;; +;;; Platforms. +;;; + +(define (platform-modules) + "Return the list of platform modules." + (all-modules (map (lambda (entry) + `(,entry . "gnu/platforms")) + %load-path) + #:warn warn-about-load-error)) + +(define %platforms + ;; The list of publically-known platforms. + (delay (fold-module-public-variables (lambda (obj result) + (if (platform? obj) + (cons obj result) + result)) + '() + (platform-modules)))) + + +;;; +;;; Systems & Targets. +;;; + +(define (systems) + "Return the list of supported systems." + (delete-duplicates + (filter-map platform-system (force %platforms)))) + +(define (targets) + "Return the list of supported targets." + (map platform-target (force %platforms)))