metadata: Support "renamed" dependencies

For example,

```toml
[dependencies]
open-ssl = { version="0.10", package = "openssl", optional = true }
[features]
openssl = ["actix-tls/openssl", "awc/openssl", "open-ssl"]
```

would end up previously with just +openssl subpackage with dependency on
crate(openssl). Now we create +open-ssl subpackage with dependency on
crate(openssl) and +openssl subpackage with dependencies on
crate(actix-tls/openssl), crate(awc/openssl) and +open-ssl subpackage.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
Igor Gnatenko 2019-12-20 17:40:26 +01:00
parent b2d348bd41
commit 509c9ca267
No known key found for this signature in database
GPG key ID: 695714BD1BBC5F4C

View file

@ -286,14 +286,17 @@ class Metadata:
for dep in md["dependencies"]:
if dep["kind"] == "dev":
continue
deps_by_name[dep["name"]].append(Dependency.from_json(dep))
deps_by_name[dep["rename"] or dep["name"]].append(Dependency.from_json(dep))
deps_by_feature = {}
local_features = set(md["features"]) | set(
d["rename"] for d in md["dependencies"] if d["rename"] is not None
)
for feature, f_deps in md["features"].items():
features = {None}
deps = set()
for dep in f_deps:
if dep in md["features"]:
if dep in local_features:
features.add(dep)
else:
pkg, _, f = dep.partition("/")