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

Unified Diff: tools/json_schema_compiler/compiler.py

Issue 10272021: Files generated by the JSON schema compiler are named incorrectly (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Check bundle schema filenames Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/cpp_type_generator_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/compiler.py
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py
index 1d0884152e057200c1ca8f54e65cd6594960060b..06c8c6ead8863bf99f0bcbe28e9b9eecb9e02996 100755
--- a/tools/json_schema_compiler/compiler.py
+++ b/tools/json_schema_compiler/compiler.py
@@ -38,6 +38,9 @@ def load_schema(schema):
else:
sys.exit("Did not recognize file extension %s for schema %s" %
(schema_extension, schema))
+ if len(api_defs) != 1:
+ sys.exit("File %s has multiple schemas. Files are only allowed to contain a"
+ " single schema." % schema)
return api_defs
@@ -68,9 +71,14 @@ def handle_single_schema(filename, dest_dir, root, root_namespace):
if not namespace:
continue
+ path, schema_filename = os.path.split(schema_filename)
not at google - send to devlin 2012/05/12 00:19:37 Rather than doing this every loop, just do it at t
cduvall 2012/05/12 00:59:37 Done.
+ if schema_filename != namespace.unix_name:
+ sys.exit("Filename %s%s is illegal. Name files using unix_hacker style." %
+ (schema_filename, schema_extension))
+
# The output filename must match the input filename for gyp to deal with it
# properly.
- out_file = namespace.name
+ out_file = namespace.unix_name
type_generator = cpp_type_generator.CppTypeGenerator(
root_namespace, namespace, namespace.unix_name)
for referenced_namespace in api_model.namespaces.values():
@@ -78,7 +86,7 @@ def handle_single_schema(filename, dest_dir, root, root_namespace):
continue
type_generator.AddNamespace(
referenced_namespace,
- referenced_namespace.name)
+ referenced_namespace.unix_name)
h_code = (h_generator.HGenerator(namespace, type_generator)
.Generate().Render())
@@ -113,14 +121,18 @@ def handle_bundle_schema(filenames, dest_dir, root, root_namespace):
api_model = model.Model()
relpath = os.path.relpath(os.path.normpath(filenames[0]), root)
- for target_namespace in api_defs:
- api_model.AddNamespace(target_namespace, relpath)
+ for target_namespace, schema_filename in zip(api_defs, filenames):
+ namespace = api_model.AddNamespace(target_namespace, relpath)
+ filename, extension = os.path.splitext(schema_filename)
+ if namespace.unix_name != filename:
not at google - send to devlin 2012/05/12 00:19:37 could you add a comment here explaining why (just
cduvall 2012/05/12 00:59:37 Done.
+ sys.exit("Filename %s is illegal. Name files using unix_hacker style." %
+ schema_filename)
type_generator = cpp_type_generator.CppTypeGenerator(root_namespace)
for referenced_namespace in api_model.namespaces.values():
type_generator.AddNamespace(
referenced_namespace,
- referenced_namespace.name)
+ referenced_namespace.unix_name)
generator = schema_bundle_generator.SchemaBundleGenerator(
api_model, api_defs, type_generator)
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/cpp_type_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698