diff --git a/README.md b/README.md index bf0412b..7036740 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ default settings (`[DEFAULT]`) and target-specific settings (i.e. `[fedora]`). 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 `+feature` subpackage should be generated (for example, dependencies on Rust compiler internals for crates that are also bundled with Rust itself) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index 87f0a44..8d9ce82 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -412,7 +412,7 @@ def main(): kwargs["generator_version"] = __version__ kwargs["crate"] = crate kwargs["target"] = args.target - kwargs["all_features"] = args.all_features + 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"}] is_bin = len(bins) > 0 @@ -519,6 +519,13 @@ def main(): 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) if args.stdout: print(f"# {spec_file}")