Skip to content

Commit acd42df

Browse files
committed
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.
1 parent 3e0a24d commit acd42df

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ endif
2828
API_JSON_FILES = $(shell find etc -type f -name '*-api.json')
2929
MAKO_LIB_DIR = $(MAKO_SRC)/lib
3030
MAKO_LIB_FILES = $(shell find $(MAKO_LIB_DIR) -type f -name '*.*')
31-
MAKO = PYTHONPATH=$(MAKO_LIB_DIR) $(TPL) --template-dir '.'
31+
MAKO = $(TPL) --template-dir '.'
32+
PYPATH = PYTHONPATH=$(MAKO_LIB_DIR)
3233
MAKO_STANDARD_DEPENDENCIES = $(API_SHARED_INFO) $(MAKO_LIB_FILES) $(MAKO_RENDER)
3334

3435
help:
@@ -60,10 +61,10 @@ $(MAKO_RENDER): $(PYTHON)
6061
# Explicitly NOT depending on $(MAKO_LIB_FILES), as it's quite stable and now takes 'too long' thanks
6162
# to a URL get call to the google discovery service
6263
$(API_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(TYPE_API_INFO) $(API_LIST)
63-
$(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_API_INFO) $(API_LIST)
64+
$(PYPATH) $(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_API_INFO) $(API_LIST)
6465

6566
$(CLI_DEPS): $(API_DEPS_TPL) $(API_SHARED_INFO) $(MAKO_RENDER) $(TYPE_CLI_INFO) $(API_LIST)
66-
$(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_CLI_INFO) $(API_LIST)
67+
$(PYPATH) $(MAKO) -io $(API_DEPS_TPL)=$@ --data-files $(API_SHARED_INFO) $(TYPE_CLI_INFO) $(API_LIST)
6768

6869
deps: $(API_DEPS) $(CLI_DEPS)
6970

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# transform name to be a suitable subcommand
1212
def mangle_subcommand(name):
13-
return util.camel_to_under(name).replace('_', '-').replace('.', '-')
13+
return util.camel_to_under(util.singular(name)).replace('_', '-').replace('.', '-')
1414

1515

1616
# transform the resource name into a suitable filename to contain the markdown documentation for it

src/mako/cli/main.rs.mako

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern crate rustc_serialize;
1818
${docopt.new(c)}\
1919

2020
fn main() {
21-
let _: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
21+
let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
22+
println!("{:?}", args);
2223
println!("Hello, ${id} !");
2324
}

src/mako/deps.mako

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232
if mako is not UNDEFINED:
3333
post_processor_arg = '--post-process-python-module=%s' % mako.post_processor_module
3434
35+
python_path = 'PYTHONPATH=$(MAKO_LIB_DIR)'
3536
try:
3637
root = directories.mako_src + '/' + make.id + '/lib'
3738
lib_files = [os.path.join(root, file_name) for file_name in os.listdir(root)]
39+
python_path += ':%s' % root
3840
except OSError:
3941
lib_files = list()
4042
%>\
@@ -89,7 +91,7 @@ ${api_common}: $(RUST_SRC)/${make.id}/cmn.rs $(lastword $(MAKEFILE_LIST)) ${gen_
8991

9092
${gen_root_stamp}: ${' '.join(i[0] for i in sds)} ${' '.join(lib_files)} ${api_json_inputs} $(MAKO_STANDARD_DEPENDENCIES) ${depends_on_target}
9193
@echo Generating ${api_target}
92-
@$(MAKO) -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} ${post_processor_arg} --data-files ${api_json_inputs}
94+
@${python_path} $(MAKO) -io ${' '.join("%s=%s" % (s, d) for s, d in sds)} ${post_processor_arg} --data-files ${api_json_inputs}
9395
@touch $@
9496

9597
${api_target}: ${api_common}
@@ -134,7 +136,7 @@ gen-all${agsuffix}: ${space_join(0)}
134136

135137
% if global_targets:
136138
${doc_index}: docs${agsuffix} ${type_specific_json} ## TODO: all type dependencies: docs-api, docs-cli
137-
$(MAKO) --var DOC_ROOT=${doc_root} -io $(MAKO_SRC)/index.html.mako=$@ --data-files $(API_SHARED_INFO) $(API_LIST) ${type_specific_json}
139+
$(PYPATH) $(MAKO) --var DOC_ROOT=${doc_root} -io $(MAKO_SRC)/index.html.mako=$@ --data-files $(API_SHARED_INFO) $(API_LIST) ${type_specific_json}
138140
@echo Documentation index created at '$@'
139141
docs-all: ${doc_index}
140142
docs-all-clean:

0 commit comments

Comments
 (0)