diff --git a/etc/api/type-cli.yaml b/etc/api/type-cli.yaml index de31625529..2df567e11e 100644 --- a/etc/api/type-cli.yaml +++ b/etc/api/type-cli.yaml @@ -19,6 +19,7 @@ make: cargo: build_version: "0.0.1" keywords: [cli] + is_executable: YES dependencies: - docopt = "*" - docopt_macros = "*" diff --git a/src/mako/Cargo.toml.mako b/src/mako/Cargo.toml.mako index a93ce8e60a..4c98f29a29 100644 --- a/src/mako/Cargo.toml.mako +++ b/src/mako/Cargo.toml.mako @@ -17,6 +17,11 @@ documentation = "${cargo.doc_base_url}/${to_extern_crate_name(util.crate_name()) license = "${copyright.license_abbrev}" keywords = ["${name[:20]}", ${", ".join(estr(cargo.keywords))}] +% if cargo.get('is_executable', False): +[[bin]] +name = "${util.program_name()}" +% endif + [dependencies] hyper = "*" mime = "*" diff --git a/src/mako/cli/lib/docopt.mako b/src/mako/cli/lib/docopt.mako new file mode 100644 index 0000000000..ae8175485e --- /dev/null +++ b/src/mako/cli/lib/docopt.mako @@ -0,0 +1,22 @@ +<%namespace name="util" file="../../lib/util.mako"/>\ +<%def name="new(c)">\ +docopt!(Args derive Debug, " +Usage: ${util.program_name()} [options] (|-) + ${util.program_name()} --help + +Options: +--width The width of the output image [default: 1024] +--height The height of the output image [default: 1024] +--samples-per-pixel Amount of samples per pixel. 4 means 16 over-samples [default: 1] +--num-cores Amount of cores to do the rendering on [default: 1] + If this is not set, you may also use the RTRACEMAXPROCS + environment variable, e.g. RTRACEMAXPROCS=4. + The commandline always overrides environment variables. + +|- Either a file with .tga extension, or - to write file to stdout +" +, flag_samples_per_pixel: u16 +, flag_height: u16 +, flag_width: u16 +, flag_num_cores: usize); + \ No newline at end of file diff --git a/src/mako/cli/main.rs.mako b/src/mako/cli/main.rs.mako index 69a7511942..16e9ff4f78 100644 --- a/src/mako/cli/main.rs.mako +++ b/src/mako/cli/main.rs.mako @@ -1,28 +1,17 @@ +<%namespace name="docopt" file="lib/docopt.mako"/>\ +<% + from util import new_context + + c = new_context(schemas, resources, context.get('methods')) + default_user_agent = "google-cli-rust-client/" + cargo.build_version +%>\ #![feature(plugin)] #![plugin(docopt_macros)] extern crate docopt; extern crate rustc_serialize; -docopt!(Args derive Debug, " -Usage: rtrace [options] (|-) - rtrace --help - -Options: ---width The width of the output image [default: 1024] ---height The height of the output image [default: 1024] ---samples-per-pixel Amount of samples per pixel. 4 means 16 over-samples [default: 1] ---num-cores Amount of cores to do the rendering on [default: 1] - If this is not set, you may also use the RTRACEMAXPROCS - environment variable, e.g. RTRACEMAXPROCS=4. - The commandline always overrides environment variables. - -|- Either a file with .tga extension, or - to write file to stdout -" -, flag_samples_per_pixel: u16 -, flag_height: u16 -, flag_width: u16 -, flag_num_cores: usize); +<%docopt:new c="c"/>\ fn main() { let _: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); diff --git a/src/mako/deps.mako b/src/mako/deps.mako index 5a63ea32e0..548e87b3c4 100644 --- a/src/mako/deps.mako +++ b/src/mako/deps.mako @@ -44,15 +44,17 @@ import os import json + CMN_SRC = '/src/cmn.rs' + api_name = util.library_name(an, version) api_target = util.target_directory_name(an, version, suffix) depends_on_target = '' if make.depends_on_suffix is not None: - depends_on_target = util.target_directory_name(an, version, make.depends_on_suffix) + depends_on_target = directories.output + '/' + util.target_directory_name(an, version, make.depends_on_suffix) + CMN_SRC crate_name = util.library_to_crate_name(api_name, suffix) gen_root = directories.output + '/' + api_target gen_root_stamp = gen_root + '/.timestamp' - api_common = gen_root + '/src/cmn.rs' + api_common = gen_root + CMN_SRC api_clean = api_target + '-clean' api_cargo = api_target + '-cargo' api_doc = api_target + '-doc' diff --git a/src/mako/lib/util.mako b/src/mako/lib/util.mako index c738976b86..14c1a85990 100644 --- a/src/mako/lib/util.mako +++ b/src/mako/lib/util.mako @@ -46,4 +46,8 @@ ${name}\ % else: ${canonicalName}\ % endif + + +<%def name="program_name()" buffered="True">\ +${self.library_name().replace('_', '-')}\ \ No newline at end of file