[PATCH] gnu: rust-freetype-sys-0.13: Unbundle freetype2.

  • Open
  • quality assurance status badge
Details
2 participants
  • Maxime Devos
  • Jean Pierre De Jesus DIAZ
Owner
unassigned
Submitted by
Jean Pierre De Jesus DIAZ
Severity
normal
J
J
Jean Pierre De Jesus DIAZ wrote on 7 Aug 2022 20:39
(name . guix-patches@gnu.org)(address . guix-patches@gnu.org)
HGgZmDLEAonfFN-y6zfOKMo8NKy1RXvOfRvKz_NhjsFPW6NMdGToBoJpBnJ5Rh8b6eRsJjw7UpVAxlhZeJww-6VXMmYswdYS2QXvB1fdEBE=@jeandudey.tech
Hello,

This patch removes the bundled freetype2 library on `rust-freetype-sys-0.13'.

Also removes unneeded build dependencies (`pkg-config' and `cmake').

One less bundled dependency ;).

Jean-Pierre De Jesus DIAZ
From f6dec2567dc997a32ef308bd42d259ac60dbbab5 Mon Sep 17 00:00:00 2001
From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
Date: Sun, 7 Aug 2022 20:36:14 +0200
Subject: [PATCH] gnu: rust-freetype-sys-0.13: Unbundle freetype2.

