diff --git a/Cargo.toml b/Cargo.toml --- a/Cargo.toml +++ b/Cargo.toml @@ -16,4 +16,3 @@ serde-xml-rs = "0.2.1" serde_derive = "1.0" serde_json = "1.0" -toml = "0.4.10" diff --git a/src/bin/rust_qt_binding_generator.rs b/src/bin/rust_qt_binding_generator.rs --- a/src/bin/rust_qt_binding_generator.rs +++ b/src/bin/rust_qt_binding_generator.rs @@ -12,6 +12,12 @@ .long("overwrite-implementation") .help("Overwrite existing implementation."), ) + .arg( + Arg::with_name("edition") + .long("edition") + .takes_value(true) + .help("Rust edition (default 2015)") + ) .arg( Arg::with_name("config") .multiple(true) @@ -22,8 +28,9 @@ .get_matches(); let overwrite_implementation = matches.is_present("overwrite-implementation"); + let edition = matches.value_of("edition"); for config in matches.values_of("config").unwrap() { - if let Err(e) = generate_bindings_from_config_file(config, overwrite_implementation) { + if let Err(e) = generate_bindings_from_config_file(config, overwrite_implementation, edition) { eprintln!("{}", e); ::std::process::exit(1); } diff --git a/src/configuration.rs b/src/configuration.rs --- a/src/configuration.rs +++ b/src/configuration.rs @@ -5,7 +5,6 @@ use std::fs; use std::path::{Path, PathBuf}; use std::rc::Rc; -use toml; mod json { use super::Rust; @@ -466,27 +465,12 @@ post_process_object(object, &mut objects, &json.objects)?; } - let rust_edition: RustEdition = { - let mut buf = config_file.to_path_buf(); - buf.pop(); - buf.push(&json.rust.dir); - buf.push("Cargo.toml"); - if !buf.exists() { - return Err(format!("{} does not exist.", buf.display()).into()); - } - let manifest: toml::Value = fs::read_to_string(&buf)?.parse()?; - manifest["package"] - .get("edition") - .and_then(|val| val.as_str()) - .into() - }; - Ok(Config { config_file: config_file.into(), cpp_file: json.cpp_file, objects, rust: json.rust, - rust_edition, + rust_edition: RustEdition::Rust2015, overwrite_implementation: json.overwrite_implementation, }) } diff --git a/src/lib.rs b/src/lib.rs --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,6 @@ extern crate serde_derive; extern crate serde_json; extern crate serde_xml_rs; -extern crate toml; pub mod build; pub mod configuration; @@ -34,10 +33,12 @@ pub fn generate_bindings_from_config_file>( config_file: P, overwrite_implementation: bool, + edition: Option<&str>, ) -> Result<(), Box> { let mut config = read_bindings_file(config_file)?; if overwrite_implementation { config.overwrite_implementation = true; } + config.rust_edition = edition.into(); generate_bindings(&config) }