process more kinds of metadata

This commit is contained in:
Oliver Schneider 2016-06-02 17:29:25 +02:00
parent b33abd3876
commit 7bb8ba4631
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46
2 changed files with 8 additions and 19 deletions

View file

@ -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,
}

View file

@ -126,13 +126,11 @@ 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
_ => {},
assert!(!target.kind.is_empty());
if target.kind.len() > 1 || target.kind[0].ends_with("lib") {
process(std::iter::once("--lib".to_owned()).chain(args), &dep_path, &sys_root);
} else if target.kind[0] == "bin" {
process(vec!["--bin".to_owned(), target.name].into_iter().chain(args), &dep_path, &sys_root);
}
}
} else {