| 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:])
|
|
|