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

Side by Side Diff: chrome/browser/resources/settings/vulcanize.py

Issue 1870853003: Vulcanize settings (hacky and dirty, don't use) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git squash commit. Created 4 years, 5 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
michaelpg 2016/07/01 18:17:23 note: also need to edit vulcanize: $NODE_INSTALLA
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
4 # found in the LICENSE file.
5
6 #TODO: target platform!
7 #pass "chromeos" to vulcanize for chromeos
8
9
10 import os
11 import re
12 import subprocess
13 import shutil
14 import sys
15 import tempfile
16 import flatten_settings
17
18 _HERE_PATH = os.path.join(os.path.dirname(__file__))
19
20 _HTML_OUT_PATH = os.path.join(_HERE_PATH, 'vulcanized.html')
21 _JS_OUT_PATH = os.path.join(_HERE_PATH, 'crisper.js')
22
23 _SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..', '..'))
24
25 _RESOURCES_PATH = os.path.join(_SRC_PATH, 'ui', 'webui', 'resources')
26
27 _CR_ELEMENTS_PATH = os.path.join(_RESOURCES_PATH, 'cr_elements')
28 _CSS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'css')
29 _HTML_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'html')
30 _JS_RESOURCES_PATH = os.path.join(_RESOURCES_PATH, 'js')
31
32 _POLYMER_PATH = os.path.join(
33 _SRC_PATH, 'third_party', 'polymer', 'v1_0', 'components-chromium')
34
35 def main():
36 def _run_cmd(cmd_parts, stdout=None):
37 cmd = "'" + "' '".join(cmd_parts) + "'"
38 process = subprocess.Popen(
39 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
40 stdout, stderr = process.communicate()
41
42 if stderr:
43 print >> sys.stderr, '%s failed: %s' % (cmd, stderr)
44 raise
45
46 return stdout
47
48 def _run_vulcanize(settings_dir):
49 _VULCANIZE_ARGS = [
50 '--exclude', 'crisper.js',
51
52 # These files are already combined and minified.
53 '--exclude', 'chrome://resources/html/polymer.html',
54 '--exclude', 'web-animations-next-lite.min.js',
55
56 # These files are dynamically created by C++.
57 '--exclude', 'load_time_data.js',
58 '--exclude', 'strings.js',
59 '--exclude', 'text_defaults.css',
60 '--exclude', 'text_defaults_md.css',
61
62 '--inline-css',
63 '--inline-scripts',
64
65 # last-to-first
66 '--redirect', '/|%s' % settings_dir,
67 '--redirect', 'chrome://md-settings/|%s' % settings_dir,
68 '--redirect', 'chrome://resources/cr_elements/|%s' % _CR_ELEMENTS_PATH,
69 '--redirect', 'chrome://resources/css/|%s' % _CSS_RESOURCES_PATH,
70 '--redirect', 'chrome://resources/html/|%s' % _HTML_RESOURCES_PATH,
71 '--redirect', 'chrome://resources/js/|%s' % _JS_RESOURCES_PATH,
72 '--redirect', 'chrome://resources/polymer/v1_0/|%s' % _POLYMER_PATH,
73
74 '--strip-comments',
75 ]
76
77 # Relative to
78 _HTML_IN_PATH = os.path.join('/settings.html')
79 output = _run_cmd(['vulcanize'] + _VULCANIZE_ARGS + [_HTML_IN_PATH])
80
81 with tempfile.NamedTemporaryFile(mode='wt+', delete=False) as tmp:
82 tmp.write(output.replace(
83 '<include src="', '<include src="../../../../ui/webui/resources/js/'))
84
85 try:
86 _run_cmd(['crisper', '--source', tmp.name,
87 '--script-in-head', 'false',
88 '--html', _HTML_OUT_PATH,
89 '--js', _JS_OUT_PATH])
90 finally:
91 os.remove(tmp.name)
92
93 chromeos = len(sys.argv) > 1 and sys.argv[1] == 'chromeos'
94 settings_dir = flatten_settings.flatten(sys.argv[1])
95 try:
96 _run_vulcanize(settings_dir)
97 finally:
98 shutil.rmtree(settings_dir)
99
100
101 if __name__ == '__main__':
102 main()
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/settings_menu/settings_menu.js ('k') | chrome/browser/resources/vulcanize.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698