Merge pull request #974 from oli-obk/metadata2
process more kinds of metadata
This commit is contained in:
commit
d7df882fa0
@ -16,7 +16,7 @@ pub struct Package {
|
||||
pub name: String,
|
||||
pub version: String,
|
||||
id: String,
|
||||
source: Option<()>,
|
||||
source: Option<String>,
|
||||
pub dependencies: Vec<Dependency>,
|
||||
pub targets: Vec<Target>,
|
||||
features: HashMap<String, Vec<String>>,
|
||||
@ -31,23 +31,14 @@ pub struct Dependency {
|
||||
kind: Option<String>,
|
||||
optional: bool,
|
||||
uses_default_features: bool,
|
||||
features: Vec<HashMap<String, String>>,
|
||||
features: Vec<String>,
|
||||
target: Option<()>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(RustcDecodable, Debug)]
|
||||
pub enum Kind {
|
||||
dylib,
|
||||
test,
|
||||
bin,
|
||||
lib,
|
||||
}
|
||||
|
||||
#[derive(RustcDecodable, Debug)]
|
||||
pub struct Target {
|
||||
pub name: String,
|
||||
pub kind: Vec<Kind>,
|
||||
pub kind: Vec<String>,
|
||||
src_path: String,
|
||||
}
|
||||
|
||||
|
15
src/main.rs
15
src/main.rs
@ -126,13 +126,14 @@ pub fn main() {
|
||||
assert_eq!(metadata.version, 1);
|
||||
for target in metadata.packages.remove(0).targets {
|
||||
let args = std::env::args().skip(2);
|
||||
assert_eq!(target.kind.len(), 1);
|
||||
match &target.kind[..] {
|
||||
[cargo::Kind::lib] |
|
||||
[cargo::Kind::dylib] => process(std::iter::once("--lib".to_owned()).chain(args), &dep_path, &sys_root),
|
||||
[cargo::Kind::bin] => process(vec!["--bin".to_owned(), target.name].into_iter().chain(args), &dep_path, &sys_root),
|
||||
// don't process tests and other stuff
|
||||
_ => {},
|
||||
if let Some(first) = target.kind.get(0) {
|
||||
if target.kind.len() > 1 || first.ends_with("lib") {
|
||||
process(std::iter::once("--lib".to_owned()).chain(args), &dep_path, &sys_root);
|
||||
} else if first == "bin" {
|
||||
process(vec!["--bin".to_owned(), target.name].into_iter().chain(args), &dep_path, &sys_root);
|
||||
}
|
||||
} else {
|
||||
panic!("badly formatted cargo metadata: target::kind is an empty array");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user