optional dependencies are also features
References: https://github.com/rust-lang/cargo/issues/4911 Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
parent
47b6c3ef80
commit
c9e7cf51e4
2 changed files with 30 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
__all__ = ["Dependency", "Metadata"]
|
__all__ = ["Dependency", "Metadata"]
|
||||||
|
|
||||||
|
import itertools
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
@ -162,7 +163,11 @@ class Metadata(object):
|
||||||
self.targets = [Target(tgt["kind"][0], tgt["name"]) for tgt in md["targets"]]
|
self.targets = [Target(tgt["kind"][0], tgt["name"]) for tgt in md["targets"]]
|
||||||
|
|
||||||
# Provides
|
# Provides
|
||||||
provides = Dependency(self.name, version, features=md["features"], provides=True)
|
# All optional depdencies are also features
|
||||||
|
# https://github.com/rust-lang/cargo/issues/4911
|
||||||
|
features = itertools.chain((x["name"] for x in md["dependencies"] if x["optional"]),
|
||||||
|
md["features"])
|
||||||
|
provides = Dependency(self.name, version, features=features, provides=True)
|
||||||
self.provides = str(provides).split(" and ")
|
self.provides = str(provides).split(" and ")
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
24
test.py
24
test.py
|
@ -75,6 +75,30 @@ def cargo_toml(request):
|
||||||
"crate(hello/color) = 1.2.3"],
|
"crate(hello/color) = 1.2.3"],
|
||||||
[]),
|
[]),
|
||||||
|
|
||||||
|
# Provides for optional dependencies
|
||||||
|
("""
|
||||||
|
[package]
|
||||||
|
name = "hello"
|
||||||
|
version = "1.2.3"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
non_optional = "1"
|
||||||
|
serde = { version = "1", optional = true }
|
||||||
|
rand = { version = "0.4", optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
std = []
|
||||||
|
v1 = ["rand"]
|
||||||
|
""",
|
||||||
|
["crate(hello) = 1.2.3",
|
||||||
|
"crate(hello/rand) = 1.2.3",
|
||||||
|
"crate(hello/serde) = 1.2.3",
|
||||||
|
"crate(hello/std) = 1.2.3",
|
||||||
|
"crate(hello/v1) = 1.2.3"],
|
||||||
|
["(crate(non_optional) >= 1.0.0 with crate(non_optional) < 2.0.0)",
|
||||||
|
"(crate(rand) >= 0.4.0 with crate(rand) < 0.5.0)",
|
||||||
|
"(crate(serde) >= 1.0.0 with crate(serde) < 2.0.0)"]),
|
||||||
|
|
||||||
# Caret requirements
|
# Caret requirements
|
||||||
("""
|
("""
|
||||||
[package]
|
[package]
|
||||||
|
|
Loading…
Reference in a new issue