Add support for --all-features

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
Igor Gnatenko 2019-03-16 15:08:43 +01:00
parent 5d7a0b2444
commit 47597fcad7
No known key found for this signature in database
GPG key ID: 695714BD1BBC5F4C
2 changed files with 11 additions and 3 deletions

View file

@ -220,6 +220,8 @@ def main():
help="Do initial patching of Cargo.toml") help="Do initial patching of Cargo.toml")
parser.add_argument("-s", "--store-crate", action="store_true", parser.add_argument("-s", "--store-crate", action="store_true",
help="Store crate in current directory") help="Store crate in current directory")
parser.add_argument("--all-features", action="store_true",
help="Activate all available features")
parser.add_argument("crate", help="crates.io name\n" parser.add_argument("crate", help="crates.io name\n"
"path/to/local.crate\n" "path/to/local.crate\n"
"path/to/project/", "path/to/project/",
@ -250,6 +252,7 @@ def main():
kwargs = {} kwargs = {}
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

View file

@ -44,7 +44,12 @@ Patch0: {{ patch_file }}
ExclusiveArch: %{rust_arches} ExclusiveArch: %{rust_arches}
BuildRequires: rust-packaging BuildRequires: rust-packaging
{% if not all_features %}
{% set buildrequires = normalize_deps(md.requires("default", resolve=True))|sort %} {% set buildrequires = normalize_deps(md.requires("default", resolve=True))|sort %}
{% else %}
{% set buildrequires = normalize_deps(md.all_dependencies)|sort %}
{% set cargo_args = " -a" %}
{% endif %}
{% for req in buildrequires %} {% for req in buildrequires %}
BuildRequires: {{ req }} BuildRequires: {{ req }}
{% endfor %} {% endfor %}
@ -158,14 +163,14 @@ which use {% if feature is not none %}"{{ feature }}" feature of {% endif %}"%{c
%cargo_prep %cargo_prep
%build %build
%cargo_build %cargo_build{{ cargo_args }}
%install %install
%cargo_install %cargo_install{{ cargo_args }}
%if %{with check} %if %{with check}
%check %check
%cargo_test %cargo_test{{ cargo_args }}
%endif %endif
%changelog %changelog