Merge #7368
7368: Clarify enabled features and defined features in PackageData r=matklad a=edwin0cheng Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
commit
64a92e2328
@ -99,8 +99,10 @@ pub struct PackageData {
|
|||||||
pub dependencies: Vec<PackageDependency>,
|
pub dependencies: Vec<PackageDependency>,
|
||||||
/// Rust edition for this package
|
/// Rust edition for this package
|
||||||
pub edition: Edition,
|
pub edition: Edition,
|
||||||
/// List of features to activate
|
/// Features provided by the crate, mapped to the features required by that feature.
|
||||||
pub features: Vec<String>,
|
pub features: FxHashMap<String, Vec<String>>,
|
||||||
|
/// List of features enabled on this package
|
||||||
|
pub active_features: Vec<String>,
|
||||||
/// List of config flags defined by this package's build script
|
/// List of config flags defined by this package's build script
|
||||||
pub cfgs: Vec<CfgFlag>,
|
pub cfgs: Vec<CfgFlag>,
|
||||||
/// List of cargo-related environment variables with their value
|
/// List of cargo-related environment variables with their value
|
||||||
@ -281,7 +283,8 @@ pub fn from_cargo_metadata(
|
|||||||
is_member,
|
is_member,
|
||||||
edition,
|
edition,
|
||||||
dependencies: Vec::new(),
|
dependencies: Vec::new(),
|
||||||
features: Vec::new(),
|
features: meta_pkg.features.into_iter().collect(),
|
||||||
|
active_features: Vec::new(),
|
||||||
cfgs: cfgs.get(&id).cloned().unwrap_or_default(),
|
cfgs: cfgs.get(&id).cloned().unwrap_or_default(),
|
||||||
envs: envs.get(&id).cloned().unwrap_or_default(),
|
envs: envs.get(&id).cloned().unwrap_or_default(),
|
||||||
out_dir: out_dir_by_id.get(&id).cloned(),
|
out_dir: out_dir_by_id.get(&id).cloned(),
|
||||||
@ -328,7 +331,7 @@ pub fn from_cargo_metadata(
|
|||||||
let dep = PackageDependency { name: dep_node.name, pkg };
|
let dep = PackageDependency { name: dep_node.name, pkg };
|
||||||
packages[source].dependencies.push(dep);
|
packages[source].dependencies.push(dep);
|
||||||
}
|
}
|
||||||
packages[source].features.extend(node.features);
|
packages[source].active_features.extend(node.features);
|
||||||
}
|
}
|
||||||
|
|
||||||
let workspace_root = AbsPathBuf::assert(meta.workspace_root);
|
let workspace_root = AbsPathBuf::assert(meta.workspace_root);
|
||||||
|
@ -481,7 +481,7 @@ fn add_target_crate_root(
|
|||||||
let edition = pkg.edition;
|
let edition = pkg.edition;
|
||||||
let cfg_options = {
|
let cfg_options = {
|
||||||
let mut opts = cfg_options.clone();
|
let mut opts = cfg_options.clone();
|
||||||
for feature in pkg.features.iter() {
|
for feature in pkg.active_features.iter() {
|
||||||
opts.insert_key_value("feature".into(), feature.into());
|
opts.insert_key_value("feature".into(), feature.into());
|
||||||
}
|
}
|
||||||
opts.extend(pkg.cfgs.iter().cloned());
|
opts.extend(pkg.cfgs.iter().cloned());
|
||||||
|
Loading…
Reference in New Issue
Block a user