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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tools/polymer/generate_compiled_resources_gypi.py
diff --git a/tools/polymer/generate_compiled_resources_gypi.py b/tools/polymer/generate_compiled_resources_gypi.py
new file mode 100755
index 0000000000000000000000000000000000000000..eedbfc1db51ec1d21193e8b19718b96799a87212
--- /dev/null
+++ b/tools/polymer/generate_compiled_resources_gypi.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from bs4 import BeautifulSoup
+from datetime import date
+import os.path as path
+import pprint
+import sys
+
+
+_SRC = path.join(path.dirname(path.abspath(__file__)), "..", "..")
+_COMPILE_JS = path.join(
+ _SRC, "third_party", "closure_compiler", "compile_js2.gypi")
+_POLYMERS = ['polymer%s.html' % p for p in ('', '-mini', '-micro')]
+
+
+def main(html_files):
+ targets = []
+
+ for html_file in html_files:
+ basename = path.basename(html_file)
+ if basename in _POLYMERS:
+ continue
+
+ dependencies = []
+
+ parsed = BeautifulSoup(open(html_file), "html.parser")
+ imports = set(i.get("href") for i in parsed.find_all("link", rel="import"))
+
+ for html_import in sorted(imports):
+ dirname, import_basename = path.split(html_import)
+ if import_basename in _POLYMERS:
+ continue
+ target = "compiled_resources2.gyp:" + import_basename[:-5] + "-extracted"
+ dependencies.append(path.join(dirname, target))
+
+ target = {
+ "includes": [path.relpath(_COMPILE_JS, path.dirname(html_file))],
+ "target_name": basename[:-5] + "-extracted",
+ }
+
+ if dependencies:
+ target["dependencies"] = dependencies
+
+ targets.append(target)
+
+ if not targets:
+ return
+
+ print """
+# Copyright %d The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+""".strip() % date.today().year
+
+ pp = pprint.PrettyPrinter(indent=2)
+ pp.pprint({"targets": targets})
+
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
« 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