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

Unified Diff: chrome/browser/resources/vulcanize_gn.py

Issue 2670723002: [MD History] Vulcanize as part of GN build. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/vulcanize_gn.py
diff --git a/chrome/browser/resources/vulcanize_gn.py b/chrome/browser/resources/vulcanize_gn.py
index 0b2df59ac2b0f6ae5b0585090ddc1fcd40f5d4a6..17795a27ce190fdb4e1bf67154813e379030547c 100755
--- a/chrome/browser/resources/vulcanize_gn.py
+++ b/chrome/browser/resources/vulcanize_gn.py
@@ -8,7 +8,6 @@ import itertools
import os
import platform
import re
-import subprocess
import sys
import tempfile
@@ -73,24 +72,10 @@ _VULCANIZE_REDIRECT_ARGS = list(itertools.chain.from_iterable(map(
lambda m: ['--redirect', '"%s|%s"' % (m[0], m[1])], _URL_MAPPINGS)))
-_REQUEST_LIST_FILE = 'request_list.txt'
-
-
_PAK_UNPACK_FOLDER = 'flattened'
-
-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()
-
- if stderr:
- print >> sys.stderr, '%s failed: %s' % (cmd, stderr)
- raise
-
- return stdout
-
+def _request_list_path(out_path, html_out_file):
+ return os.path.join(out_path, html_out_file + '.requestlist')
def _undo_mapping(mappings, url):
for (redirect_url, file_path) in mappings:
@@ -106,8 +91,8 @@ def _update_dep_file(in_folder, args):
out_path = os.path.join(_CWD, args.out_folder)
# Prior call to vulcanize already generated the deps list, grab it from there.
- request_list = open(os.path.join(
- out_path, _REQUEST_LIST_FILE), 'r').read().splitlines()
+ request_list = open(_request_list_path(out_path, args.html_out_file),
+ 'r').read().splitlines()
# Undo the URL mappings applied by vulcanize to get file paths relative to
# current working directory.
@@ -134,17 +119,24 @@ def _update_dep_file(in_folder, args):
def _vulcanize(in_folder, out_folder, host, html_in_file,
- html_out_file, js_out_file):
+ html_out_file, js_out_file, exclude):
in_path = os.path.normpath(os.path.join(_CWD, in_folder))
out_path = os.path.join(_CWD, out_folder)
html_out_path = os.path.join(out_path, html_out_file)
js_out_path = os.path.join(out_path, js_out_file)
- output = _run_node(
+ exclude = exclude or []
+
+ exclude_args = []
+ for f in exclude:
+ exclude_args.append('--exclude')
+ exclude_args.append(f)
+
+ output = node.RunNode(
[node_modules.PathToVulcanize()] +
- _VULCANIZE_BASE_ARGS + _VULCANIZE_REDIRECT_ARGS +
- ['--out-request-list', os.path.join(out_path, _REQUEST_LIST_FILE),
+ _VULCANIZE_BASE_ARGS + _VULCANIZE_REDIRECT_ARGS + exclude_args +
+ ['--out-request-list', _request_list_path(out_path, html_out_file),
'--redirect', '"/|%s"' % in_path,
'--redirect', '"chrome://%s/|%s"' % (host, in_path),
# TODO(dpapad): Figure out why vulcanize treats the input path
@@ -159,7 +151,7 @@ def _vulcanize(in_folder, out_folder, host, html_in_file,
'<include src="', '<include src-disabled="'))
try:
- _run_node([node_modules.PathToCrisper(),
+ node.RunNode([node_modules.PathToCrisper(),
'--source', tmp.name,
'--script-in-head', 'false',
'--html', html_out_path,
@@ -167,23 +159,17 @@ def _vulcanize(in_folder, out_folder, host, html_in_file,
# TODO(tsergeant): Remove when JS resources are minified by default:
# crbug.com/619091.
- _run_node([node_modules.PathToUglifyJs(), js_out_path,
+ node.RunNode([node_modules.PathToUglifyJs(), js_out_path,
'--comments', '"/Copyright|license|LICENSE|\<\/?if/"',
'--output', js_out_path])
finally:
os.remove(tmp.name)
-def _css_build(out_folder, files):
- out_path = os.path.join(_CWD, out_folder)
- paths = map(lambda f: os.path.join(out_path, f), files)
-
- _run_node([node_modules.PathToPolymerCssBuild()] + paths)
-
-
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--depfile')
+ parser.add_argument('--exclude', action='append')
parser.add_argument('--host')
parser.add_argument('--html_in_file')
parser.add_argument('--html_out_file')
@@ -200,14 +186,13 @@ def main():
# vulcanize.
if (args.input_type == 'PAK_FILE'):
import unpack_pak
- input_folder = os.path.join(_CWD, args.input)
output_folder = os.path.join(args.out_folder, _PAK_UNPACK_FOLDER)
unpack_pak.unpack(args.input, output_folder)
vulcanize_input_folder = output_folder
_vulcanize(vulcanize_input_folder, args.out_folder, args.host,
- args.html_in_file, args.html_out_file, args.js_out_file)
- _css_build(args.out_folder, files=[args.html_out_file])
+ args.html_in_file, args.html_out_file, args.js_out_file,
+ args.exclude)
_update_dep_file(vulcanize_input_folder, args)

Powered by Google App Engine
This is Rietveld 408576698