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

Side by Side Diff: mojo/public/tools/bindings/run_code_generators.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 unified diff | Download patch
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/parser_runner.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 accepts the output of version 2 of the mojom parser and uses that 6 # This script accepts the output of version 2 of the mojom parser and uses that
7 # data to invoke the code generators. 7 # data to invoke the code generators.
8 8
9 import argparse 9 import argparse
10 import imp 10 import imp
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 sys.path.insert(0, PYTHON_SDK_DIR) 60 sys.path.insert(0, PYTHON_SDK_DIR)
61 # In order to use mojom_files_mojom we need to make sure the dummy mojo_system 61 # In order to use mojom_files_mojom we need to make sure the dummy mojo_system
62 # can be found on the python path. 62 # can be found on the python path.
63 sys.path.insert(0, os.path.join(PYTHON_SDK_DIR, "dummy_mojo_system")) 63 sys.path.insert(0, os.path.join(PYTHON_SDK_DIR, "dummy_mojo_system"))
64 64
65 sys.path.insert(0, os.path.join(THIS_DIR, "pylib")) 65 sys.path.insert(0, os.path.join(THIS_DIR, "pylib"))
66 66
67 67
68 from mojom.generate.generated import mojom_files_mojom 68 from mojom.generate.generated import mojom_files_mojom
69 from mojom.generate import mojom_translator 69 from mojom.generate import mojom_translator
70 from mojom.parse import parser_runner
70 from mojo_bindings import serialization 71 from mojo_bindings import serialization
71 72
72 73
73 def LoadGenerators(generators_string): 74 def LoadGenerators(generators_string):
74 if not generators_string: 75 if not generators_string:
75 return [] # No generators. 76 return [] # No generators.
76 77
77 generators_dir = os.path.join(THIS_DIR, "generators") 78 generators_dir = os.path.join(THIS_DIR, "generators")
78 generators = [] 79 generators = []
79 for generator_name in [s.strip() for s in generators_string.split(",")]: 80 for generator_name in [s.strip() for s in generators_string.split(",")]:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 def ReadMojomFileGraphFromFile(fp): 113 def ReadMojomFileGraphFromFile(fp):
113 """Reads a mojom_files_mojom.MojomFileGraph from a file. 114 """Reads a mojom_files_mojom.MojomFileGraph from a file.
114 115
115 Args: 116 Args:
116 fp: A file pointer from which a serialized mojom_fileS_mojom.MojomFileGraph 117 fp: A file pointer from which a serialized mojom_fileS_mojom.MojomFileGraph
117 can be read. 118 can be read.
118 119
119 Returns: 120 Returns:
120 The mojom_files_mojom.MojomFileGraph that was deserialized from the file. 121 The mojom_files_mojom.MojomFileGraph that was deserialized from the file.
121 """ 122 """
122 data = bytearray(fp.read()) 123 return parser_runner.DeserializeMojomFileGraph(fp.read())
123 context = serialization.RootDeserializationContext(data, [])
124 return mojom_files_mojom.MojomFileGraph.Deserialize(context)
125
126 124
127 def FixModulePath(module, abs_src_root_path): 125 def FixModulePath(module, abs_src_root_path):
128 """Fix the path attribute of the provided module and its imports. 126 """Fix the path attribute of the provided module and its imports.
129 127
130 The path provided for the various modules is the absolute path to the mojom 128 The path provided for the various modules is the absolute path to the mojom
131 file which the module represents. But the generators expect the path to be 129 file which the module represents. But the generators expect the path to be
132 relative to the root of the source tree. 130 relative to the root of the source tree.
133 131
134 Args: 132 Args:
135 module: {module.Module} whose path is to be updated. 133 module: {module.Module} whose path is to be updated.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 filtered_args = [arg for arg in remaining_args 178 filtered_args = [arg for arg in remaining_args
181 if arg.startswith(prefix)] 179 if arg.startswith(prefix)]
182 if args.generate_type_info: 180 if args.generate_type_info:
183 filtered_args.append("--generate_type_info") 181 filtered_args.append("--generate_type_info")
184 182
185 generator.GenerateFiles(filtered_args) 183 generator.GenerateFiles(filtered_args)
186 184
187 185
188 if __name__ == "__main__": 186 if __name__ == "__main__":
189 sys.exit(main()) 187 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/parser_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698