Skip to content

Commit

Permalink
feat(mako): cargo.toml template
Browse files Browse the repository at this point in the history
It's quite final, and super easy to change and to read.

It seems we want to use namespaces/shared implementations soon to allow
using defs. In our case, we transform the version in a particular way,
which is easy enough, yet I'd like to use it to make the system more
powerful.
  • Loading branch information
Byron committed Mar 1, 2015
1 parent 2d77857 commit be93825
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
10 changes: 6 additions & 4 deletions etc/api/shared.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Contains values shared among all API implementations
directories:
# directory under which all generated sources should reside
output: ./generated
output: generated
# how to get from `output` back to common library
common: ../
# where are all the API meta files
api_base: ./etc/api
api_base: etc/api
# all mako source files
mako_src: ./src/mako
mako_src: src/mako
api:
list:
- name: youtube
Expand All @@ -19,8 +19,10 @@ api:
# output_dir: optional - not there if unset
cargo:
build_version: "0.0.1"
repo_base_url: https://github.com/Byron/youtube-rs
doc_base_url: http://byron.github.io/youtube-rs
authors:
- Sebastian Thiel <byronimo@gmail>
keywords: [google, protocol]
keywords: [google, protocol, web, api]
# All APIs should live in the same repository
repository_url: https://github.com/Byron/youtube-rs
14 changes: 8 additions & 6 deletions src/mako/cargo.toml.mako
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[package]

name = "youtube3-dev"
version = "0.0.1"
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
description = "A library to facilitate interacting with your youtube account"
repository = "https://github.com/Byron/youtube-rs"
name = "${name}${version[1:]}"
version = "${cargo.build_version}"
authors = [${",\n ".join('"%s"' % a for a in cargo.authors)}]
description = "A library to interact with ${canonicalName} (protocol ${version})"
repository = "${cargo.repo_base_url}/${OUTPUT_DIR}"
homepage = "${documentationLink}"
documentation = "${cargo.doc_base_url}"
license = "MIT"
keywords = ["youtube", "google", "protocol"]
keywords = ["${name}", ${", ".join('"%s"' % k for k in cargo.keywords)}]

[dependencies]
# Just to get hyper to work !
Expand Down
4 changes: 2 additions & 2 deletions src/mako/deps.mako
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%api_info=[]%>\
% for a in api.list:
<%
gen_root = directories.output + '/' + a.name + '_' + a.version
gen_root = directories.output + '/' + a.name + a.version[1:]
api_name = a.name + a.version
api_clean = api_name + '-clean'
# source, destination
Expand All @@ -17,7 +17,7 @@
%>\
${gen_root}: ${' '.join(i[0] for i in sds)} ${api_json_inputs}
@mkdir -p $@
$(TPL) -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} --data-files ${api_json_inputs}
$(TPL) --var OUTPUT_DIR=$@ -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} --data-files ${api_json_inputs}
${api_name}: ${gen_root}
Expand Down

0 comments on commit be93825

Please sign in to comment.