Chromium Code Reviews| Index: chrome/browser/resources/vulcanize_gn.py |
| diff --git a/chrome/browser/resources/vulcanize_gn.py b/chrome/browser/resources/vulcanize_gn.py |
| index 36b4e88c6d57913a187cc3254c849e9a03583ea8..bd220a2cd2010e58317e6ea6e9f3783157c0c098 100755 |
| --- a/chrome/browser/resources/vulcanize_gn.py |
| +++ b/chrome/browser/resources/vulcanize_gn.py |
| @@ -96,7 +96,8 @@ def _undo_mapping(mappings, url): |
| for (redirect_url, file_path) in mappings: |
| if url.startswith(redirect_url): |
| return url.replace(redirect_url, file_path + os.sep) |
| - return url |
| + print >> sys.stderr, 'failed to find: ' + url |
| + raise |
| # Get a list of all files that were bundled with Vulcanize and update the |
| @@ -106,8 +107,22 @@ 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_path = os.path.join(out_path, _REQUEST_LIST_FILE) |
| + request_list = open(request_list_path, 'r').read().splitlines() |
| + |
| + if platform.system() == 'Windows': |
| + # TODO(dbeam): UGH. For some reason Vulcanize is interpreting the target |
| + # file path as a URL and using the drive letter (e.g. D:\) as a protocol. |
| + # This is a little insane, but we're fixing here by normalizing case (which |
| + # really shouldn't matter, these are all file paths and generally are all |
| + # lower case) and writing from / to \ (file path) and then back again. This |
| + # is compounded by NodeJS having a bug in url.resolve() that handles |
| + # chrome:// protocol URLs poorly as well as us using startswith() to strip |
| + # file paths (which isn't crazy awesome either). Don't remove unless you |
| + # really really know what you're doing. |
| + norm = lambda u: u.lower().replace('/', '\\') |
| + request_list = [norm(u).replace(norm(in_path), '').replace('\\', '/') |
| + for u in request_list] |
| # Undo the URL mappings applied by vulcanize to get file paths relative to |
| # current working directory. |
| @@ -116,21 +131,18 @@ def _update_dep_file(in_folder, args): |
| ('chrome://%s/' % args.host, os.path.relpath(in_path, _CWD)), |
| ] |
| - dependencies = map( |
| - lambda url: _undo_mapping(url_mappings, url), request_list) |
| + deps = [_undo_mapping(url_mappings, u) for u in request_list] |
| + deps = map(os.path.normpath, deps) |
| # If the input was a .pak file, the generated depfile should not list files |
| # already in the .pak file. |
| - filtered_dependencies = dependencies |
| if (args.input_type == 'PAK_FILE'): |
| filter_url = os.path.join(args.out_folder, _PAK_UNPACK_FOLDER) |
| - filtered_dependencies = filter( |
| - lambda url: not url.startswith(filter_url), dependencies) |
| + deps = [d for d in deps if d.startswith(filter_url)] |
|
dpapad
2017/02/02 01:39:37
I think this is missing a "not"
deps = [d for d i
dpapad
2017/02/02 01:43:03
Verified locally (on Linux). This was causing the
Dan Beam
2017/02/03 22:42:05
Done.
|
| with open(os.path.join(_CWD, args.depfile), 'w') as f: |
| - f.write(os.path.join( |
| - args.out_folder, args.html_out_file) + ': ' + ' '.join( |
| - filtered_dependencies)) |
| + deps_file_header = os.path.join(args.out_folder, args.html_out_file) |
| + f.write(deps_file_header + ': ' + ' '.join(deps)) |
| def _vulcanize(in_folder, args): |
| @@ -181,7 +193,7 @@ def _vulcanize(in_folder, args): |
| 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) |
| + paths = [os.path.join(out_path, f) for f in files] |
| _run_node([node_modules.PathToPolymerCssBuild()] + paths) |
| @@ -198,7 +210,10 @@ def main(): |
| parser.add_argument('--js_out_file') |
| parser.add_argument('--out_folder') |
| args = parser.parse_args() |
| + |
| + args.depfile = os.path.normpath(args.depfile) |
| args.input = os.path.normpath(args.input) |
| + args.out_folder = os.path.normpath(args.out_folder) |
| vulcanize_input_folder = args.input |