OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os.path | 5 import os.path |
6 import sys | 6 import sys |
7 import optparse | 7 import optparse |
8 try: | 8 try: |
9 import json | 9 import json |
10 except ImportError: | 10 except ImportError: |
11 import simplejson as json | 11 import simplejson as json |
12 | 12 |
13 # Path handling for libraries and templates | 13 # Path handling for libraries and templates |
14 # Paths have to be normalized because Jinja uses the exact template path to | 14 # Paths have to be normalized because Jinja uses the exact template path to |
15 # determine the hash used in the cache filename, and we need a pre-caching step | 15 # determine the hash used in the cache filename, and we need a pre-caching step |
16 # to be concurrency-safe. Use absolute path because __file__ is absolute if | 16 # to be concurrency-safe. Use absolute path because __file__ is absolute if |
17 # module is imported, and relative if executed directly. | 17 # module is imported, and relative if executed directly. |
18 # If paths differ between pre-caching and individual file compilation, the cache | 18 # If paths differ between pre-caching and individual file compilation, the cache |
19 # is regenerated, which causes a race condition and breaks concurrent build, | 19 # is regenerated, which causes a race condition and breaks concurrent build, |
20 # since some compile processes will try to read the partially written cache. | 20 # since some compile processes will try to read the partially written cache. |
21 module_path, module_filename = os.path.split(os.path.realpath(__file__)) | 21 module_path, module_filename = os.path.split(os.path.realpath(__file__)) |
22 templates_dir = module_path | 22 templates_dir = module_path |
23 | 23 |
24 # In Blink, jinja2 is in chromium's third_party directory. | 24 # In Blink, jinja2 is in chromium's third_party directory. |
25 # Insert at 1 so at front to override system libraries, and | 25 # Insert at 1 so at front to override system libraries, and |
26 # after path[0] == invoking script dir | 26 # after path[0] == invoking script dir |
27 third_party_dir = os.path.normpath(os.path.join( | 27 blink_third_party_dir = os.path.normpath(os.path.join( |
28 module_path, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, | 28 module_path, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, |
29 "third_party")) | 29 "third_party")) |
30 if os.path.isdir(third_party_dir): | 30 if os.path.isdir(blink_third_party_dir): |
31 sys.path.insert(1, third_party_dir) | 31 sys.path.insert(1, blink_third_party_dir) |
| 32 |
| 33 # In V8, it is in third_party folder |
| 34 v8_third_party_dir = os.path.normpath(os.path.join( |
| 35 module_path, os.pardir, os.pardir, "third_party")) |
| 36 |
| 37 if os.path.isdir(v8_third_party_dir): |
| 38 sys.path.insert(1, v8_third_party_dir) |
32 | 39 |
33 # In Node, it is in deps folder | 40 # In Node, it is in deps folder |
34 deps_dir = os.path.normpath(os.path.join( | 41 deps_dir = os.path.normpath(os.path.join( |
35 module_path, os.pardir, os.pardir, os.pardir, os.pardir, "third_party")) | 42 module_path, os.pardir, os.pardir, os.pardir, os.pardir, "third_party")) |
36 | 43 |
37 if os.path.isdir(deps_dir): | 44 if os.path.isdir(deps_dir): |
38 sys.path.insert(1, os.path.join(deps_dir, "jinja2")) | 45 sys.path.insert(1, os.path.join(deps_dir, "jinja2")) |
39 sys.path.insert(1, os.path.join(deps_dir, "markupsafe")) | 46 sys.path.insert(1, os.path.join(deps_dir, "markupsafe")) |
40 | 47 |
41 import jinja2 | 48 import jinja2 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 cpp_file = output_file(cpp_file_name) | 355 cpp_file = output_file(cpp_file_name) |
349 h_file.write(h_template.render(template_context)) | 356 h_file.write(h_template.render(template_context)) |
350 cpp_file.write(cpp_template.render(template_context)) | 357 cpp_file.write(cpp_template.render(template_context)) |
351 h_file.close() | 358 h_file.close() |
352 cpp_file.close() | 359 cpp_file.close() |
353 | 360 |
354 | 361 |
355 for domain in json_api["domains"]: | 362 for domain in json_api["domains"]: |
356 if domain["domain"] in generate_domains: | 363 if domain["domain"] in generate_domains: |
357 generate(domain) | 364 generate(domain) |
OLD | NEW |