#185 Allow enabling features via .rust2rpm.conf
Closed: Fixed a year ago by decathorpe. Opened 2 years ago by alebastr.

The config file already allows to specify unwanted-features. It would be reasonable to add support for enabling optional features as well, e.g.

[DEFAULT]
all-features = true

or

[DEFAULT]
enable-features = foo bar baz

This would also serve as a partial workaround for #110, allowing to store the state of an optional feature with binaries between rust2rpm invocations.


#183 didn't actually end up addressing this problem.

However, we have recently added support for setting all-features = true, which addresses your first use case.

I've been thinking about the second case (where only certain features need to be enabled for some steps of the build), and I'm not sure how to best address this as a setting. But the most flexible solution for me would be something like this:

[DEFAULT]
genbr-features =
  foo
  bar
build-features =
  foo
install-features =
  bar
test-features =
  foo
  bar

It is slightly more verbose, but it would allow setting different features for the different stages of the build process (for example, if some feature only needs to be enabled for tests, like a ci feature).

However, this also has the potential to be used to create slightly broken .spec files (for example, not enabling a feature in %cargo_build but enabling it in %cargo_test might give unexpected failures or cause unnecessary recompilation to happen).

Using the simpler approach would solve this problem:

[DEFAULT]
enable-features =
  foo
  bar

This does not offer the same level of granularity (which is, in general, not needed anyway), but would work around the "possible inconsistency problem" that the more fine-grained approach would suffer from.

Ideally, we'd read the "required-features" settings for binaries and generate -f foo,bar flags for all %cargo_* macros automatically. And if tests are enabled (which they are, by default), we'd need to read the "required-features" settings for all examples and test binaries as well.

That reminds me, we should have a setting + CLI switch for defaulting to %with_check (and ideally, supplying a reason string that can be included in the .spec file). That's one of the few things that aren't automated / persistent with a setting in rust2rpm.conf yet ...

Metadata Update from @decathorpe:
- Issue set to the milestone: 23

2 years ago

@alebastr anything we still need to do here, or was your use case addressed with the support for the "all-features" setting?

If we still need support for enabling specific features without using "--all-features", I still think an "enable-features = foo bar" setting would be the easiest - if not the most flexible - solution.

all-features works for my packages.
There's 8 specs1 in Fedora that may benefit from a persistent config option for -f something, but I'm not sure if that's worth the extra work :)

Ok, thanks for the confirmation, let's punt this to a future release, and get v23 out now. It has a few bugfixes :)

Metadata Update from @decathorpe:
- Issue set to the milestone: 24 (was: 23)

a year ago

Metadata Update from @decathorpe:
- Issue set to the milestone: v24.1 (was: 24)

a year ago

rust2rpm will now add "-f foo" flags for all required features of "bin" targets:
https://pagure.io/fedora-rust/rust2rpm/c/a0e869199f96dc3eabf8abbe204db337fc8346fc?branch=main

I used dotenvy as a test case when I wrote the code for this, and the cli feature is now explicitly enabled automatically:
https://pagure.io/fedora-rust/rust2rpm/blob/a0e869199f96dc3eabf8abbe204db337fc8346fc/f/rust2rpm/tests/samples/dotenvy-0.15.6.fedora.spec

I think this should solve your original problem, @alebastr ?

I'll keep this issue open, because enabling other features manually is still something I'd like to implement.

Released with rust2rpm v24.1.0.

Metadata Update from @decathorpe:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

a year ago

Login to comment on this ticket.

Metadata
Related Pull Requests
  • #183 Merged 2 years ago