gnu: make-crust-package: Memoize.

* gnu/packages/firmware.scm (make-crust-package): Use mlambda.

Change-Id: I2d916b96bc650f3731a69505e086cf8f8f470809
This commit is contained in:
Jean-Pierre De Jesus DIAZ 2024-01-19 14:54:44 +01:00 committed by Mathieu Othacehe
parent ae7da5cbf0
commit e5a00639aa
No known key found for this signature in database
GPG key ID: 8354763531769CA6

View file

@ -1197,81 +1197,82 @@ such as:
;; Adding debug symbols causes the size to exceed limits. ;; Adding debug symbols causes the size to exceed limits.
#~(delete "DEBUG=1" #$flags))))))) #~(delete "DEBUG=1" #$flags)))))))
(define (make-crust-package platform) (define make-crust-package
(package (mlambda (platform)
(name (string-append "crust-" (package
(string-replace-substring platform "_" "-"))) (name (string-append "crust-"
(version "0.5") (string-replace-substring platform "_" "-")))
(source (version "0.5")
(origin (source
(method git-fetch) (origin
(uri (git-reference (method git-fetch)
;; There are only GitHub generated release snapshots. (uri (git-reference
(url "https://github.com/crust-firmware/crust") ;; There are only GitHub generated release snapshots.
(commit (string-append "v" version)))) (url "https://github.com/crust-firmware/crust")
(file-name (git-file-name "crust" version)) (commit (string-append "v" version))))
(sha256 (file-name (git-file-name "crust" version))
(base32 (sha256
"0xgbbhifg3miwd3yp6jq9kp7nqgz5gzy00w95vba45j8jk5vjvvz")))) (base32
(build-system gnu-build-system) "0xgbbhifg3miwd3yp6jq9kp7nqgz5gzy00w95vba45j8jk5vjvvz"))))
(arguments (build-system gnu-build-system)
(list (arguments
#:tests? #f ;no test suite (list
#:make-flags #:tests? #f ;no test suite
(let ((triplet-without-vendor #:make-flags
(and (%current-target-system) (let ((triplet-without-vendor
;; TODO: Is there a use case for allowing this? (and (%current-target-system)
(not (target-avr?)) ;; TODO: Is there a use case for allowing this?
(match (string-split (nix-system->gnu-triplet (not (target-avr?))
(%current-target-system)) #\-) (match (string-split (nix-system->gnu-triplet
((arch vendor os ..1) (%current-target-system)) #\-)
(string-join `(,arch ,@os) "-")))))) ((arch vendor os ..1)
#~(list "CROSS_COMPILE=or1k-elf-" (string-join `(,arch ,@os) "-"))))))
"V=1" #~(list "CROSS_COMPILE=or1k-elf-"
#$@(if triplet-without-vendor "V=1"
;; We are cross-compiling the tools, intended to be #$@(if triplet-without-vendor
;; executable for the target system. ;; We are cross-compiling the tools, intended to be
(list (string-append "HOSTAR=" triplet-without-vendor ;; executable for the target system.
"-ar") (list (string-append "HOSTAR=" triplet-without-vendor
(string-append "HOSTCC=" triplet-without-vendor "-ar")
"-gcc")) (string-append "HOSTCC=" triplet-without-vendor
;; Not cross-compiling. "-gcc"))
(list "HOSTAR=ar" ;; Not cross-compiling.
"HOSTCC=gcc")) (list "HOSTAR=ar"
"LEX=flex")) "HOSTCC=gcc"))
#:phases "LEX=flex"))
#~(modify-phases %standard-phases #:phases
(add-after 'unpack 'do-not-build-tests #~(modify-phases %standard-phases
(lambda _ (add-after 'unpack 'do-not-build-tests
;; Attempting to build the tools test binary on a non-aarch64 (lambda _
;; architecture fails with: "No cache cleaning implementation ;; Attempting to build the tools test binary on a non-aarch64
;; available for this architecture". Avoid building it (see: ;; architecture fails with: "No cache cleaning implementation
;; https://github.com/crust-firmware/crust/issues/182). ;; available for this architecture". Avoid building it (see:
(substitute* "tools/Makefile" ;; https://github.com/crust-firmware/crust/issues/182).
(("tools-y \\+= test") "")))) (substitute* "tools/Makefile"
(delete 'configure) (("tools-y \\+= test") ""))))
(add-before 'build 'defconfig (delete 'configure)
(lambda* (#:key make-flags #:allow-other-keys) (add-before 'build 'defconfig
(let ((config-name (string-append #$platform "_defconfig"))) (lambda* (#:key make-flags #:allow-other-keys)
(apply invoke "make" (cons config-name make-flags))))) (let ((config-name (string-append #$platform "_defconfig")))
(replace 'install (apply invoke "make" (cons config-name make-flags)))))
(lambda _ (replace 'install
(for-each (lambda (file) (lambda _
(install-file file (string-append #$output (for-each (lambda (file)
"/libexec"))) (install-file file (string-append #$output
(find-files "." "(scp\\.bin|\\.config)$")) "/libexec")))
(install-file "build/tools/load" (find-files "." "(scp\\.bin|\\.config)$"))
(string-append #$output "/bin"))))))) (install-file "build/tools/load"
;; The firmware is cross-compiled using a "bare bones" compiler (no libc). (string-append #$output "/bin")))))))
;; Use our own tool chain for that. ;; The firmware is cross-compiled using a "bare bones" compiler (no libc).
(native-inputs ;; Use our own tool chain for that.
(list bison (native-inputs
(cross-gcc "or1k-elf") (list bison
(cross-binutils "or1k-elf") (cross-gcc "or1k-elf")
flex)) (cross-binutils "or1k-elf")
(home-page "https://github.com/crust-firmware/crust") flex))
(synopsis "Firmware for Allwinner sunxi SoCs") (home-page "https://github.com/crust-firmware/crust")
(description "Crust improves battery life and thermal performance by (synopsis "Firmware for Allwinner sunxi SoCs")
(description "Crust improves battery life and thermal performance by
implementing a deep sleep state. During deep sleep, the CPU cores, the DRAM implementing a deep sleep state. During deep sleep, the CPU cores, the DRAM
controller, and most onboard peripherals are powered down, reducing power controller, and most onboard peripherals are powered down, reducing power
consumption by 80% or more compared to an idle device. On boards without a consumption by 80% or more compared to an idle device. On boards without a
@ -1280,8 +1281,8 @@ device. For this to work, Crust runs outside the main CPU and DRAM, on a
dedicated always-on microprocessor called a System Control Processor (SCP). dedicated always-on microprocessor called a System Control Processor (SCP).
Crust is designed to run on a specific SCP implementation, Allwinner's Crust is designed to run on a specific SCP implementation, Allwinner's
AR100.") AR100.")
;; Most files are dual-licensed "BSD-3 OR GPL2", a few are GPL2 only. ;; Most files are dual-licensed "BSD-3 OR GPL2", a few are GPL2 only.
(license (list license:bsd-3 license:gpl2)))) (license (list license:bsd-3 license:gpl2)))))
(define-public crust-pinebook (define-public crust-pinebook
(make-crust-package "pinebook")) (make-crust-package "pinebook"))