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 import os | 6 import os |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 | 10 |
11 | 11 |
12 _HERE_PATH = os.path.join(os.path.dirname(__file__)) | 12 _HERE_PATH = os.path.join(os.path.dirname(__file__)) |
13 | 13 |
14 _HTML_IN_PATH = os.path.join(_HERE_PATH, 'downloads.html') | 14 _HTML_IN_PATH = os.path.join(_HERE_PATH, 'downloads.html') |
15 _HTML_OUT_PATH = os.path.join(_HERE_PATH, 'vulcanized.html') | 15 _HTML_OUT_PATH = os.path.join(_HERE_PATH, 'vulcanized.html') |
16 _JS_OUT_PATH = os.path.join(_HERE_PATH, 'crisper.js') | 16 _JS_OUT_PATH = os.path.join(_HERE_PATH, 'crisper.js') |
17 | 17 |
18 _SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..', '..')) | 18 _SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..', '..')) |
19 | 19 |
20 _RESOURCES_PATH = os.path.join(_SRC_PATH, 'ui', 'webui', 'resources') | 20 _RESOURCES_PATH = os.path.join(_SRC_PATH, 'ui', 'webui', 'resources') |
21 | 21 |
22 _CR_ELEMENTS_PATH = os.path.join(_RESOURCES_PATH, 'cr_elements') | 22 _CR_ELEMENTS_PATH = os.path.join(_RESOURCES_PATH, 'cr_elements') |
23 _CSS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'css') | 23 _CSS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'css') |
24 _HTML_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'html') | 24 _HTML_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'html') |
25 _JS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'js') | 25 _JS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'js') |
26 | 26 |
27 _POLYMER_PATH = os.path.join( | 27 _POLYMER_PATH = os.path.join( |
28 _SRC_PATH, 'third_party', 'polymer', 'v1_0', 'components-chromium') | 28 _SRC_PATH, 'third_party', 'polymer', 'v1_0', 'components-chromium') |
29 _WEB_ANIMATIONS_PATH = os.path.join( | |
30 _SRC_PATH, 'third_party', 'web-animations-js', 'sources') | |
31 | 29 |
32 _VULCANIZE_ARGS = [ | 30 _VULCANIZE_ARGS = [ |
33 '--exclude', 'crisper.js', | 31 '--exclude', 'crisper.js', |
| 32 |
| 33 # These files are already combined and minified. |
| 34 '--exclude', 'polymer-extracted.js', |
| 35 '--exclude', 'polymer-micro-extracted.js', |
| 36 '--exclude', 'polymer-mini-extracted.js', |
| 37 '--exclude', 'polymer_config.js', |
| 38 '--exclude', 'web-animations-next-lite.min.js', |
| 39 |
| 40 # These files are dynamically created by C++. |
34 '--exclude', 'load_time_data.js', | 41 '--exclude', 'load_time_data.js', |
35 '--exclude', 'strings.js', | 42 '--exclude', 'strings.js', |
36 '--exclude', 'text_defaults.css', | 43 '--exclude', 'text_defaults.css', |
| 44 |
37 '--inline-css', | 45 '--inline-css', |
38 '--inline-scripts', | 46 '--inline-scripts', |
| 47 |
39 '--redirect', 'chrome://downloads/|%s' % _HERE_PATH, | 48 '--redirect', 'chrome://downloads/|%s' % _HERE_PATH, |
40 '--redirect', 'chrome://resources/cr_elements/|%s' % _CR_ELEMENTS_PATH, | 49 '--redirect', 'chrome://resources/cr_elements/|%s' % _CR_ELEMENTS_PATH, |
41 '--redirect', 'chrome://resources/css/|%s' % _CSS_RESOURCES_PATH, | 50 '--redirect', 'chrome://resources/css/|%s' % _CSS_RESOURCES_PATH, |
42 '--redirect', 'chrome://resources/html/|%s' % _HTML_RESOURCES_PATH, | 51 '--redirect', 'chrome://resources/html/|%s' % _HTML_RESOURCES_PATH, |
43 '--redirect', 'chrome://resources/js/|%s' % _JS_RESOURCES_PATH, | 52 '--redirect', 'chrome://resources/js/|%s' % _JS_RESOURCES_PATH, |
44 '--redirect', 'chrome://resources/polymer/v1_0/web-animations-js/|%s' % _WEB_A
NIMATIONS_PATH, | |
45 '--redirect', 'chrome://resources/polymer/v1_0/|%s' % _POLYMER_PATH, | 53 '--redirect', 'chrome://resources/polymer/v1_0/|%s' % _POLYMER_PATH, |
| 54 |
46 '--strip-comments', | 55 '--strip-comments', |
47 ] | 56 ] |
48 | 57 |
49 def main(): | 58 def main(): |
50 def _run_cmd(cmd_parts, stdout=None): | 59 def _run_cmd(cmd_parts, stdout=None): |
51 cmd = "'" + "' '".join(cmd_parts) + "'" | 60 cmd = "'" + "' '".join(cmd_parts) + "'" |
52 process = subprocess.Popen( | 61 process = subprocess.Popen( |
53 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | 62 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) |
54 stdout, stderr = process.communicate() | 63 stdout, stderr = process.communicate() |
55 | 64 |
(...skipping 13 matching lines...) Expand all Loading... |
69 _run_cmd(['crisper', '--source', tmp.name, | 78 _run_cmd(['crisper', '--source', tmp.name, |
70 '--script-in-head', 'false', | 79 '--script-in-head', 'false', |
71 '--html', _HTML_OUT_PATH, | 80 '--html', _HTML_OUT_PATH, |
72 '--js', _JS_OUT_PATH]) | 81 '--js', _JS_OUT_PATH]) |
73 finally: | 82 finally: |
74 os.remove(tmp.name) | 83 os.remove(tmp.name) |
75 | 84 |
76 | 85 |
77 if __name__ == '__main__': | 86 if __name__ == '__main__': |
78 main() | 87 main() |
OLD | NEW |