Allow setting the "all-features" setting in rust2rpm.conf

This new setting works the same way as the `--all-features` CLI flag
when set to `true`. This makes it possible to set it to `true` permanently,
without having to remember to use the CLI flag when running rust2rpm.
This commit is contained in:
Fabio Valentini 2022-06-06 21:14:27 +02:00
parent 63acdf63c4
commit 4b93531d5f
No known key found for this signature in database
GPG key ID: 5AC5F572E5D410AF
2 changed files with 11 additions and 1 deletions

View file

@ -15,6 +15,9 @@ default settings (`[DEFAULT]`) and target-specific settings (i.e. `[fedora]`).
These configuration options are available right now: These configuration options are available right now:
- `all-features`: enable all cargo features when generating `BuildRequires`,
building the crate, and running cargo tests (defaults to `false`; setting this
value to `true` is equivalent to supplying the `--all-features` CLI flag)
- `unwanted-features`: features or optional dependencies for which no - `unwanted-features`: features or optional dependencies for which no
`+feature` subpackage should be generated (for example, dependencies on Rust `+feature` subpackage should be generated (for example, dependencies on Rust
compiler internals for crates that are also bundled with Rust itself) compiler internals for crates that are also bundled with Rust itself)

View file

@ -412,7 +412,7 @@ def main():
kwargs["generator_version"] = __version__ kwargs["generator_version"] = __version__
kwargs["crate"] = crate kwargs["crate"] = crate
kwargs["target"] = args.target kwargs["target"] = args.target
kwargs["all_features"] = args.all_features
bins = [tgt for tgt in metadata.targets if tgt.kind == "bin"] bins = [tgt for tgt in metadata.targets if tgt.kind == "bin"]
libs = [tgt for tgt in metadata.targets if tgt.kind in {"lib", "rlib", "proc-macro"}] libs = [tgt for tgt in metadata.targets if tgt.kind in {"lib", "rlib", "proc-macro"}]
is_bin = len(bins) > 0 is_bin = len(bins) > 0
@ -519,6 +519,13 @@ def main():
kwargs["distconf"] = conf[args.target] kwargs["distconf"] = conf[args.target]
conf_all_features = conf[args.target].getboolean("all-features")
kwargs["all_features"] = conf_all_features or args.all_features
if conf_all_features is False and args.all_features:
print("WARNING: Conflicting settings for enabling all features: The setting is \"false\"")
print(" in rust2rpm.conf but it was enabled with the \"--all-features\" CLI flag.")
spec_contents = template.render(md=metadata, patch_file=patch_file, **kwargs) spec_contents = template.render(md=metadata, patch_file=patch_file, **kwargs)
if args.stdout: if args.stdout:
print(f"# {spec_file}") print(f"# {spec_file}")