| Index: tools/json_schema_compiler/compiler.py
|
| diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py
|
| index c626f2f96c20570980c9b2637dcdae96c5128271..43aa45bb5f5e387169248db363bc59b4103ecb3f 100755
|
| --- a/tools/json_schema_compiler/compiler.py
|
| +++ b/tools/json_schema_compiler/compiler.py
|
| @@ -44,7 +44,8 @@ def GenerateSchema(generator_name,
|
| cpp_namespace_pattern,
|
| bundle_name,
|
| impl_dir,
|
| - include_rules):
|
| + include_rules,
|
| + custom_output_dir):
|
| # Merge the source files into a single list of schemas.
|
| api_defs = []
|
| for file_path in file_paths:
|
| @@ -126,8 +127,9 @@ def GenerateSchema(generator_name,
|
| ('%s.cc' % filename_base, cpp_generator.cc_generator)
|
| ]
|
| elif generator_name == 'externs':
|
| + print('Generating js externs')
|
| generators = [
|
| - ('%s_externs.js' % namespace.unix_name, JsExternsGenerator())
|
| + ('%s.js' % namespace.unix_name, JsExternsGenerator())
|
| ]
|
| elif generator_name == 'interface':
|
| generators = [
|
| @@ -145,7 +147,8 @@ def GenerateSchema(generator_name,
|
| # API implementations.
|
| output_dir = os.path.join(destdir, impl_dir)
|
| else:
|
| - output_dir = os.path.join(destdir, src_path)
|
| + path = custom_output_dir if custom_output_dir else src_path
|
| + output_dir = os.path.join(destdir, path)
|
| if not os.path.exists(output_dir):
|
| os.makedirs(output_dir)
|
| with open(os.path.join(output_dir, filename), 'w') as f:
|
| @@ -184,6 +187,9 @@ if __name__ == '__main__':
|
| help='A list of paths to include when searching for referenced objects,'
|
| ' with the namespace separated by a \':\'. Example: '
|
| '/foo/bar:Foo::Bar::%(namespace)s')
|
| + parser.add_option('-o', '--output-dir',
|
| + help='A custom output directory under the "gen" folder. If not provided,'
|
| + ' this defaults to the source path.')
|
|
|
| (opts, file_paths) = parser.parse_args()
|
|
|
| @@ -210,6 +216,6 @@ if __name__ == '__main__':
|
|
|
| result = GenerateSchema(opts.generator, file_paths, opts.root, opts.destdir,
|
| opts.namespace, opts.bundle_name, opts.impl_dir,
|
| - include_rules)
|
| + include_rules, opts.output_dir)
|
| if not opts.destdir:
|
| print result
|
|
|