diff options
author | calamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-21 01:13:07 +0000 |
---|---|---|
committer | calamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-21 01:13:07 +0000 |
commit | 712eca0f458b38d5fe47c14932302ad3f14e292d (patch) | |
tree | 905236d46f0a4c471745ead8ad371910b89b5bd0 /tools/json_schema_compiler/compiler.py | |
parent | 17f5abff8f422bbfd63bfbb809a86464fd20f7ce (diff) | |
download | chromium_src-712eca0f458b38d5fe47c14932302ad3f14e292d.zip chromium_src-712eca0f458b38d5fe47c14932302ad3f14e292d.tar.gz chromium_src-712eca0f458b38d5fe47c14932302ad3f14e292d.tar.bz2 |
Add tests to tools/json_schema_compiler
Add tests for different json cases by compiling test jsons and running C++
tests against them. Also fixed bugs where tests failed, removed a dead flag and refactored for readability.
BUG=
TEST=
Review URL: http://codereview.chromium.org/9415001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122781 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/compiler.py')
-rw-r--r-- | tools/json_schema_compiler/compiler.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py index fab0504..d5f0802 100644 --- a/tools/json_schema_compiler/compiler.py +++ b/tools/json_schema_compiler/compiler.py @@ -12,11 +12,10 @@ are in chrome/common/extensions/api. Usage example: compiler.py --root /home/Work/src --namespace extensions windows.json tabs.json - compiler.py --destdir gen --suffix _api --root /home/Work/src + compiler.py --destdir gen --root /home/Work/src --namespace extensions windows.json tabs.json """ -import cpp_util import cc_generator import cpp_type_generator import h_generator @@ -37,15 +36,12 @@ if __name__ == '__main__': help='root directory to output generated files.') parser.add_option('-n', '--namespace', default='generated_api_schemas', help='C++ namespace for generated files. e.g extensions::api.') - parser.add_option('-s', '--suffix', default='', - help='Filename and C++ namespace suffix for generated files.') (opts, args) = parser.parse_args() if not args: sys.exit(parser.get_usage()) dest_dir = opts.destdir root_namespace = opts.namespace - filename_suffix = opts.suffix schema = os.path.normpath(args[0]) referenced_schemas = args[1:] @@ -73,14 +69,15 @@ if __name__ == '__main__': if not namespace: continue - out_file = namespace.name + filename_suffix + # The output filename must match the input filename for gyp to deal with it + # properly. + out_file = namespace.name type_generator = cpp_type_generator.CppTypeGenerator(root_namespace, namespace, out_file) for referenced_namespace in api_model.namespaces.values(): type_generator.AddNamespace( referenced_namespace, - cpp_util.Classname(referenced_namespace.name).lower() + - filename_suffix) + referenced_namespace.unix_name) cc_generator = cc_generator.CCGenerator(namespace, type_generator) cc_code = cc_generator.Generate().Render() h_generator = h_generator.HGenerator(namespace, type_generator) |