diff options
author | yoz <yoz@chromium.org> | 2014-08-26 17:51:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-27 00:52:34 +0000 |
commit | 3b70ef14be986a3252428cc6d9553bf2c69deb70 (patch) | |
tree | 18167a3e08272d016043fd8972049c6b6c90ee1a /tools/json_schema_compiler/compiler.py | |
parent | 54b4f85af7b2ced969435cc04d2b743cfd5f29e2 (diff) | |
download | chromium_src-3b70ef14be986a3252428cc6d9553bf2c69deb70.zip chromium_src-3b70ef14be986a3252428cc6d9553bf2c69deb70.tar.gz chromium_src-3b70ef14be986a3252428cc6d9553bf2c69deb70.tar.bz2 |
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=sky@chromium.org
Review URL: https://codereview.chromium.org/489153003
Cr-Commit-Position: refs/heads/master@{#292057}
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.") |