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

Side by Side Diff: tools/polymer/generate_compiled_resources_gyp.py

Issue 1908273002: [tools] fix target_name ordering bug in generate_compiled_resources_gyp.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: whoops Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 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 from bs4 import BeautifulSoup 6 from bs4 import BeautifulSoup
7 from datetime import date 7 from datetime import date
8 import os.path as path 8 import os.path as path
9 import sys 9 import sys
10 10
(...skipping 14 matching lines...) Expand all
25 'targets': [ 25 'targets': [
26 %s 26 %s
27 ], 27 ],
28 } 28 }
29 """.strip() 29 """.strip()
30 30
31 31
32 def main(created_by, html_files): 32 def main(created_by, html_files):
33 targets = "" 33 targets = ""
34 34
35 for html_file in html_files: 35 def _target_name(target_file):
36 assert target_file.endswith(".html")
37 return path.basename(target_file)[:-len(".html")] + "-extracted"
38
39 for html_file in sorted(html_files, key=lambda h: _target_name(h)):
michaelpg 2016/04/22 00:49:04 is the lambda necessary, or can this be just "sort
Dan Beam 2016/04/22 00:59:18 Done.
36 html_base = path.basename(html_file) 40 html_base = path.basename(html_file)
37 if html_base in _POLYMERS: 41 if html_base in _POLYMERS:
38 continue 42 continue
39 43
40 parsed = BeautifulSoup(open(html_file), "html.parser") 44 parsed = BeautifulSoup(open(html_file), "html.parser")
41 imports = set(i.get("href") for i in parsed.find_all("link", rel="import")) 45 imports = set(i.get("href") for i in parsed.find_all("link", rel="import"))
42 46
43 html_dir = path.dirname(html_file) 47 html_dir = path.dirname(html_file)
44 dependencies = [] 48 dependencies = []
45 49
46 for html_import in sorted(imports): 50 for html_import in sorted(imports):
47 import_dir, import_base = path.split(html_import.encode("ascii")) 51 import_dir, import_base = path.split(html_import.encode("ascii"))
48 if import_base in _POLYMERS: 52 if import_base in _POLYMERS:
49 continue 53 continue
50 54
51 if import_base == _WEB_ANIMATIONS_BASE: 55 if import_base == _WEB_ANIMATIONS_BASE:
52 dependencies.append(_WEB_ANIMATIONS_TARGET) 56 dependencies.append(_WEB_ANIMATIONS_TARGET)
53 continue 57 continue
54 58
55 target = import_base[:-5] + "-extracted" 59 target = _target_name(import_base)
56 if not path.isfile(path.join(html_dir, import_dir, target + ".js")): 60 if not path.isfile(path.join(html_dir, import_dir, target + ".js")):
57 continue 61 continue
58 62
59 if import_dir: 63 if import_dir:
60 target = "compiled_resources2.gyp:" + target 64 target = "compiled_resources2.gyp:" + target
61 65
62 dependencies.append(path.join(import_dir, target)) 66 dependencies.append(path.join(import_dir, target))
63 67
64 path_to_compile_js = path.relpath(_COMPILE_JS, html_dir) 68 path_to_compile_js = path.relpath(_COMPILE_JS, html_dir)
65 69
66 targets += "\n {" 70 targets += "\n {"
67 targets += "\n 'target_name': '%s-extracted'," % html_base[:-5] 71 targets += "\n 'target_name': '%s-extracted'," % html_base[:-5]
68 if dependencies: 72 if dependencies:
69 targets += "\n 'dependencies': [" 73 targets += "\n 'dependencies': ["
70 targets += "\n '%s'," % "',\n '".join(dependencies) 74 targets += "\n '%s'," % "',\n '".join(dependencies)
71 targets += "\n ]," 75 targets += "\n ],"
72 targets += "\n 'includes': ['%s']," % path_to_compile_js 76 targets += "\n 'includes': ['%s']," % path_to_compile_js
73 targets += "\n }," 77 targets += "\n },"
74 78
75 targets = targets.strip() 79 targets = targets.strip()
76 80
77 if targets: 81 if targets:
78 current_year = date.today().year 82 current_year = date.today().year
79 print _COMPILED_RESOURCES_TEMPLATE % (current_year, created_by, targets) 83 print _COMPILED_RESOURCES_TEMPLATE % (current_year, created_by, targets)
80 84
81 85
82 if __name__ == "__main__": 86 if __name__ == "__main__":
83 main(path.basename(sys.argv[0]), sys.argv[1:]) 87 main(path.basename(sys.argv[0]), sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698