mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2025-12-30 08:08:50 +01:00
feat(mako): mako-render generates output dirs
That way, the makefile doesn't need to know that much anymore, and gets simpler/less verbose. \# Also * Added filters for rust doc string * fixed .PHONY
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,8 +1,6 @@
|
||||
.pyenv
|
||||
*.pyc
|
||||
generated/
|
||||
target
|
||||
**target/
|
||||
.api.deps
|
||||
Cargo.lock
|
||||
**Cargo.lock
|
||||
*.sublime-workspace
|
||||
*.xml
|
||||
|
||||
5
Makefile
5
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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:]
|
||||
|
||||
Reference in New Issue
Block a user