From acd42dfccc87f49cf5c9bf51a206da8bed9c02c2 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 12 Apr 2015 09:55:17 +0200 Subject: [PATCH] fix(make): dependencies are now per-program-type Previously we put cli.py into the common lib folder, which caused the API to be regenerated and rebuilt whenever we changed code that will only affect the CLI, causing terrible turnaround times. Now the dependency is fixed. --- Makefile | 7 ++++--- src/mako/{ => cli}/lib/cli.py | 2 +- src/mako/cli/main.rs.mako | 3 ++- src/mako/deps.mako | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) rename src/mako/{ => cli}/lib/cli.py (91%) diff --git a/Makefile b/Makefile index 761c8d92c6c..92faff5925f 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,8 @@ endif API_JSON_FILES = $(shell find etc -type f -name '*-api.json') MAKO_LIB_DIR = $(MAKO_SRC)/lib MAKO_LIB_FILES = $(shell find $(MAKO_LIB_DIR) -type f -name '*.*') -MAKO = PYTHONPATH=$(MAKO_LIB_DIR) $(TPL) --template-dir '.' +MAKO = $(TPL) --template-dir '.' +PYPATH = PYTHONPATH=$(MAKO_LIB_DIR) MAKO_STANDARD_DEPENDENCIES = $(API_SHARED_INFO) $(MAKO_LIB_FILES) $(MAKO_RENDER) help: @@ -60,10 +61,10 @@ $(MAKO_RENDER): $(PYTHON) # Explicitly NOT depending on $(MAKO_LIB_FILES), as it's quite stable and now takes 'too long' thanks # to a URL get call to the google discovery service $(API_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(TYPE_API_INFO) $(API_LIST) - $(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_API_INFO) $(API_LIST) + $(PYPATH) $(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_API_INFO) $(API_LIST) $(CLI_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(TYPE_CLI_INFO) $(API_LIST) - $(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_CLI_INFO) $(API_LIST) + $(PYPATH) $(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_CLI_INFO) $(API_LIST) deps: $(API_DEPS) $(CLI_DEPS) diff --git a/src/mako/lib/cli.py b/src/mako/cli/lib/cli.py similarity index 91% rename from src/mako/lib/cli.py rename to src/mako/cli/lib/cli.py index 82a2b1a2bb2..d5dd18df4ae 100644 --- a/src/mako/lib/cli.py +++ b/src/mako/cli/lib/cli.py @@ -10,7 +10,7 @@ # transform name to be a suitable subcommand def mangle_subcommand(name): - return util.camel_to_under(name).replace('_', '-').replace('.', '-') + return util.camel_to_under(util.singular(name)).replace('_', '-').replace('.', '-') # transform the resource name into a suitable filename to contain the markdown documentation for it diff --git a/src/mako/cli/main.rs.mako b/src/mako/cli/main.rs.mako index 02501ed24b0..1551f218270 100644 --- a/src/mako/cli/main.rs.mako +++ b/src/mako/cli/main.rs.mako @@ -18,6 +18,7 @@ extern crate rustc_serialize; ${docopt.new(c)}\ fn main() { - let _: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); + let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); + println!("{:?}", args); println!("Hello, ${id} !"); } \ No newline at end of file diff --git a/src/mako/deps.mako b/src/mako/deps.mako index 0e0c42932bc..3eed06b9632 100644 --- a/src/mako/deps.mako +++ b/src/mako/deps.mako @@ -32,9 +32,11 @@ if mako is not UNDEFINED: post_processor_arg = '--post-process-python-module=%s' % mako.post_processor_module + python_path = 'PYTHONPATH=$(MAKO_LIB_DIR)' try: root = directories.mako_src + '/' + make.id + '/lib' lib_files = [os.path.join(root, file_name) for file_name in os.listdir(root)] + python_path += ':%s' % root except OSError: lib_files = list() %>\ @@ -89,7 +91,7 @@ ${api_common}: $(RUST_SRC)/${make.id}/cmn.rs $(lastword $(MAKEFILE_LIST)) ${gen_ ${gen_root_stamp}: ${' '.join(i[0] for i in sds)} ${' '.join(lib_files)} ${api_json_inputs} $(MAKO_STANDARD_DEPENDENCIES) ${depends_on_target} @echo Generating ${api_target} - @$(MAKO) -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} ${post_processor_arg} --data-files ${api_json_inputs} + @${python_path} $(MAKO) -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} ${post_processor_arg} --data-files ${api_json_inputs} @touch $@ ${api_target}: ${api_common} @@ -134,7 +136,7 @@ gen-all${agsuffix}: ${space_join(0)} % if global_targets: ${doc_index}: docs${agsuffix} ${type_specific_json} ## TODO: all type dependencies: docs-api, docs-cli - $(MAKO) --var DOC_ROOT=${doc_root} -io $(MAKO_SRC)/index.html.mako=$@ --data-files $(API_SHARED_INFO) $(API_LIST) ${type_specific_json} + $(PYPATH) $(MAKO) --var DOC_ROOT=${doc_root} -io $(MAKO_SRC)/index.html.mako=$@ --data-files $(API_SHARED_INFO) $(API_LIST) ${type_specific_json} @echo Documentation index created at '$@' docs-all: ${doc_index} docs-all-clean: