unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 60224@debbugs.gnu.org
Cc: rekado@elephly.net, Maxim Cournoyer <maxim.cournoyer@gmail.com>,
	vagrant@reproducible-builds.org
Subject: [bug#60224] [PATCH v4 11/12] gnu: make-arm-trusted-firmware: Simplify build.
Date: Wed, 11 Jan 2023 15:44:32 -0500	[thread overview]
Message-ID: <20230111204433.15305-11-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20230111204433.15305-1-maxim.cournoyer@gmail.com>

Reuse knowledge from recent U-Boot modifications to streamline the package
definition.

* gnu/packages/firmware.scm (make-arm-trusted-firmware): Change optional
argument ARCH to keyword TRIPLET.  Default to aarch64-linux-gnu.
[arguments]: Use gexps.  Add a #:target argument.  Streamline how the
CROSS_COMPILE make flag is computed.
[native-inputs]: Delete field.

---

Changes in v4:
- New commit

 gnu/packages/firmware.scm | 116 +++++++++++++++++---------------------
 1 file changed, 52 insertions(+), 64 deletions(-)

diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index f08d59752a..bd20ee81d9 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -8,7 +8,7 @@
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
-;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -944,70 +944,58 @@ (define-public ovmf-arm
                              (string-append fmw "/ovmf_arm.bin")))))))))
     (supported-systems %supported-systems)))
 
