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

Unified Diff: mojo/public/tools/bindings/mojom_bindings_generator.py

Issue 2171033002: [mojo] Allow bindings generation with explicit relative include paths (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/mojom_bindings_generator.py
diff --git a/mojo/public/tools/bindings/mojom_bindings_generator.py b/mojo/public/tools/bindings/mojom_bindings_generator.py
index 5240dd7f4d2b0660e98794b2658fa8ce624114e8..6e23c5649b1966aa186a6a7cbd5eca26f616b4c4 100755
--- a/mojo/public/tools/bindings/mojom_bindings_generator.py
+++ b/mojo/public/tools/bindings/mojom_bindings_generator.py
@@ -81,8 +81,8 @@ def FindImportFile(dir_name, file_name, search_dirs):
for search_dir in [dir_name] + search_dirs:
path = os.path.join(search_dir, file_name)
if os.path.isfile(path):
- return path
- return os.path.join(dir_name, file_name)
+ return path, search_dir
+ return os.path.join(dir_name, file_name), None
yzshen1 2016/07/21 23:21:51 According to our discussion, I wonder why this is
Luis Héctor Chávez 2016/07/21 23:33:13 Returning this will trigger L178 to print a nice i
class MojomProcessor(object):
def __init__(self, should_generate):
@@ -108,9 +108,10 @@ class MojomProcessor(object):
self._ParseFileAndImports(filename, args.import_directories, [])
return self._GenerateModule(args, remaining_args, generator_modules,
- filename)
+ filename, args.depth)
- def _GenerateModule(self, args, remaining_args, generator_modules, filename):
+ def _GenerateModule(self, args, remaining_args, generator_modules, filename,
+ source_root):
# Return the already-generated module.
if filename in self._processed_files:
return self._processed_files[filename]
@@ -124,17 +125,19 @@ class MojomProcessor(object):
# Process all our imports first and collect the module object for each.
# We use these to generate proper type info.
for import_data in mojom['imports']:
- import_filename = FindImportFile(dirname,
- import_data['filename'],
- args.import_directories)
+ import_filename, import_dir = FindImportFile(dirname,
+ import_data['filename'],
+ args.import_directories)
+ if import_dir is None:
+ import_dir = args.depth
import_data['module'] = self._GenerateModule(
- args, remaining_args, generator_modules, import_filename)
+ args, remaining_args, generator_modules, import_filename, import_dir)
module = OrderedModuleFromData(mojom)
# Set the path as relative to the source root.
module.path = os.path.relpath(os.path.abspath(filename),
- os.path.abspath(args.depth))
+ os.path.abspath(source_root))
# Normalize to unix-style path here to keep the generators simpler.
module.path = module.path.replace('\\', '/')
@@ -185,7 +188,7 @@ class MojomProcessor(object):
dirname = os.path.split(filename)[0]
for imp_entry in tree.import_list:
- import_filename = FindImportFile(dirname,
+ import_filename, _ = FindImportFile(dirname,
imp_entry.import_filename, import_directories)
self._ParseFileAndImports(import_filename, import_directories,
imported_filename_stack + [filename])
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698