* gnu/packages/crates-io.scm (rust-freetype-sys-0.13)
[source]: Remove bundled `freetype2' source code and add patch to use
system library.
---
gnu/packages/crates-io.scm | 16 +++---
...ust-freetype-sys-0.13-simplify-build.patch | 53 +++++++++++++++++++
2 files changed, 63 insertions(+), 6 deletions(-)
create mode 100644 gnu/packages/patches/rust-freetype-sys-0.13-simplify-build.patch

Toggle diff (97 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index cfafce9aa3..cddd8ebaf0 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -27,6 +27,7 @@
;;; Copyright © 2022 Aleksandr Vityazev <avityazev@posteo.org>
;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2022 Evgenii Lepikhin <e.lepikhin@corp.mail.ru>
+;;; Copyright © 2022 Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -22904,14 +22905,17 @@ (define-public rust-freetype-sys-0.13
(uri (crate-uri "freetype-sys" version))
(file-name (string-append name "-" version ".tar.gz"))
(sha256
- (base32 "06kkds31s6b1i39dyanwmzbnic7laia1kk3gfvx8sqncq08l0zd3"))))
+ (base32 "06kkds31s6b1i39dyanwmzbnic7laia1kk3gfvx8sqncq08l0zd3"))
+ (patches (search-patches "rust-freetype-sys-0.13-simplify-build.patch"))
+ (modules '((guix build utils)))
+ (snippet
+ '(delete-file-recursively "freetype2"))))
(build-system cargo-build-system)
(arguments
- `(#:skip-build? #t
- #:cargo-inputs
- (("rust-cmake" ,rust-cmake-0.1)
- ("rust-libc" ,rust-libc-0.2)
- ("rust-pkg-config" ,rust-pkg-config-0.3))))
+ `(#:cargo-inputs
+ (("rust-libc" ,rust-libc-0.2))))
+ (inputs
+ (list freetype))
(home-page "https://github.com/PistonDevelopers/freetype-sys")
(synopsis "Low level binding for FreeType font library")
(description
diff --git a/gnu/packages/patches/rust-freetype-sys-0.13-simplify-build.patch b/gnu/packages/patches/rust-freetype-sys-0.13-simplify-build.patch
new file mode 100644
index 0000000000..bb16f3e065
--- /dev/null
+++ b/gnu/packages/patches/rust-freetype-sys-0.13-simplify-build.patch
@@ -0,0 +1,53 @@
+Force freetype-sys to use system libraries, this removes the need for CMake.
+
+The bundled source is still present at the crate package, it should be removed
+through a package snippet.
+
+diff -Naur freetype-sys-0.13.1/Cargo.toml freetype-sys-0.13.1-patch/Cargo.toml > 1.patch
+--- freetype-sys-0.13.1/Cargo.toml 2020-07-05 11:15:43.000000000 +0200
++++ freetype-sys-0.13.1-patch/Cargo.toml 2022-08-07 19:53:57.649678214 +0200
+@@ -24,8 +24,3 @@
+ repository = "https://github.com/PistonDevelopers/freetype-sys.git"
+ [dependencies.libc]
+ version = "0.2.42"
+-[build-dependencies.cmake]
+-version = "0.1.42"
+-
+-[build-dependencies.pkg-config]
+-version = "0.3.11"
+diff -Naur freetype-sys-0.13.1/build.rs freetype-sys-0.13.1-patch/build.rs > 2.patch
+--- freetype-sys-0.13.1/build.rs 2020-05-30 05:59:09.000000000 +0200
++++ freetype-sys-0.13.1-patch/build.rs 2022-08-07 19:54:34.153503846 +0200
+@@ -1,30 +1,4 @@
+-extern crate cmake;
+-extern crate pkg_config;
+-
+-use cmake::Config;
+-use std::env;
+-
+ fn main() {
+- let target = env::var("TARGET").unwrap();
+- if !target.contains("android")
+- && pkg_config::Config::new().atleast_version("18.5.12").find("freetype2").is_ok()
+- {
+- return
+- }
+-
+- let mut config = Config::new("freetype2");
+- if let Ok(s) = env::var("FREETYPE_CMAKE_GENERATOR") {
+- config.generator(s);
+- }
+- let dst = config
+- .define("WITH_BZip2", "OFF")
+- .define("WITH_HarfBuzz", "OFF")
+- .define("WITH_PNG", "OFF")
+- .define("WITH_ZLIB", "OFF")
+- .profile("Release")
+- .build();
+- let out_dir = env::var("OUT_DIR").unwrap();
+- println!("cargo:rustc-link-search=native={}/lib", dst.display());
+- println!("cargo:rustc-link-lib=static=freetype");
++ println!("cargo:rustc-link-lib=freetype");
+- println!("cargo:outdir={}", out_dir);
+ }
++
--
2.36.1
M
M
Maxime Devos wrote on 7 Aug 2022 23:59
07ad189f-3042-2354-cc85-333f34bba966@telenet.be
On 07-08-2022 20:39, Jean Pierre De Jesus DIAZ via Guix-patches via wrote:
Toggle quote (5 lines)
> Hello,
>
> This patch removes the bundled freetype2 library on `rust-freetype-sys-0.13'.
>
> Also removes unneeded build dependencies (`pkg-config' and `cmake').
I've noticed this in antioxidant (and fixed it there locally) but didn't
report it yet.
Anyway, this can be done more simple -- all that I needed to do was
deleting the freetype2 subdirectory (in a snippet) and adding 'freetype'
to inputs.  Patching the build script or build.rs was not necessary.
Additionally, I noticed that in the modified build.rs, only
rustc-link-lib (-l) is set, but not rustc-link-search (-L). Antioxidant
needs the latter to be set, otherwise dependents will fail to link
because of not finding the freetype library.
Greetings,
Maxime.
Attachment: OpenPGP_signature
J
J
Jean Pierre De Jesus DIAZ wrote on 8 Aug 2022 16:37
[PATCH] gnu: rust-freetype-sys-0.13: Unbundle freetype2.
(name . 57043@debbugs.gnu.org)(address . 57043@debbugs.gnu.org)
IVg0RBBB75esVQ62YwfXdBTMYRgTsRGyHzqJi73VVUMcNILlr2dh1ViKMdLRGvMFzsNVPUXwLfr_hY3cyWb0UlRlCQs6ipd3Qk0G-OqyS0M=@jeandudey.tech
Toggle quote (4 lines)
>Anyway, this can be done more simple -- all that I needed to do was
>deleting the freetype2 subdirectory (in a snippet) and adding 'freetype'
>to inputs. Patching the build script or build.rs was not necessary.

Thought that the pkg-config `if' block was for Android only, my mistake.

Probably influenced by the compilation error caused by not building
without the freetype2 directory, because `pkg-config' was not present.

Toggle quote (6 lines)
>Additionally, I noticed that in the modified build.rs, only
>rustc-link-lib (-l) is set, but not rustc-link-search (-L).

>Antioxidant needs the latter to be set, otherwise dependents will fail
>to link because of not finding the freetype library.

This reminds me of also fixing `rust-bzip2-sys-0.1' in the future because
it also doesn't specify the linker search path because the default build
script was removed like I did in this case.

See:


I don't know our stance on this though, or if there's a policy that
mandates removing compilation support for bundled code or to leave it as
is as long as the code compiles. I'd leave it as it though to make
maintenance easier and less modifications to the original source code.

Thanks for the review!

Jean-Pierre De Jesus DIAZ
From a3487eae2c5b7a507929816e60206878c1d2fc0e Mon Sep 17 00:00:00 2001
From: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
Date: Mon, 8 Aug 2022 16:33:16 +0200
Subject: [PATCH] gnu: rust-freetype-sys-0.13: Unbundle freetype2.

* gnu/packages/crates-io.scm (rust-freetype-sys-0.13)
[source]: Remove bundled `freetype2' source code.
[arguments]: Remove `#:skip-build? #t'.
[native-inputs]: Add pkg-config.
[inputs]: Add freetype.
---
gnu/packages/crates-io.scm | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

Toggle diff (38 lines)
diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index cfafce9aa3..b5d4dc7c61 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -27,6 +27,7 @@
;;; Copyright © 2022 Aleksandr Vityazev <avityazev@posteo.org>
;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2022 Evgenii Lepikhin <e.lepikhin@corp.mail.ru>
+;;; Copyright © 2022 Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -22904,14 +22905,20 @@ (define-public rust-freetype-sys-0.13
(uri (crate-uri "freetype-sys" version))
(file-name (string-append name "-" version ".tar.gz"))
(sha256
- (base32 "06kkds31s6b1i39dyanwmzbnic7laia1kk3gfvx8sqncq08l0zd3"))))
+ (base32 "06kkds31s6b1i39dyanwmzbnic7laia1kk3gfvx8sqncq08l0zd3"))
+ (modules '((guix build utils)))
+ (snippet
+ '(delete-file-recursively "freetype2"))))
(build-system cargo-build-system)
(arguments
- `(#:skip-build? #t
- #:cargo-inputs
+ `(#:cargo-inputs
(("rust-cmake" ,rust-cmake-0.1)
("rust-libc" ,rust-libc-0.2)
("rust-pkg-config" ,rust-pkg-config-0.3))))
+ (native-inputs
+ (list pkg-config))
+ (inputs
+ (list freetype))
(home-page "https://github.com/PistonDevelopers/freetype-sys")
(synopsis "Low level binding for FreeType font library")
(description
--
2.36.1
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 57043@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 57043
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch