summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrockot@chromium.org <rockot@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 10:11:19 +0000
committerrockot@chromium.org <rockot@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 10:11:19 +0000
commit704a900dae24b39386940a88978a3b31fdd0a805 (patch)
treec167257cf7d99e6ac7163a4f3f6f0d385111f8de
parenta6f76d55135f0b0082d8b6a859bf6dbc3ba2c99c (diff)
downloadchromium_src-704a900dae24b39386940a88978a3b31fdd0a805.zip
chromium_src-704a900dae24b39386940a88978a3b31fdd0a805.tar.gz
chromium_src-704a900dae24b39386940a88978a3b31fdd0a805.tar.bz2
Add an implementation path option to json_schema_compiler
This replaces the hard-coded chrome/browser/extensions/api path with a command-line option (impl_dir). BUG=349019 Review URL: https://codereview.chromium.org/183763032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254995 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/json_schema_bundle_compile.gypi4
-rw-r--r--build/json_schema_compile.gypi5
-rwxr-xr-xtools/json_schema_compiler/compiler.py11
-rw-r--r--tools/json_schema_compiler/cpp_bundle_generator.py9
-rwxr-xr-xtools/json_schema_compiler/dart_generator_test.py2
5 files changed, 24 insertions, 7 deletions
diff --git a/build/json_schema_bundle_compile.gypi b/build/json_schema_bundle_compile.gypi
index 630e9c6..39576ad 100644
--- a/build/json_schema_bundle_compile.gypi
+++ b/build/json_schema_bundle_compile.gypi
@@ -9,8 +9,11 @@
# cc_dir: path to generated files
# root_namespace: the C++ namespace that all generated files go under
# Functions and namespaces can be excluded by setting "nocompile" to true.
+ # The default root path of API implementation sources is
+ # chrome/browser/extensions/api and can be overridden by setting "impl_dir".
'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler',
'api_gen': '<(api_gen_dir)/compiler.py',
+ 'impl_dir%': 'chrome/browser/extensions/api',
},
'actions': [
{
@@ -43,6 +46,7 @@
'--destdir=<(SHARED_INTERMEDIATE_DIR)',
'--namespace=<(root_namespace)',
'--generator=cpp-bundle',
+ '--impl-dir=<(impl_dir)',
'<@(schema_files)',
'<@(non_compiled_schema_files)',
],
diff --git a/build/json_schema_compile.gypi b/build/json_schema_compile.gypi
index 4f1c295..c446603 100644
--- a/build/json_schema_compile.gypi
+++ b/build/json_schema_compile.gypi
@@ -9,8 +9,11 @@
# cc_dir: path to generated files
# root_namespace: the C++ namespace that all generated files go under
# Functions and namespaces can be excluded by setting "nocompile" to true.
+ # The default root path of API implementation sources is
+ # chrome/browser/extensions/api and can be overridden by setting "impl_dir".
'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler',
'api_gen': '<(api_gen_dir)/compiler.py',
+ 'impl_dir%': 'chrome/browser/extensions/api',
},
'rules': [
{
@@ -47,6 +50,7 @@
'--destdir=<(SHARED_INTERMEDIATE_DIR)',
'--namespace=<(root_namespace)',
'--generator=cpp',
+ '--impl-dir=<(impl_dir)'
],
'message': 'Generating C++ code from <(RULE_INPUT_PATH) json files',
'process_outputs_as_sources': 1,
@@ -85,6 +89,7 @@
'--destdir=<(SHARED_INTERMEDIATE_DIR)',
'--namespace=<(root_namespace)',
'--generator=cpp',
+ '--impl-dir=<(impl_dir)'
],
'message': 'Generating C++ code from <(RULE_INPUT_PATH) IDL files',
'process_outputs_as_sources': 1,
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py
index c79beaec..1773d4b 100755
--- a/tools/json_schema_compiler/compiler.py
+++ b/tools/json_schema_compiler/compiler.py
@@ -38,7 +38,8 @@ def GenerateSchema(generator,
root,
destdir,
root_namespace,
- dart_overrides_dir):
+ dart_overrides_dir,
+ impl_dir):
schema_loader = SchemaLoader(
os.path.dirname(os.path.relpath(os.path.normpath(filenames[0]), root)),
os.path.dirname(filenames[0]))
@@ -82,7 +83,8 @@ def GenerateSchema(generator,
api_defs,
type_generator,
root_namespace,
- namespace.source_file_dir)
+ namespace.source_file_dir,
+ impl_dir)
generators = [
('generated_api.cc', cpp_bundle_generator.api_cc_generator),
('generated_api.h', cpp_bundle_generator.api_h_generator),
@@ -138,6 +140,8 @@ if __name__ == '__main__':
' %s' % GENERATORS)
parser.add_option('-D', '--dart-overrides-dir', dest='dart_overrides_dir',
help='Adds custom dart from files in the given directory (Dart only).')
+ parser.add_option('-i', '--impl-dir', dest='impl_dir',
+ help='The root path of all API implementations')
(opts, filenames) = parser.parse_args()
@@ -151,6 +155,7 @@ if __name__ == '__main__':
"Unless in bundle mode, only one file can be specified at a time.")
result = GenerateSchema(opts.generator, filenames, opts.root, opts.destdir,
- opts.namespace, opts.dart_overrides_dir)
+ opts.namespace, opts.dart_overrides_dir,
+ opts.impl_dir)
if not opts.destdir:
print result
diff --git a/tools/json_schema_compiler/cpp_bundle_generator.py b/tools/json_schema_compiler/cpp_bundle_generator.py
index 1cadff8..09163cd 100644
--- a/tools/json_schema_compiler/cpp_bundle_generator.py
+++ b/tools/json_schema_compiler/cpp_bundle_generator.py
@@ -40,13 +40,15 @@ class CppBundleGenerator(object):
api_defs,
cpp_type_generator,
cpp_namespace,
- source_file_dir):
+ source_file_dir,
+ impl_dir):
self._root = root
self._model = model
self._api_defs = api_defs
self._cpp_type_generator = cpp_type_generator
self._cpp_namespace = cpp_namespace
self._source_file_dir = source_file_dir
+ self._impl_dir = impl_dir
self.api_cc_generator = _APICCGenerator(self)
self.api_h_generator = _APIHGenerator(self)
@@ -183,8 +185,9 @@ class _APICCGenerator(object):
namespace_name = namespace.unix_name.replace("experimental_", "")
implementation_header = namespace.compiler_options.get(
"implemented_in",
- "chrome/browser/extensions/api/%s/%s_api.h" % (namespace_name,
- namespace_name))
+ "%s/%s/%s_api.h" % (self._bundle._impl_dir,
+ namespace_name,
+ namespace_name))
if not os.path.exists(
os.path.join(self._bundle._root,
os.path.normpath(implementation_header))):
diff --git a/tools/json_schema_compiler/dart_generator_test.py b/tools/json_schema_compiler/dart_generator_test.py
index fd88625..b01d467 100755
--- a/tools/json_schema_compiler/dart_generator_test.py
+++ b/tools/json_schema_compiler/dart_generator_test.py
@@ -32,7 +32,7 @@ class DartTest(unittest.TestCase):
if REBASE_MODE:
output_dir = TESTS_DIR
output_code = GenerateSchema('dart', ['%s.idl' % file_rel], TESTS_DIR,
- output_dir, None, None)
+ output_dir, None, None, None)
if not REBASE_MODE:
with open('%s.dart' % file_rel) as f: