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

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

Issue 1702553002: Generate compiled_resources2.gyp for Polymer based on <link rel=import>s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asdf Created 4 years, 10 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
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
4 # found in the LICENSE file.
5
6 from bs4 import BeautifulSoup
7 from datetime import date
8 import os.path as path
9 import pprint
10 import sys
11
12
13 _SRC = path.join(path.dirname(path.abspath(__file__)), "..", "..")
14 _COMPILE_JS = path.join(
15 _SRC, "third_party", "closure_compiler", "compile_js2.gypi")
16 _POLYMERS = ['polymer%s.html' % p for p in ('', '-mini', '-micro')]
17
18
19 def main(html_files):
20 targets = []
21
22 for html_file in html_files:
23 basename = path.basename(html_file)
24 if basename in _POLYMERS:
25 continue
26
27 dependencies = []
28
29 parsed = BeautifulSoup(open(html_file), "html.parser")
30 imports = set(i.get("href") for i in parsed.find_all("link", rel="import"))
31
32 for html_import in sorted(imports):
33 dirname, import_basename = path.split(html_import)
34 if import_basename in _POLYMERS:
35 continue
36 target = "compiled_resources2.gyp:" + import_basename[:-5] + "-extracted"
37 dependencies.append(path.join(dirname, target))
38
39 target = {
40 "includes": [path.relpath(_COMPILE_JS, path.dirname(html_file))],
41 "target_name": basename[:-5] + "-extracted",
42 }
43
44 if dependencies:
45 target["dependencies"] = dependencies
46
47 targets.append(target)
48
49 if not targets:
50 return
51
52 print """
53 # Copyright %d The Chromium Authors. All rights reserved.
54 # Use of this source code is governed by a BSD-style license that can be
55 # found in the LICENSE file.
56 """.strip() % date.today().year
57
58 pp = pprint.PrettyPrinter(indent=2)
59 pp.pprint({"targets": targets})
60
61
62 if __name__ == "__main__":
63 main(sys.argv[1:])
OLDNEW
« third_party/polymer/v1_0/generate_gyp.sh ('K') | « third_party/polymer/v1_0/generate_gyp.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698