gnu: librsvg: Switch to gnu-build-system.

* gnu/packages/gnome.scm (librsvg)[build-system]: Switch to gnu-build-system.
[inputs]: Use ‘cargo-inputs’.
[native-inputs]: Add rust, rust:cargo.
Add rust-sysroot when cross-compiling.
[arguments]: Remove #:cargo-inputs and #:cargo-development-inputs.
<#:phases>: Add ‘prepare-cargo-build-system’ to apply Rust phases.
Remove phases already provided by gnu-build-system.
Move flags in ‘gnu-configure’ and ‘prepare-for-build’  to...
<#:configure-flags, #:make-flags>: ...here.
* gnu/packages/rust-crates.scm (lookup-cargo-inputs)[librsvg]: New entry.

Change-Id: I5c2c34efe95343184bc832e2ff72e3a735e96a92
This commit is contained in:
Hilton Chain 2025-03-03 14:24:54 +08:00
parent 085b1b6b8c
commit e386bb5cb1
No known key found for this signature in database
GPG key ID: ACC66D09CA528292
2 changed files with 970 additions and 96 deletions

View file

@ -3677,68 +3677,38 @@ for dealing with different structured file formats.")
(sha256
(base32
"0ym2yg94sc7ralh1kwqqrhz3wcc51079z90mbx0qrls7wfh36hi2"))))
(build-system cargo-build-system)
(build-system gnu-build-system)
(outputs '("out" "doc" "debug"))
(arguments
(list
#:install-source? #f
#:configure-flags
#~(list "--disable-static"
#$@(if (%current-target-system)
#~(;; g-ir-scanner can't import its modules
;; and vala currently can't be cross-compiled.
"--enable-introspection=no"
"--enable-vala=no"
;; These two are necessary for cross-compiling.
(string-append
"--build=" #$(nix-system->gnu-triplet
(%current-system)))
(string-append
"--host=" #$(%current-target-system)))
#~("--enable-vala")))
#:make-flags
#~(list (string-append "CC=" #$(cc-for-target))
(string-append "PKG_CONFIG=" #$(pkg-config-for-target))
#$@(if (%current-target-system)
#~((string-append "RUST_TARGET="
#$(platform-rust-target
(lookup-platform-by-target
(%current-target-system)))))
#~()))
#:imported-modules %cargo-build-system-modules
#:modules
'((guix build cargo-build-system)
(guix build utils)
((guix build gnu-build-system) #:prefix gnu:))
#:cargo-inputs
`(("rust-anyhow" ,rust-anyhow-1)
("rust-cairo-rs" ,rust-cairo-rs-0.19)
("rust-cast" ,rust-cast-0.3)
("rust-chrono" ,rust-chrono-0.4)
("rust-clap" ,rust-clap-4)
("rust-clap-complete" ,rust-clap-complete-4)
("rust-cssparser" ,rust-cssparser-0.31)
("rust-cstr" ,rust-cstr-0.2)
("rust-data-url" ,rust-data-url-0.3)
("rust-encoding-rs" ,rust-encoding-rs-0.8)
("rust-float-cmp" ,rust-float-cmp-0.9)
("rust-gdk-pixbuf" ,rust-gdk-pixbuf-0.19)
("rust-gio" ,rust-gio-0.19)
("rust-glib" ,rust-glib-0.19)
("rust-image" ,rust-image-0.24)
("rust-itertools" ,rust-itertools-0.12)
("rust-language-tags" ,rust-language-tags-0.3)
("rust-libc" ,rust-libc-0.2)
("rust-locale-config" ,rust-locale-config-0.3)
("rust-markup5ever" ,rust-markup5ever-0.11)
("rust-nalgebra" ,rust-nalgebra-0.32)
("rust-num-traits" ,rust-num-traits-0.2)
("rust-pango" ,rust-pango-0.19)
("rust-pangocairo" ,rust-pangocairo-0.19)
("rust-rayon" ,rust-rayon-1)
("rust-rctree" ,rust-rctree-0.6)
("rust-regex" ,rust-regex-1)
("rust-rgb" ,rust-rgb-0.8)
("rust-selectors" ,rust-selectors-0.25)
("rust-string-cache" ,rust-string-cache-0.8)
("rust-system-deps" ,rust-system-deps-6)
("rust-thiserror" ,rust-thiserror-1)
("rust-tinyvec" ,rust-tinyvec-1)
("rust-url" ,rust-url-2)
("rust-xml5ever" ,rust-xml5ever-0.17)
("rust-yeslogic-fontconfig-sys" ,rust-yeslogic-fontconfig-sys-5))
#:cargo-development-inputs
`(("rust-anyhow" ,rust-anyhow-1)
("rust-assert-cmd" ,rust-assert-cmd-2)
("rust-chrono" ,rust-chrono-0.4)
("rust-criterion" ,rust-criterion-0.5)
("rust-float-cmp" ,rust-float-cmp-0.9)
("rust-lopdf" ,rust-lopdf-0.32)
("rust-matches" ,rust-matches-0.1)
("rust-png" ,rust-png-0.17)
("rust-predicates" ,rust-predicates-3)
("rust-proptest" ,rust-proptest-1)
("rust-quick-error" ,rust-quick-error-2)
("rust-serde" ,rust-serde-1)
("rust-serde-json" ,rust-serde-json-1)
("rust-tempfile" ,rust-tempfile-3)
("rust-url" ,rust-url-2))
'(((guix build cargo-build-system) #:prefix cargo:)
(guix build gnu-build-system)
(guix build utils))
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'patch-gdk-pixbuf-thumbnailer
@ -3752,15 +3722,6 @@ for dealing with different structured file formats.")
"/bin/gdk-pixbuf-thumbnailer")))))
(add-after 'unpack 'prepare-for-build
(lambda _
;; In lieu of #:make-flags
(setenv "CC" #$(cc-for-target))
(setenv "PKG_CONFIG" #$(pkg-config-for-target))
#$@(if (%current-target-system)
#~((setenv "RUST_TARGET"
#$(platform-rust-target
(lookup-platform-by-target
(%current-target-system)))))
#~())
;; Something about the build environment resists building
;; successfully with the '--locked' flag.
(substitute* '("Makefile.am" "Makefile.in")
@ -3789,35 +3750,37 @@ for dealing with different structured file formats.")
(string-append "gdk_pixbuf_cache_file="
#$output "/"
#$%gdk-pixbuf-loaders-cache-file "\n")))))
(add-after 'configure 'gnu-configure
(lambda* (#:key outputs #:allow-other-keys #:rest args)
(apply (assoc-ref gnu:%standard-phases 'configure)
#:configure-flags
(list "--disable-static"
#$@(if (%current-target-system)
#~(;; g-ir-scanner can't import its modules
;; and vala currently can't be cross-compiled.
"--enable-introspection=no"
"--enable-vala=no"
;; These two are necessary for cross-compiling.
(string-append
"--build=" #$(nix-system->gnu-triplet
(%current-system)))
(string-append
"--host=" #$(%current-target-system)))
#~("--enable-vala")))
args)))
(replace 'build
(assoc-ref gnu:%standard-phases 'build))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys #:rest args)
(when tests?
((assoc-ref gnu:%standard-phases 'check)
#:test-target "check"))))
(replace 'install
(assoc-ref gnu:%standard-phases 'install)))))
(native-inputs (list gdk-pixbuf `(,glib "bin") gobject-introspection pkg-config vala))
(inputs (list freetype gobject-introspection harfbuzz libxml2 pango))
(add-after 'unpack 'prepare-cargo-build-system
(lambda args
(for-each
(lambda (phase)
(format #t "Running cargo phase: ~a~%" phase)
(apply (assoc-ref cargo:%standard-phases phase)
#:cargo-target #$(cargo-triplet)
args))
'(unpack-rust-crates
configure
check-for-pregenerated-files
patch-cargo-checksums)))))))
(native-inputs
(append
(list gdk-pixbuf
`(,glib "bin")
gobject-introspection
pkg-config
rust
`(,rust "cargo")
vala)
(or (and=> (%current-target-system)
(compose list make-rust-sysroot))
'())))
(inputs
(cons* freetype
gobject-introspection
harfbuzz
libxml2
pango
(cargo-inputs 'librsvg)))
(propagated-inputs (list cairo gdk-pixbuf glib))
(synopsis "SVG rendering library")
(description "Librsvg is a library to render SVG images to Cairo surfaces.