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

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

Issue 77063004: JSON schema compiler: remove SOURCE_BASE_PATH hack from bundle generator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/json_schema_compiler/cpp_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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 # Construct the type generator with all the namespaces in this model. 80 # Construct the type generator with all the namespaces in this model.
81 type_generator = CppTypeGenerator(api_model, 81 type_generator = CppTypeGenerator(api_model,
82 schema_loader, 82 schema_loader,
83 default_namespace=default_namespace) 83 default_namespace=default_namespace)
84 84
85 if generator == 'cpp-bundle': 85 if generator == 'cpp-bundle':
86 cpp_bundle_generator = CppBundleGenerator(root, 86 cpp_bundle_generator = CppBundleGenerator(root,
87 api_model, 87 api_model,
88 api_defs, 88 api_defs,
89 type_generator, 89 type_generator,
90 root_namespace) 90 root_namespace,
91 namespace.source_file_dir)
91 generators = [ 92 generators = [
92 ('generated_api.cc', cpp_bundle_generator.api_cc_generator), 93 ('generated_api.cc', cpp_bundle_generator.api_cc_generator),
93 ('generated_api.h', cpp_bundle_generator.api_h_generator), 94 ('generated_api.h', cpp_bundle_generator.api_h_generator),
94 ('generated_schemas.cc', cpp_bundle_generator.schemas_cc_generator), 95 ('generated_schemas.cc', cpp_bundle_generator.schemas_cc_generator),
95 ('generated_schemas.h', cpp_bundle_generator.schemas_h_generator) 96 ('generated_schemas.h', cpp_bundle_generator.schemas_h_generator)
96 ] 97 ]
97 elif generator == 'cpp': 98 elif generator == 'cpp':
98 cpp_generator = CppGenerator(type_generator, root_namespace) 99 cpp_generator = CppGenerator(type_generator, root_namespace)
99 generators = [ 100 generators = [
100 ('%s.h' % namespace.unix_name, cpp_generator.h_generator), 101 ('%s.h' % namespace.unix_name, cpp_generator.h_generator),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 # Unless in bundle mode, only one file should be specified. 147 # Unless in bundle mode, only one file should be specified.
147 if opts.generator != 'cpp-bundle' and len(filenames) > 1: 148 if opts.generator != 'cpp-bundle' and len(filenames) > 1:
148 # TODO(sashab): Could also just use filenames[0] here and not complain. 149 # TODO(sashab): Could also just use filenames[0] here and not complain.
149 raise Exception( 150 raise Exception(
150 "Unless in bundle mode, only one file can be specified at a time.") 151 "Unless in bundle mode, only one file can be specified at a time.")
151 152
152 result = GenerateSchema(opts.generator, filenames, opts.root, opts.destdir, 153 result = GenerateSchema(opts.generator, filenames, opts.root, opts.destdir,
153 opts.namespace, opts.dart_overrides_dir) 154 opts.namespace, opts.dart_overrides_dir)
154 if not opts.destdir: 155 if not opts.destdir:
155 print result 156 print result
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/cpp_bundle_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698