OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 import ast | 6 import ast |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 script_dir = os.path.dirname(os.path.realpath(__file__)) | 10 script_dir = os.path.dirname(os.path.realpath(__file__)) |
11 sys.path.insert(0, os.path.join(script_dir, os.pardir, "pylib")) | 11 sys.path.insert(0, os.path.join(script_dir, os.pardir, "pylib")) |
12 | 12 |
13 from generate import mojom_data | 13 from generate import mojom_data |
14 import mojom_cpp_generator | 14 import mojom_cpp_generator |
15 | 15 |
16 def ReadDict(file): | 16 def ReadDict(file): |
17 with open(file, 'r') as f: | 17 with open(file, 'r') as f: |
18 s = f.read() | 18 s = f.read() |
19 dict = ast.literal_eval(s) | 19 dict = ast.literal_eval(s) |
20 return dict | 20 return dict |
21 | 21 |
22 dict = ReadDict(sys.argv[1]) | 22 dict = ReadDict(sys.argv[1]) |
23 module = mojom_data.ModuleFromData(dict) | 23 module = mojom_data.ModuleFromData(dict) |
24 dir = None | 24 dir = None |
25 if len(sys.argv) > 2: | 25 if len(sys.argv) > 2: |
26 dir = sys.argv[2] | 26 dir = sys.argv[2] |
27 cpp = mojom_cpp_generator.Generator(module, ".", dir) | 27 cpp = mojom_cpp_generator.Generator(module, ".", dir) |
28 cpp.GenerateFiles() | 28 cpp.GenerateFiles() |
OLD | NEW |