diff --git a/.gitignore b/.gitignore index 6fe38ff5b4..cda5827075 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ .pyenv *.pyc -generated/ -target +**target/ .api.deps -Cargo.lock +**Cargo.lock *.sublime-workspace -*.xml diff --git a/Makefile b/Makefile index 737494e8c4..9f54140ccb 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: json-to-xml clean help api-deps +.PHONY: json-to-xml clean help api-deps rebuild-apis .SUFFIXES: include Makefile.helpers @@ -24,6 +24,7 @@ help: $(info Targets) $(info help - print this help) $(info api-deps - generate a file to tell make what API file dependencies will be) + $(info rebuild-apis - clear out all generated apis, and regenerate them) $(info help-api - show all api targets to build individually) $(PYTHON): @@ -39,6 +40,8 @@ api-deps: $(API_DEPS) include $(API_DEPS) +rebuild-apis: clean-apis apis + clean: clean-apis -rm -Rf $(VENV_DIR) -rm $(API_DEPS) diff --git a/etc/api/shared.yaml b/etc/api/shared.yaml index e47e9c65fb..fed2e4156b 100644 --- a/etc/api/shared.yaml +++ b/etc/api/shared.yaml @@ -1,7 +1,7 @@ # Contains values shared among all API implementations directories: # directory under which all generated sources should reside - output: generated + output: lib # how to get from `output` back to common library common: ../ # where are all the API meta files @@ -15,6 +15,7 @@ api: base_path: "etc/api" templates: # all output directories are relative to the one set for the respective API + - source: README.md - source: cargo.toml # output_dir: optional - not there if unset cargo: diff --git a/etc/bin/mako-render b/etc/bin/mako-render index 2dc01bc1a5..2150eaf5fb 100644 --- a/etc/bin/mako-render +++ b/etc/bin/mako-render @@ -5,6 +5,7 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php from argparse import ArgumentParser from os.path import isfile, dirname +import os import sys from mako.template import Template from mako.lookup import TemplateLookup @@ -307,6 +308,8 @@ def cmdline(argv=None): try: result = template.render(**data_converted) if output_file: + if not os.path.isdir(dirname(output_file)): + os.makedirs(dirname(output_file)) fh = open(output_file, "wb") fh.write(result) fh.close() diff --git a/src/mako/deps.mako b/src/mako/deps.mako index a6fd635c6a..a1bd62ebff 100644 --- a/src/mako/deps.mako +++ b/src/mako/deps.mako @@ -19,7 +19,6 @@ api_info.append((api_name, api_clean, gen_root)) %>\ ${gen_root}: ${' '.join(i[0] for i in sds)} ${api_json_inputs} $(MAKO_LIB_FILES) $(MAKO_RENDER) - @mkdir -p $@ PYTHONPATH=$(MAKO_LIB_DIR) $(TPL) --template-dir '.' --var OUTPUT_DIR=$@ -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} --data-files ${api_json_inputs} ${api_name}: ${gen_root} @@ -28,7 +27,7 @@ ${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)} +.PHONY += $(.PHONY) help-api clean-apis apis ${' '.join(a[0] for a in api_info)} ${' '.join(a[1] for a in api_info)} help-api: $(info apis - make all APIs) diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index ac9d21348f..e871dc52ea 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -1,3 +1,13 @@ + +# rust module doc comment filter +def rmdc(s): + return '//! ' + s + +# rust doc comment filter +def rdc(s): + return '/// ' + s + +# Expects v to be 'v\d+', throws otherwise def to_api_version(v): assert len(v) >= 2 and v[0] == 'v' return v[1:]