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

Unified Diff: tools/json_schema_compiler/compiler.py

Issue 232183002: Chromium side changes to add the ledger API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 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 | « extensions/common/permissions/api_permission.h ('k') | tools/metrics/histograms/histograms.xml » ('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 1773d4b136123b24db6a58f1330554adb9636ffc..98f44d743e43d72eeaa9692c4a999e139c864da4 100755
--- a/tools/json_schema_compiler/compiler.py
+++ b/tools/json_schema_compiler/compiler.py
@@ -40,13 +40,13 @@ def GenerateSchema(generator,
root_namespace,
dart_overrides_dir,
impl_dir):
- schema_loader = SchemaLoader(
- os.path.dirname(os.path.relpath(os.path.normpath(filenames[0]), root)),
- os.path.dirname(filenames[0]))
# Merge the source files into a single list of schemas.
api_defs = []
for filename in filenames:
schema = os.path.normpath(filename)
+ schema_loader = SchemaLoader(
+ os.path.dirname(os.path.relpath(os.path.normpath(filename), root)),
+ os.path.dirname(filename))
api_def = schema_loader.LoadSchema(os.path.split(schema)[1])
# If compiling the C++ model code, delete 'nocompile' nodes.
@@ -60,15 +60,25 @@ def GenerateSchema(generator,
# is the default one.
default_namespace = None
+ # If we have files from multiple source paths, we'll use the common parent
+ # path as the source directory.
+ src_path = None
+
# Load the actual namespaces into the model.
for target_namespace, schema_filename in zip(api_defs, filenames):
relpath = os.path.relpath(os.path.normpath(schema_filename), root)
namespace = api_model.AddNamespace(target_namespace,
relpath,
include_compiler_options=True)
+
if default_namespace is None:
default_namespace = namespace
+ if src_path is None:
+ src_path = namespace.source_file_dir
+ else:
+ src_path = os.path.commonprefix((src_path, namespace.source_file_dir))
+
path, filename = os.path.split(schema_filename)
short_filename, extension = os.path.splitext(filename)
@@ -76,14 +86,13 @@ def GenerateSchema(generator,
type_generator = CppTypeGenerator(api_model,
schema_loader,
default_namespace=default_namespace)
-
if generator == 'cpp-bundle':
cpp_bundle_generator = CppBundleGenerator(root,
api_model,
api_defs,
type_generator,
root_namespace,
- namespace.source_file_dir,
+ src_path,
impl_dir)
generators = [
('generated_api.cc', cpp_bundle_generator.api_cc_generator),
@@ -115,8 +124,10 @@ def GenerateSchema(generator,
for filename, generator in generators:
code = generator.Generate(namespace).Render()
if destdir:
- with open(os.path.join(destdir, namespace.source_file_dir,
- filename), 'w') as f:
+ 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:
f.write(code)
output_code += [filename, '', code, '']
« no previous file with comments | « extensions/common/permissions/api_permission.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698