| Index: chrome/browser/resources/vulcanize.py
|
| diff --git a/chrome/browser/resources/vulcanize.py b/chrome/browser/resources/vulcanize.py
|
| index 3256bbb94f883eb9dec80a92d55664127f989e3d..03aeb8fa0c77ffdb13a7004676ad1140ebf04dcf 100755
|
| --- a/chrome/browser/resources/vulcanize.py
|
| +++ b/chrome/browser/resources/vulcanize.py
|
| @@ -8,12 +8,18 @@ import subprocess
|
| import sys
|
| import tempfile
|
|
|
| +
|
| # See //docs/vulcanize.md for instructions on installing prerequistes and
|
| # running the vulcanize build.
|
|
|
| _HERE_PATH = os.path.join(os.path.dirname(__file__))
|
| _SRC_PATH = os.path.normpath(os.path.join(_HERE_PATH, '..', '..', '..'))
|
|
|
| +sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'node'))
|
| +import node
|
| +import node_modules
|
| +
|
| +
|
| _RESOURCES_PATH = os.path.join(_SRC_PATH, 'ui', 'webui', 'resources')
|
|
|
| _CR_ELEMENTS_PATH = os.path.join(_RESOURCES_PATH, 'cr_elements')
|
| @@ -48,8 +54,9 @@ _VULCANIZE_BASE_ARGS = [
|
| '--strip-comments',
|
| ]
|
|
|
| -def _run_cmd(cmd_parts, stdout=None):
|
| - cmd = " ".join(cmd_parts)
|
| +
|
| +def _run_node(cmd_parts, stdout=None):
|
| + cmd = " ".join([node.GetBinaryPath()] + cmd_parts)
|
| process = subprocess.Popen(
|
| cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
| stdout, stderr = process.communicate()
|
| @@ -60,6 +67,7 @@ def _run_cmd(cmd_parts, stdout=None):
|
|
|
| return stdout
|
|
|
| +
|
| def _vulcanize(directory, host, html_in_file, html_out_file='vulcanized.html',
|
| js_out_file='crisper.js', extra_args=None):
|
| print 'Vulcanizing %s/%s' % (directory, html_in_file)
|
| @@ -70,9 +78,9 @@ def _vulcanize(directory, host, html_in_file, html_out_file='vulcanized.html',
|
| js_out_path = os.path.join(target_path, js_out_file)
|
| extra_args = extra_args or []
|
|
|
| - output = _run_cmd(['vulcanize'] + _VULCANIZE_BASE_ARGS + extra_args +
|
| - ['--redirect', '"chrome://%s/|%s"' % (host, target_path),
|
| - html_in_path])
|
| + output = _run_node(
|
| + [node_modules.PathToVulcanize()] + _VULCANIZE_BASE_ARGS + extra_args +
|
| + ['--redirect', '"chrome://%s/|%s"' % (host, target_path), html_in_path])
|
|
|
| with tempfile.NamedTemporaryFile(mode='wt+', delete=False) as tmp:
|
| # Grit includes are not supported, use HTML imports instead.
|
| @@ -80,16 +88,15 @@ def _vulcanize(directory, host, html_in_file, html_out_file='vulcanized.html',
|
| '<include src="', '<include src-disabled="'))
|
|
|
| try:
|
| - _run_cmd(['crisper', '--source', tmp.name,
|
| - '--script-in-head', 'false',
|
| - '--html', html_out_path,
|
| - '--js', js_out_path])
|
| + _run_node([node_modules.PathToCrisper(), '--source', tmp.name,
|
| + '--script-in-head', 'false', '--html', html_out_path,
|
| + '--js', js_out_path])
|
|
|
| # TODO(tsergeant): Remove when JS resources are minified by default:
|
| # crbug.com/619091.
|
| - _run_cmd(['uglifyjs', js_out_path,
|
| - '--comments', '"/Copyright|license|LICENSE|\<\/?if/"',
|
| - '--output', js_out_path])
|
| + _run_node([node_modules.PathToUglifyJs(), js_out_path,
|
| + '--comments', '"/Copyright|license|LICENSE|\<\/?if/"',
|
| + '--output', js_out_path])
|
| finally:
|
| os.remove(tmp.name)
|
|
|
| @@ -98,7 +105,7 @@ def _css_build(directory, files):
|
| target_path = os.path.join(_HERE_PATH, directory)
|
| paths = map(lambda f: os.path.join(target_path, f), files)
|
|
|
| - _run_cmd(['polymer-css-build'] + paths)
|
| + _run_node([node_modules.PathToPolymerCssBuild()] + paths)
|
|
|
|
|
| def main():
|
| @@ -124,5 +131,6 @@ def main():
|
| _css_build(directory='md_history', files=['app.vulcanized.html',
|
| 'lazy_load.vulcanized.html'])
|
|
|
| +
|
| if __name__ == '__main__':
|
| main()
|
|
|