Skip to content

Commit

Permalink
feat(mako): api deps generation works
Browse files Browse the repository at this point in the history
It's very pleasant to use, and worth the slightly greater effort.
  • Loading branch information
Byron committed Mar 1, 2015
1 parent 20410ad commit 30041e9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ API_SHARED_INFO = ./etc/api/shared.yaml
API_JSON_FILES = $(shell find ./etc -type f -name '*-api.json')

help:
$(info Programs)
$(info ----> templat engine: '$(TPL)')
$(info using template engine: '$(TPL)')
$(info )
$(info Targets)
$(info help - print this help)
Expand All @@ -30,13 +29,13 @@ $(PYTHON):
$(MAKO_RENDER): $(PYTHON)

$(API_DEPS): $(API_SHARED_INFO) $(API_DEPS_TPL) $(MAKO_RENDER)
$(TPL) --data-files $(API_SHARED_INFO) $(API_DEPS_TPL) > $@
$(TPL) --data-files $(API_SHARED_INFO) --var SHARED_INFO_FILE=$(API_SHARED_INFO) $(API_DEPS_TPL) > $@

api-deps: $(API_DEPS)

include $(API_DEPS)

clean:
clean: clean-api
-rm -Rf $(VENV_DIR)
-rm $(API_DEPS)

Expand Down
2 changes: 1 addition & 1 deletion etc/bin/mako-render
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def cmdline(argv=None):
data = load_data(datafiles)
data = dict((k, DictObject(v)) for k, v in data.items())
data.update(dict([varsplit(var) for var in options.var]))

try:
print(template.render(**data))
except:
Expand Down
1 change: 1 addition & 0 deletions etc/sublime-text/youtube-rs.sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"folder_exclude_patterns" : [
"target",
".git",
".pyenv"
],
},
]
Expand Down
24 changes: 24 additions & 0 deletions src/mako/deps.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<%api_info=[]%>
% for a in api.list:
<%
gen_root = directories.output + '/' + a.name + '_' + a.version
api_name = a.name + a.version
api_clean = api_name + '-clean'
api_info.append((api_name, api_clean, gen_root))
%>
${gen_root}: ${directories.api_base}/${a.name}/${a.version}/${a.name}-api.json ${SHARED_INFO_FILE}
${api_name}: ${gen_root}
@echo TODO ${api_name} command
${api_clean}:
-rm -Rf ${gen_root}
% endfor
.PHONY += $(.PHONY) ${' '.join(a[0] for a in api_info)} ${' '.join(a[1] for a in api_info)}
help-api:
% for a in api_info:
$(info ${a[0]} - build the ${a[0]} api)
$(info ${a[1]} - clean all generated files of the ${a[0]} api)
% endfor
clean-api: ${' '.join(a[1] for a in api_info)}

0 comments on commit 30041e9

Please sign in to comment.