-(define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
-  (package
-    (name (string-append "arm-trusted-firmware-" platform))
-    (version "2.8")
-    (source
-      (origin
-        (method git-fetch)
-        (uri (git-reference
+(define* (make-arm-trusted-firmware platform
+                                    #:key (triplet "aarch64-linux-gnu"))
+  (let ((native-build? (lambda ()
+                         ;; Note: %current-system is a *triplet*, unlike its
+                         ;; name would suggest.
+                         (or (not triplet) ;disable cross-compilation
+                             (string=? (%current-system)
+                                       (gnu-triplet->nix-system triplet))))))
+    (package
+      (name (string-append "arm-trusted-firmware-" platform))
+      (version "2.8")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
                ;; There are only GitHub generated release snapshots.
                (url "https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/")
                (commit (string-append "v" version))))
-        (file-name (git-file-name "arm-trusted-firmware" version))
-       (sha256
-        (base32
-         "0grq3fgxi9xhcljnhwlxjvdghyz15gaq50raw41xy4lm8rkmnzp3"))
-       (snippet
-        #~(begin
-            (use-modules (guix build utils))
-            ;; Remove binary blobs which do not contain source or proper license.
-            (for-each (lambda (file)
-                        (delete-file file))
-                      (find-files "." "\\.bin$"))))))
-    (build-system gnu-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (delete 'configure) ; no configure script
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out"))
-                   (bin (find-files "." "\\.(bin|elf)$")))
-               (for-each
-                 (lambda (file)
-                   (install-file file out))
-                 bin)))))
-       #:make-flags (list (string-append "PLAT=" ,platform)
-                          ,@(if (and (not (string-prefix? "aarch64"
-                                                          (%current-system)))
-                                     (string-prefix? "aarch64" arch))
-                              `("CROSS_COMPILE=aarch64-linux-gnu-")
-                              '())
-                          ,@(if (and (not (string-prefix? "armhf"
-                                                          (%current-system)))
-                                     (string-prefix? "armhf" arch))
-                              `("CROSS_COMPILE=arm-linux-gnueabihf-")
-                              '())
-                          "DEBUG=1")
-       #:tests? #f)) ; no tests
-    (native-inputs
-     (let ((system (%current-system)))
-       (cond
-        ((and (not (string-prefix? "aarch64" system))
-              (string-prefix? "aarch64" arch))
-         (list (cross-gcc "aarch64-linux-gnu")
-               (cross-binutils "aarch64-linux-gnu")))
-        ((and (not (string-prefix? "armhf" system))
-              (string-prefix? "armhf" arch))
-         (list (cross-gcc "arm-linux-gnueabihf")
-               (cross-binutils "arm-linux-gnueabihf")))
-        (else '()))))
-    (home-page "https://www.trustedfirmware.org/")
-    (synopsis "Implementation of \"secure world software\"")
-    (description
-     "ARM Trusted Firmware provides a reference implementation of secure world
+         (file-name (git-file-name "arm-trusted-firmware" version))
+         (sha256
+          (base32
+           "0grq3fgxi9xhcljnhwlxjvdghyz15gaq50raw41xy4lm8rkmnzp3"))
+         (snippet
+          #~(begin
+              (use-modules (guix build utils))
+              ;; Remove binary blobs which do not contain source or proper
+              ;; license.
+              (for-each (lambda (file)
+                          (delete-file file))
+                        (find-files "." "\\.bin$"))))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:target (and (not (native-build?)) triplet)
+        #:phases
+        #~(modify-phases %standard-phases
+            (delete 'configure)         ;no configure script
+            (replace 'install
+              (lambda _
+                (for-each (lambda (file)
+                            (install-file file #$output))
+                          (find-files "." "\\.(bin|elf)$")))))
+        #:make-flags #~(list (string-append "PLAT=" #$platform)
+                             #$@(if (not (native-build?))
+                                    (list (string-append "CROSS_COMPILE=" triplet "-"))
+                                    '())
+                             "DEBUG=1")
+        #:tests? #f))                   ;no test suite
+      (home-page "https://www.trustedfirmware.org/")
+      (synopsis "Implementation of \"secure world software\"")
+      (description
+       "ARM Trusted Firmware provides a reference implementation of secure world
 software for ARMv7A and ARMv8-A, including a Secure Monitor executing at
 @dfn{Exception Level 3} (EL3).  It implements various ARM interface standards,
 such as:
@@ -1018,8 +1006,8 @@ (define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
 @item System Control and Management Interface
 @item Software Delegated Exception Interface (SDEI)
 @end enumerate\n")
-    (license (list license:bsd-3
-                   license:bsd-2)))) ; libfdt
+      (license (list license:bsd-3
+                     license:bsd-2))))) ; libfdt
 
 (define-public arm-trusted-firmware-sun50i-a64
   (let ((base (make-arm-trusted-firmware "sun50i_a64")))
-- 
2.38.1





  parent reply	other threads:[~2023-01-11 20:47 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20 16:50 [bug#60224] [PATCH 0/9] Improvements to our u-boot tooling Maxim Cournoyer
2022-12-20 18:34 ` [bug#60224] [PATCH 1/9] gnu: make-u-boot-package: Add a u-boot argument and use gexps Maxim Cournoyer
2022-12-20 18:34   ` [bug#60224] [PATCH 2/9] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
2022-12-20 18:34   ` [bug#60224] [PATCH 3/9] gnu: make-uboot-package: Simplify build Maxim Cournoyer
2022-12-20 18:34   ` [bug#60224] [PATCH 4/9] gnu: u-boot-pinebook-pro-rk3399: Remove input labels and use gexps Maxim Cournoyer
2022-12-20 18:34   ` [bug#60224] [PATCH 5/9] gnu: u-boot-firefly-rk3399: Use gexps and fix cross-build Maxim Cournoyer
2022-12-20 18:34   ` [bug#60224] [PATCH 6/9] gnu: make-u-boot-sunxi64-package: Use gexps and adjust file name Maxim Cournoyer
2022-12-20 18:34   ` [bug#60224] [PATCH 7/9] gnu: u-boot-rock64-rk3328: Fix build Maxim Cournoyer
2022-12-20 18:34   ` [bug#60224] [PATCH 8/9] gnu: u-boot-sifive-unmatched: Use gexps and remove inputs Maxim Cournoyer
2022-12-20 18:34   ` [bug#60224] [PATCH 9/9] gnu: u-boot-puma-rk3399: Use make-u-boot-sunxi64-package Maxim Cournoyer
2022-12-29 19:18 ` [bug#60224] [PATCH 0/9] Improvements to our u-boot tooling Ricardo Wurmus
2023-01-02  0:27   ` Maxim Cournoyer
2023-01-02  0:46 ` [bug#60224] [PATCH v3 01/11] gnu: make-u-boot-package: Add a u-boot argument and use gexps Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 02/11] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 03/11] gnu: make-uboot-package: Simplify build Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 04/11] gnu: make-u-boot-package: Allow disabling cross-compilation Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 05/11] gnu: u-boot-pinebook-pro-rk3399: Remove input labels and use gexps Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 06/11] gnu: u-boot-firefly-rk3399: Use gexps and fix cross-build Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 07/11] gnu: make-u-boot-sunxi64-package: Use gexps and adjust file name Maxim Cournoyer
2023-01-06 17:17     ` Vagrant Cascadian
2023-01-11 19:55       ` Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 08/11] gnu: u-boot-rock64-rk3328: Fix build Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 09/11] gnu: u-boot-sifive-unmatched: Use gexps and remove inputs Maxim Cournoyer
2023-01-02  0:46   ` [bug#60224] [PATCH v3 10/11] gnu: u-boot-puma-rk3399: Use make-u-boot-sunxi64-package Maxim Cournoyer
2023-01-06 17:09     ` Vagrant Cascadian
2023-01-02  0:46   ` [bug#60224] [PATCH v3 11/11] gnu: u-boot-rockpro64-rk3399: Fix build Maxim Cournoyer
2023-01-11 20:44 ` [bug#60224] [PATCH v4 01/12] gnu: make-u-boot-package: Add a u-boot argument and use gexps Maxim Cournoyer
2023-01-11 20:44   ` [bug#60224] [PATCH v4 02/12] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
2023-01-11 20:44   ` [bug#60224] [PATCH v4 03/12] gnu: make-uboot-package: Simplify build Maxim Cournoyer
2023-01-11 20:44   ` [bug#60224] [PATCH v4 04/12] gnu: make-u-boot-package: Allow disabling cross-compilation Maxim Cournoyer
2023-01-11 20:44   ` [bug#60224] [PATCH v4 05/12] gnu: u-boot-pinebook-pro-rk3399: Remove input labels and use gexps Maxim Cournoyer
2023-01-11 20:44   ` [bug#60224] [PATCH v4 06/12] gnu: u-boot-firefly-rk3399: Use gexps and fix cross-build Maxim Cournoyer
2023-01-11 20:44   ` [bug#60224] [PATCH v4 07/12] gnu: make-u-boot-sunxi64-package: Use gexps and adjust file name Maxim Cournoyer
2023-01-12 22:12     ` Vagrant Cascadian
2023-01-11 20:44   ` [bug#60224] [PATCH v4 08/12] gnu: u-boot-rock64-rk3328: Fix build Maxim Cournoyer
2023-01-11 20:44   ` [bug#60224] [PATCH v4 09/12] gnu: u-boot-sifive-unmatched: Use gexps and remove inputs Maxim Cournoyer
2023-01-11 20:44   ` [bug#60224] [PATCH v4 10/12] gnu: u-boot-rockpro64-rk3399: Fix build Maxim Cournoyer
2023-01-11 20:44   ` Maxim Cournoyer [this message]
2023-01-11 20:44   ` [bug#60224] [PATCH v4 12/12] gnu: u-boot-puma-rk3399: " Maxim Cournoyer
2023-01-16  3:25 ` [bug#60224] [PATCH v5 01/13] gnu: make-u-boot-package: Add a u-boot argument and use gexps Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 02/13] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 03/13] gnu: u-boot: Reduce the number of native inputs Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 04/13] gnu: make-uboot-package: Simplify build Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 05/13] gnu: make-u-boot-package: Allow disabling cross-compilation Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 06/13] gnu: u-boot-pinebook-pro-rk3399: Remove input labels and use gexps Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 07/13] gnu: u-boot-firefly-rk3399: Use gexps and fix build Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 08/13] gnu: make-u-boot-sunxi64-package: " Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 09/13] gnu: u-boot-rock64-rk3328: " Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 10/13] gnu: u-boot-sifive-unmatched: Use gexps and remove inputs labels Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 11/13] gnu: u-boot-rockpro64-rk3399: Use gexps and fix build Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 12/13] gnu: make-arm-trusted-firmware: Simplify build Maxim Cournoyer
2023-01-16  3:25   ` [bug#60224] [PATCH v5 13/13] gnu: u-boot-puma-rk3399: Use gexps and fix build Maxim Cournoyer
2023-01-19  2:10   ` bug#60224: [PATCH 0/9] Improvements to our u-boot tooling Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230111204433.15305-11-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=60224@debbugs.gnu.org \
    --cc=rekado@elephly.net \
    --cc=vagrant@reproducible-builds.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).