Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: tools/json_schema_compiler/compiler.py

Issue 12035070: IDL generated extensions code only generate foo_api.h when required (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rework Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/json_schema_compiler/schema_bundle_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Generator for C++ structs from api json files. 5 """Generator for C++ structs from api json files.
6 6
7 The purpose of this tool is to remove the need for hand-written code that 7 The purpose of this tool is to remove the need for hand-written code that
8 converts to and from base::Value types when receiving javascript api calls. 8 converts to and from base::Value types when receiving javascript api calls.
9 Originally written for generating code for extension apis. Reference schemas 9 Originally written for generating code for extension apis. Reference schemas
10 are in chrome/common/extensions/api. 10 are in chrome/common/extensions/api.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 sys.exit("Filename %s is illegal. Name files using unix_hacker style." % 146 sys.exit("Filename %s is illegal. Name files using unix_hacker style." %
147 schema_filename) 147 schema_filename)
148 148
149 type_generator = cpp_type_generator.CppTypeGenerator(root_namespace) 149 type_generator = cpp_type_generator.CppTypeGenerator(root_namespace)
150 for referenced_namespace in api_model.namespaces.values(): 150 for referenced_namespace in api_model.namespaces.values():
151 type_generator.AddNamespace( 151 type_generator.AddNamespace(
152 referenced_namespace, 152 referenced_namespace,
153 referenced_namespace.unix_name) 153 referenced_namespace.unix_name)
154 154
155 generator = schema_bundle_generator.SchemaBundleGenerator( 155 generator = schema_bundle_generator.SchemaBundleGenerator(
156 api_model, api_defs, type_generator) 156 root, api_model, api_defs, type_generator)
157 api_h_code = generator.GenerateAPIHeader().Render() 157 api_h_code = generator.GenerateAPIHeader().Render()
158 schemas_h_code = generator.GenerateSchemasHeader().Render() 158 schemas_h_code = generator.GenerateSchemasHeader().Render()
159 schemas_cc_code = generator.GenerateSchemasCC().Render() 159 schemas_cc_code = generator.GenerateSchemasCC().Render()
160 160
161 if dest_dir: 161 if dest_dir:
162 basedir = os.path.join(dest_dir, 'chrome/common/extensions/api') 162 basedir = os.path.join(dest_dir, 'chrome/common/extensions/api')
163 with open(os.path.join(basedir, 'generated_api.h'), 'w') as h_file: 163 with open(os.path.join(basedir, 'generated_api.h'), 'w') as h_file:
164 h_file.write(api_h_code) 164 h_file.write(api_h_code)
165 with open(os.path.join(basedir, 'generated_schemas.h'), 'w') as h_file: 165 with open(os.path.join(basedir, 'generated_schemas.h'), 'w') as h_file:
166 h_file.write(schemas_h_code) 166 h_file.write(schemas_h_code)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 if not args: 199 if not args:
200 sys.exit(0) # This is OK as a no-op 200 sys.exit(0) # This is OK as a no-op
201 dest_dir = opts.destdir 201 dest_dir = opts.destdir
202 root_namespace = opts.namespace 202 root_namespace = opts.namespace
203 203
204 if opts.bundle: 204 if opts.bundle:
205 handle_bundle_schema(args, dest_dir, opts.root, root_namespace) 205 handle_bundle_schema(args, dest_dir, opts.root, root_namespace)
206 else: 206 else:
207 handle_single_schema(args[0], dest_dir, opts.root, root_namespace) 207 handle_single_schema(args[0], dest_dir, opts.root, root_namespace)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/schema_bundle_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698