Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 721936 - cargo.eclass: allow configuring crate features (PATCH)
Summary: cargo.eclass: allow configuring crate features (PATCH)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Rust Project
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2020-05-09 17:32 UTC by Jannik Glückert
Modified: 2020-09-23 06:33 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch that allows selecting crate features (cargo-eclass-features.patch,1.76 KB, patch)
2020-05-09 17:32 UTC, Jannik Glückert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jannik Glückert 2020-05-09 17:32:39 UTC
Created attachment 637186 [details, diff]
patch that allows selecting crate features

Currently, there's no easy way to override the crate features. You either have to edit the Cargo.toml, or override all of cargo_src_compile, cargo_src_install and cargo_src_test.

This patch adds a simple function called cargo_feature and provides cargo_src_configure to enable the selected features.

An example use would be:

src_configure() {
    use alsa && cargo_feature "alsa_backend"
    use pulseaudio && cargo_feature "pulseaudio_backend"
    use portaudio && cargo_feature "portaudio_backend"
    use dbus && cargo_feature "dbus_keyring" && cargo_feature "dbus_mpris"

    cargo_src_configure
}

Right now, cargo_feature does not check wether the feature is actually listed in the Cargo.toml, that could probably be improved.

You can see this modification in use in my overlay at https://github.com/Jannik2099/jannik-hideout , the above example is taken from media-sound/spotifyd.
Note that the eclass in there has another modification not related to this patch.
Comment 1 Georgy Yakovlev archtester gentoo-dev 2020-05-14 01:36:12 UTC
Thanks for the patch.
There are plans do add similar functionality to cargo.eclass,
a bit differently though.
Work is in progress and I'll commit as soon as it's ready.
Comment 2 Georgy Yakovlev archtester gentoo-dev 2020-06-12 09:22:29 UTC
alternative implementation posted for review

https://archives.gentoo.org/gentoo-dev/message/9c97d515d9b28cd026a9dad2ceafcc27
Comment 3 Larry the Git Cow gentoo-dev 2020-09-23 06:33:30 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=be8bafc57aff94f0f708726805bccd44ddcd30a8

commit be8bafc57aff94f0f708726805bccd44ddcd30a8
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2020-06-13 00:56:33 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2020-09-23 05:58:47 +0000

    eclass/cargo.eclass: add cargo_src_configure (revised)
    
    simple src_configure implementation inspired by cmake.eclass
    plus some nice improvements to eclass.
    
    Closes: https://bugs.gentoo.org/721936
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 eclass/cargo.eclass | 103 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 87 insertions(+), 16 deletions(-)