Skip to content

Commit

Permalink
fix(make): dependencies are now per-program-type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Byron committed Apr 12, 2015
1 parent 3e0a24d commit acd42df
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/mako/lib/cli.py → src/mako/cli/lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/mako/cli/main.rs.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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} !");
}
6 changes: 4 additions & 2 deletions src/mako/deps.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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()
%>\
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit acd42df

Please sign in to comment.