From a9e0be6583fd92b9a171091b70e81bdba4ad4aa2 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 19 Jun 2015 12:55:00 +0200 Subject: [PATCH] fix(cli): work on stable CLI was slightly adjusted to not use unstable features. Fortunately, there is no serde magic happening, which allows us to keep it simple without using a build script. --- etc/api/type-api.yaml | 1 + src/mako/Cargo.toml.mako | 4 +++- src/mako/cli/main.rs.mako | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/etc/api/type-api.yaml b/etc/api/type-api.yaml index a452cae9b6..cad1135fdd 100644 --- a/etc/api/type-api.yaml +++ b/etc/api/type-api.yaml @@ -26,6 +26,7 @@ make: output_dir: src cargo: build_version: "0.1.7" + build_script: src/build.rs keywords: [protocol, web, api] dependencies: - url = "*" diff --git a/src/mako/Cargo.toml.mako b/src/mako/Cargo.toml.mako index c53c33b035..82203c3d5b 100644 --- a/src/mako/Cargo.toml.mako +++ b/src/mako/Cargo.toml.mako @@ -16,7 +16,9 @@ homepage = "${documentationLink}" documentation = "${cargo.doc_base_url}/${to_extern_crate_name(util.crate_name())}" license = "${copyright.license_abbrev}" keywords = ["${name[:20]}", ${", ".join(estr(cargo.keywords))}] -build = "src/build.rs" +% if cargo.get('build_script'): +build = "${cargo.build_script}" +% endif % if cargo.get('is_executable', False): [[bin]] diff --git a/src/mako/cli/main.rs.mako b/src/mako/cli/main.rs.mako index 35e1986fb4..3149e59ca4 100644 --- a/src/mako/cli/main.rs.mako +++ b/src/mako/cli/main.rs.mako @@ -12,7 +12,6 @@ <%block filter="rust_comment">\ <%util:gen_info source="${self.uri}" />\ -#![feature(plugin, exit_status)] #![allow(unused_variables, unused_imports, dead_code, unused_mut)] #[macro_use] @@ -34,18 +33,19 @@ mod cmn; ${engine.new(c)}\ fn main() { + let mut exit_status = 0i32; ${argparse.new(c) | indent_all_but_first_by(1)}\ let matches = app.get_matches(); let debug = matches.is_present("${DEBUG_FLAG}"); match Engine::new(matches) { Err(err) => { - env::set_exit_status(err.exit_code); + exit_status = err.exit_code; writeln!(io::stderr(), "{}", err).ok(); }, Ok(engine) => { if let Err(doit_err) = engine.doit() { - env::set_exit_status(1); + exit_status = 1; match doit_err { DoitError::IoError(path, err) => { writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok(); @@ -61,4 +61,6 @@ fn main() { } } } + + std::process::exit(exit_status); } \ No newline at end of file