| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """This script drives the execution of the Mojom parser.""" | 6 """This script drives the execution of the Mojom parser.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import platform | 9 import platform |
| 10 import subprocess | 10 import subprocess |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 mojom_parser = os.path.join(sdk_root, "tools", "bindings", "mojom_parser", | 61 mojom_parser = os.path.join(sdk_root, "tools", "bindings", "mojom_parser", |
| 62 "bin", system_dirs[system], "mojom_parser") | 62 "bin", system_dirs[system], "mojom_parser") |
| 63 | 63 |
| 64 if not os.path.exists(mojom_parser): | 64 if not os.path.exists(mojom_parser): |
| 65 raise Exception( | 65 raise Exception( |
| 66 "The mojom parser could not be found at %s. " | 66 "The mojom parser could not be found at %s. " |
| 67 "You may need to run gclient sync." | 67 "You may need to run gclient sync." |
| 68 % mojom_parser) | 68 % mojom_parser) |
| 69 | 69 |
| 70 cmd = [mojom_parser] | 70 cmd = [mojom_parser, "parse"] |
| 71 if import_directories: | 71 if import_directories: |
| 72 cmd.extend(["-I", ",".join(import_directories)]) | 72 cmd.extend(["-I", ",".join(import_directories)]) |
| 73 if meta_data_only: | 73 if meta_data_only: |
| 74 cmd.extend(["-meta-data-only"]) | 74 cmd.extend(["-meta-data-only"]) |
| 75 | 75 |
| 76 cmd.extend(file_names) | 76 cmd.extend(file_names) |
| 77 | 77 |
| 78 try: | 78 try: |
| 79 return subprocess.check_output(cmd) | 79 return subprocess.check_output(cmd) |
| 80 except subprocess.CalledProcessError: | 80 except subprocess.CalledProcessError: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 Returns: | 118 Returns: |
| 119 {mojom_files.MojomFileGraph} The deserialized MojomFileGraph obtained by | 119 {mojom_files.MojomFileGraph} The deserialized MojomFileGraph obtained by |
| 120 deserializing the bytes returned by mojom parser, or None if the mojom | 120 deserializing the bytes returned by mojom parser, or None if the mojom |
| 121 parser returned a non-zero error code. | 121 parser returned a non-zero error code. |
| 122 """ | 122 """ |
| 123 serialized_bytes = RunParser(sdk_root, file_names, import_directories, | 123 serialized_bytes = RunParser(sdk_root, file_names, import_directories, |
| 124 meta_data_only) | 124 meta_data_only) |
| 125 if serialized_bytes is None: | 125 if serialized_bytes is None: |
| 126 return None | 126 return None |
| 127 return DeserializeMojomFileGraph(serialized_bytes) | 127 return DeserializeMojomFileGraph(serialized_bytes) |
| OLD | NEW |