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

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

Issue 1700443003: Use the new mojom parser from check_mojom_dart.py. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
Index: mojo/public/tools/bindings/mojom_bindings_generator_v2.py
diff --git a/mojo/public/tools/bindings/mojom_bindings_generator_v2.py b/mojo/public/tools/bindings/mojom_bindings_generator_v2.py
index c58cde2faadc0b3281a5c8e554635e1fed481090..1e35cd6867c65ba8e944482d5b514dd984cebf82 100755
--- a/mojo/public/tools/bindings/mojom_bindings_generator_v2.py
+++ b/mojo/public/tools/bindings/mojom_bindings_generator_v2.py
@@ -8,10 +8,11 @@
import argparse
import os
-import platform
import subprocess
import sys
+import mojom.parse.parser_runner
+
# We assume this script is located in the Mojo SDK in tools/bindings.
BINDINGS_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -25,35 +26,11 @@ def RunParser(args):
{str} The serialized mojom_files.MojomFileGraph returned by mojom parser,
or None if the mojom parser returned a non-zero error code.
"""
- system_dirs = {
- ("Linux", "64bit"): "linux64",
- ("Darwin", "64bit"): "mac64",
- }
- system = (platform.system(), platform.architecture()[0])
- if system not in system_dirs:
- raise Exception("The mojom parser only supports Linux or Mac 64 bits.")
-
- mojom_parser = os.path.join(BINDINGS_DIR,
- "mojom_parser", "bin", system_dirs[system], "mojom_parser")
-
- if args.mojom_parser:
- mojom_parser = args.mojom_parser
- if not os.path.exists(mojom_parser):
- raise Exception(
- "The mojom parser could not be found at %s. "
- "You may need to run gclient sync."
- % mojom_parser)
-
- cmd = [mojom_parser]
- if args.import_directories:
- cmd.extend(["-I", ",".join(args.import_directories)])
-
- cmd.extend(args.filename)
+ sdk_root = os.path.abspath(
+ os.path.join(BINDINGS_DIR, os.path.pardir, os.path.pardir))
- try:
- return subprocess.check_output(cmd)
- except subprocess.CalledProcessError:
- return None
+ return mojom.parse.parser_runner.RunParser(sdk_root, args.filename,
+ args.import_directories)
def RunGenerators(serialized_file_graph, args, remaining_args):
"""Runs the code generators.
« no previous file with comments | « mojo/dart/tools/presubmit/check_mojom_dart.py ('k') | mojo/public/tools/bindings/pylib/mojom/parse/parser_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698