diff options
author | yoz <yoz@chromium.org> | 2014-08-26 20:32:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-27 03:33:52 +0000 |
commit | 774dcda2d369584b2e964fa4971dda71cf819677 (patch) | |
tree | f9e3058e383cb5bf00f263a03c48e44620b3bafd /tools/json_schema_compiler/compiler.py | |
parent | 3f7aec31073c730a68ee221bbd10dca9a60e9a04 (diff) | |
download | chromium_src-774dcda2d369584b2e964fa4971dda71cf819677.zip chromium_src-774dcda2d369584b2e964fa4971dda71cf819677.tar.gz chromium_src-774dcda2d369584b2e964fa4971dda71cf819677.tar.bz2 |
Reland 596ff54335b2a1b393af10657bc4945114f3beed - Split API bundle generation steps
* Fixed in this version: dependencies for *_api_registration on *_api.
Split bundle generation steps so that API registration is generated in browser, not common.
We now have schema generation, schema bundle generation, and schema bundle registration generation; the last of these is generated in a separate build target and output to browser rather than common.
Fix a couple of dangling gyp issues also.
BUG=405226
TBR=scottmg@chromium.org,sky@chromium.org
Review URL: https://codereview.chromium.org/513633002
Cr-Commit-Position: refs/heads/master@{#292090}
Diffstat (limited to 'tools/json_schema_compiler/compiler.py')
-rwxr-xr-x | tools/json_schema_compiler/compiler.py | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py index ff91ccf..38899286 100755 --- a/tools/json_schema_compiler/compiler.py +++ b/tools/json_schema_compiler/compiler.py @@ -30,9 +30,9 @@ from schema_loader import SchemaLoader # Names of supported code generators, as specified on the command-line. # First is default. -GENERATORS = ['cpp', 'cpp-bundle', 'dart'] +GENERATORS = ['cpp', 'cpp-bundle-registration', 'cpp-bundle-schema', 'dart'] -def GenerateSchema(generator, +def GenerateSchema(generator_name, file_paths, root, destdir, @@ -49,7 +49,7 @@ def GenerateSchema(generator, api_def = schema_loader.LoadSchema(os.path.split(schema)[1]) # If compiling the C++ model code, delete 'nocompile' nodes. - if generator == 'cpp': + if generator_name == 'cpp': api_def = json_schema.DeleteNodes(api_def, 'nocompile') api_defs.extend(api_def) @@ -85,7 +85,7 @@ def GenerateSchema(generator, type_generator = CppTypeGenerator(api_model, schema_loader, default_namespace) - if generator == 'cpp-bundle': + if generator_name in ('cpp-bundle-registration', 'cpp-bundle-schema'): cpp_bundle_generator = CppBundleGenerator(root, api_model, api_defs, @@ -93,19 +93,24 @@ def GenerateSchema(generator, cpp_namespace_pattern, src_path, impl_dir) - generators = [ - ('generated_api.cc', cpp_bundle_generator.api_cc_generator), - ('generated_api.h', cpp_bundle_generator.api_h_generator), - ('generated_schemas.cc', cpp_bundle_generator.schemas_cc_generator), - ('generated_schemas.h', cpp_bundle_generator.schemas_h_generator) - ] - elif generator == 'cpp': + if generator_name == 'cpp-bundle-registration': + generators = [ + ('generated_api_registration.cc', + cpp_bundle_generator.api_cc_generator), + ('generated_api_registration.h', cpp_bundle_generator.api_h_generator), + ] + elif generator_name == 'cpp-bundle-schema': + generators = [ + ('generated_schemas.cc', cpp_bundle_generator.schemas_cc_generator), + ('generated_schemas.h', cpp_bundle_generator.schemas_h_generator) + ] + elif generator_name == 'cpp': cpp_generator = CppGenerator(type_generator, cpp_namespace_pattern) generators = [ ('%s.h' % filename_base, cpp_generator.h_generator), ('%s.cc' % filename_base, cpp_generator.cc_generator) ] - elif generator == 'dart': + elif generator_name == 'dart': generators = [ ('%s.dart' % namespace.unix_name, DartGenerator( dart_overrides_dir)) @@ -117,7 +122,12 @@ def GenerateSchema(generator, for filename, generator in generators: code = generator.Generate(namespace).Render() if destdir: - output_dir = os.path.join(destdir, src_path) + if generator_name == 'cpp-bundle-registration': + # Function registrations must be output to impl_dir, since they link in + # API implementations. + output_dir = os.path.join(destdir, impl_dir) + else: + output_dir = os.path.join(destdir, src_path) if not os.path.exists(output_dir): os.makedirs(output_dir) with open(os.path.join(output_dir, filename), 'w') as f: @@ -153,7 +163,8 @@ if __name__ == '__main__': sys.exit(0) # This is OK as a no-op # Unless in bundle mode, only one file should be specified. - if opts.generator != 'cpp-bundle' and len(file_paths) > 1: + if (opts.generator not in ('cpp-bundle-registration', 'cpp-bundle-schema') and + len(file_paths) > 1): # TODO(sashab): Could also just use file_paths[0] here and not complain. raise Exception( "Unless in bundle mode, only one file can be specified at a time.") |