gnu: axoloti-patcher: Use G-expression.

* gnu/packages/axoloti.scm (axoloti-patcher)[arguments]: Use G-expression;
delete 'make-git-checkout-writable phase.

Change-Id: I4f9b98351f1752391211f1aed84d484184d32771
This commit is contained in:
Ricardo Wurmus 2024-01-30 22:44:09 +01:00
parent bed3a0b547
commit c2dc19aecc
No known key found for this signature in database
GPG key ID: 197A5888235FACAC

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017, 2019, 2020, 2021 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2016, 2017, 2019, 2020, 2021, 2024 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@ -18,6 +18,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages axoloti) (define-module (gnu packages axoloti)
#:use-module (guix gexp)
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
@ -218,8 +219,9 @@ (define-public axoloti-patcher
(name "axoloti-patcher") (name "axoloti-patcher")
(version (package-version axoloti-runtime)) (version (package-version axoloti-runtime))
(arguments (arguments
`(#:tests? #f ; no check target (list
#:modules ((guix build gnu-build-system) #:tests? #f ; no check target
#:modules '((guix build gnu-build-system)
((guix build ant-build-system) #:prefix ant:) ((guix build ant-build-system) #:prefix ant:)
(guix build utils) (guix build utils)
(srfi srfi-1) (srfi srfi-1)
@ -229,113 +231,107 @@ (define-public axoloti-patcher
(sxml simple) (sxml simple)
(sxml xpath) (sxml xpath)
(sxml transform)) (sxml transform))
#:imported-modules ((guix build ant-build-system) #:imported-modules `((guix build ant-build-system)
,@%gnu-build-system-modules) ,@%gnu-build-system-modules)
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'make-git-checkout-writable (delete 'configure)
(lambda _ (replace 'build
(for-each make-file-writable (find-files ".")) (lambda* (#:key inputs #:allow-other-keys)
#t)) (setenv "JAVA_HOME" (assoc-ref inputs "icedtea"))
(delete 'configure) ;; We want to use our own jar files instead of the pre-built
(replace 'build ;; stuff in lib. So we replace the zipfileset tags in the
(lambda* (#:key inputs #:allow-other-keys) ;; build.xml with new ones that reference our jars.
(setenv "JAVA_HOME" (assoc-ref inputs "icedtea")) (let* ((build.xml (with-input-from-file "build.xml"
;; We want to use our own jar files instead of the pre-built (lambda _
;; stuff in lib. So we replace the zipfileset tags in the (xml->sxml #:trim-whitespace? #t))))
;; build.xml with new ones that reference our jars. (jars (append-map (match-lambda
(let* ((build.xml (with-input-from-file "build.xml" (((? (cut string-prefix? "java-" <>)
(lambda _ label) . directory)
(xml->sxml #:trim-whitespace? #t)))) (find-files directory "\\.jar$"))
(jars (append-map (match-lambda (_ '()))
(((? (cut string-prefix? "java-" <>) inputs))
label) . directory) (classpath (string-join jars ":"))
(find-files directory "\\.jar$")) (fileset (map (lambda (jar)
(_ '())) `(zipfileset (@ (excludes "META-INF/*.SF")
inputs)) (src ,jar))))
(classpath (string-join jars ":")) jars)))
(fileset (map (lambda (jar) (call-with-output-file "build.xml"
`(zipfileset (@ (excludes "META-INF/*.SF") (lambda (port)
(src ,jar)))) (sxml->xml
jars))) (pre-post-order
(call-with-output-file "build.xml" build.xml
(lambda (port) `( ;; Remove all zipfileset tags from the "jar" tree and
(sxml->xml ;; inject our own tags.
(pre-post-order (jar . ,(lambda (tag . kids)
build.xml `(jar ,@(append-map
`(;; Remove all zipfileset tags from the "jar" tree and (filter (lambda (e)
;; inject our own tags. (not (eq? 'zipfileset (car e)))))
(jar . ,(lambda (tag . kids) kids)
`(jar ,@(append-map ,@fileset)))
(filter (lambda (e) ;; Skip the "bundle" target (and the "-post-jar" target
(not (eq? 'zipfileset (car e))))) ;; that depends on it), because we don't need it and it
kids) ;; confuses sxml->xml.
,@fileset))) (target . ,(lambda (tag . kids)
;; Skip the "bundle" target (and the "-post-jar" target (let ((name ((sxpath '(name *text*))
;; that depends on it), because we don't need it and it (car kids))))
;; confuses sxml->xml. (if (or (member "bundle" name)
(target . ,(lambda (tag . kids) (member "-post-jar" name))
(let ((name ((sxpath '(name *text*)) '() ; skip
(car kids)))) `(,tag ,@kids)))))
(if (or (member "bundle" name) (*default* . ,(lambda (tag . kids) `(,tag ,@kids)))
(member "-post-jar" name)) (*text* . ,(lambda (_ txt)
'() ; skip (match txt
`(,tag ,@kids))))) ;; Remove timestamp.
(*default* . ,(lambda (tag . kids) `(,tag ,@kids))) ("${TODAY}" "(unknown)")
(*text* . ,(lambda (_ txt) (_ txt))))))
(match txt port)))
;; Remove timestamp.
("${TODAY}" "(unknown)")
(_ txt))))))
port)))
;; Build it! ;; Build it!
(invoke "ant" (invoke "ant"
(string-append "-Djavac.classpath=" classpath) (string-append "-Djavac.classpath=" classpath)
"-Dbuild.runtime=true" "-Dbuild.runtime=true"
"-Dbuild.time=01/01/1970 00:00:00" "-Dbuild.time=01/01/1970 00:00:00"
"-Djavac.source=1.7" "-Djavac.source=1.7"
"-Djavac.target=1.7" "-Djavac.target=1.7"
(string-append "-Dtag.short.version=" (string-append "-Dtag.short.version="
,version))))) #$version)))))
(replace 'install (replace 'install
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let ((share (string-append #$output "/share/axoloti/")))
(share (string-append out "/share/axoloti/"))) (install-file "dist/Axoloti.jar" share)
(install-file "dist/Axoloti.jar" share)
;; We do this to ensure that this package retains references to ;; We do this to ensure that this package retains references to
;; other Java packages' jar files. ;; other Java packages' jar files.
(install-file "build.xml" share) (install-file "build.xml" share)
;; Create a launcher script ;; Create a launcher script
(mkdir (string-append out "/bin")) (mkdir (string-append #$output "/bin"))
(let ((target (string-append out "/bin/Axoloti"))) (let ((target (string-append #$output "/bin/Axoloti")))
(with-output-to-file target (with-output-to-file target
(lambda () (lambda ()
(let* ((dir (string-append (assoc-ref outputs "out") (let* ((dir (string-append #$output "/share/axoloti"))
"/share/axoloti")) (runtime (search-input-directory inputs
(runtime (search-input-directory inputs "share/axoloti"))
"share/axoloti")) (toolchain (assoc-ref inputs "cross-toolchain"))
(toolchain (assoc-ref inputs "cross-toolchain")) (includes (string-append
(includes (string-append toolchain
toolchain "/arm-none-eabi/include/c++:"
"/arm-none-eabi/include/c++:" toolchain
toolchain "/arm-none-eabi/include/c++/arm-none-eabi/armv7e-m")))
"/arm-none-eabi/include/c++/arm-none-eabi/armv7e-m"))) (display
(display (string-append "#!" (which "sh") "\n"
(string-append "#!" (which "sh") "\n" "export CROSS_CPATH=" includes "\n"
"export CROSS_CPATH=" includes "\n" "export CROSS_CPLUS_INCLUDE_PATH=" includes "\n"
"export CROSS_CPLUS_INCLUDE_PATH=" includes "\n" "export CROSS_LIBRARY_PATH="
"export CROSS_LIBRARY_PATH=" toolchain "/arm-none-eabi/lib" "\n"
toolchain "/arm-none-eabi/lib" "\n" (which "java")
(which "java") " -Daxoloti_release=" runtime
" -Daxoloti_release=" runtime " -Daxoloti_runtime=" runtime
" -Daxoloti_runtime=" runtime " -jar " dir "/Axoloti.jar")))))
" -jar " dir "/Axoloti.jar"))))) (chmod target #o555)))))
(chmod target #o555))))) (add-after 'install 'strip-jar-timestamps
(add-after 'install 'strip-jar-timestamps (assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))
(assoc-ref ant:%standard-phases 'strip-jar-timestamps)))))
(inputs (inputs
`(("icedtea" ,icedtea "jdk") `(("icedtea" ,icedtea "jdk")
("cross-toolchain" ,(make-arm-none-eabi-nano-toolchain-4.9)) ("cross-toolchain" ,(make-arm-none-eabi-nano-toolchain-4.9))