Skip to content

Commit

Permalink
feat(mako): generic source/output mappings
Browse files Browse the repository at this point in the history
This includes proper handling of dependencies.
The code is concise, pythonic and quite 'cody', but does the job just
fine.
  • Loading branch information
Byron committed Mar 1, 2015
1 parent 087a076 commit 2d77857
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions etc/api/shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ api:
- name: youtube
version: v3
base_path: "etc/api"
templates:
# all output directories are relative to the one set for the respective API
- source: cargo.toml
# output_dir: optional - not there if unset
cargo:
build_version: "0.0.1"
authors:
Expand Down
9 changes: 7 additions & 2 deletions src/mako/deps.mako
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
gen_root = directories.output + '/' + a.name + '_' + a.version
api_name = a.name + a.version
api_clean = api_name + '-clean'
# source, destination
sds = [(directories.mako_src + '/' + i.source + '.mako', gen_root + i.get('output_dir', '') + '/' + i.source)
for i in api.templates]
api_json = directories.api_base + '/' + a.name + '/' + a.version + '/' + a.name + '-api.json'
api_json_inputs = api_json + " $(API_SHARED_INFO)"
api_info.append((api_name, api_clean, gen_root))
%>\
${gen_root}: ${directories.api_base}/${a.name}/${a.version}/${a.name}-api.json $(API_SHARED_INFO)
${gen_root}: ${' '.join(i[0] for i in sds)} ${api_json_inputs}
@mkdir -p $@
$(TPL) -io ${directories.mako_src}/cargo.toml.mako=$@/cargo.toml --data-files $^
$(TPL) -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 2d77857

Please sign in to comment.