Commit f2ab2bf1 authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI Polymer3: Auto-generate js_library() targets for third_party/polymer/v3_0/.

Specifically:
 - Update v1_0/generate_gn.sh to expect a Polymer version number.
 - Update v1_0/reproduce.sh and v3_0/reproduce.sh to pass a version.
 - Add a new tools/polymer/generate_gn_v3.py, which uses acorn to parse
   a JS file and extract JS imports.
 - Update third_party/polymer/v3_0/package.json to list acorn as
   devDependencies (and move rollup to devDependencies as well).

These files are necessary to type-check WebUI code that uses Polymer3.

Bug: 970885
Change-Id: Iae3e3e2afdb58056af6ac944a7bc4b88e87108c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717524
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682362}
parent c2670b2c
...@@ -6,13 +6,26 @@ ...@@ -6,13 +6,26 @@
dirs=$(find components-chromium -type d | grep -v 'components-chromium/polymer') dirs=$(find components-chromium -type d | grep -v 'components-chromium/polymer')
gn_files='' gn_files=''
polymer_version=$1
if [ "$polymer_version" -eq 3 ];
then
file_extension="js";
else
file_extension="html";
fi
for dir in $dirs; do for dir in $dirs; do
htmls=$(\ls $dir/*.html 2>/dev/null) files=$(\ls $dir/*.$file_extension 2>/dev/null)
if [ "$htmls" ]; then if [ "$files" ]; then
echo "Analyzing $dir" echo "Analyzing $dir"
gn_file="$dir/BUILD.gn" gn_file="$dir/BUILD.gn"
content=$(../../../tools/polymer/generate_gn.py $htmls) if [ "$polymer_version" -eq 3 ];
then
content=$(../../../tools/polymer/generate_gn_v3.py $files);
else
content=$(../../../tools/polymer/generate_gn.py $files);
fi
if [ "$content" ]; then if [ "$content" ]; then
echo "Writing $gn_file" echo "Writing $gn_file"
echo "$content" > "$gn_file" echo "$content" > "$gn_file"
...@@ -25,4 +38,12 @@ for dir in $dirs; do ...@@ -25,4 +38,12 @@ for dir in $dirs; do
fi fi
done done
# Copy components-chromium/polymer BUILD.gn file manually, since it is not
# auto-generated by generate_gn_v3.py.
if [ "$polymer_version" -eq 3 ];
then
cp ./BUILD_polymer.gn "components-chromium/polymer/BUILD.gn"
fi
git cl format $gn_files git cl format $gn_files
...@@ -108,7 +108,7 @@ echo 'Creating a summary of components...' ...@@ -108,7 +108,7 @@ echo 'Creating a summary of components...'
python create_components_summary.py > components_summary.txt python create_components_summary.py > components_summary.txt
echo 'Creating GN files for interfaces and externs...' echo 'Creating GN files for interfaces and externs...'
./generate_gn.sh ./generate_gn.sh 2 # polymer_version=2
popd > /dev/null popd > /dev/null
......
# Copyright 2019 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.
import("//third_party/closure_compiler/compile_js.gni")
js_library("polymer_bundled") {
externs_list = [
"./externs/closure-types.js",
"./externs/polymer-dom-api-externs.js",
"./externs/polymer-externs.js",
"./externs/shadycss-externs.js",
"./externs/webcomponents-externs.js",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("roboto") {
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-a11y-announcer") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-a11y-keys-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-a11y-keys") {
deps = [
"../iron-a11y-keys-behavior:iron-a11y-keys-behavior",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-button-state") {
deps = [
".:iron-control-state",
"../iron-a11y-keys-behavior:iron-a11y-keys-behavior",
"../polymer:polymer_bundled",
]
}
js_library("iron-control-state") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-collapse") {
deps = [
"../iron-resizable-behavior:iron-resizable-behavior",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-dropdown") {
deps = [
"../iron-a11y-keys-behavior:iron-a11y-keys-behavior",
"../iron-behaviors:iron-control-state",
"../iron-overlay-behavior:iron-overlay-behavior",
"../neon-animation:neon-animation-runner-behavior",
"../polymer:polymer_bundled",
]
}
js_library("iron-dropdown-scroll-manager") {
deps = [
"../iron-overlay-behavior:iron-scroll-manager",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-fit-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-flex-layout") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("iron-flex-layout-classes") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-icon") {
deps = [
"../iron-flex-layout:iron-flex-layout",
"../iron-meta:iron-meta",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-iconset-svg") {
deps = [
"../iron-meta:iron-meta",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-input") {
deps = [
"../iron-a11y-announcer:iron-a11y-announcer",
"../iron-validatable-behavior:iron-validatable-behavior",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-list") {
deps = [
"../iron-a11y-keys-behavior:iron-a11y-keys-behavior",
"../iron-resizable-behavior:iron-resizable-behavior",
"../iron-scroll-target-behavior:iron-scroll-target-behavior",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-location") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("iron-query-params") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-media-query") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-meta") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-focusables-helper") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("iron-overlay-backdrop") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("iron-overlay-behavior") {
deps = [
".:iron-focusables-helper",
".:iron-overlay-manager",
".:iron-scroll-manager",
"../iron-fit-behavior:iron-fit-behavior",
"../iron-resizable-behavior:iron-resizable-behavior",
"../polymer:polymer_bundled",
]
}
js_library("iron-overlay-manager") {
deps = [
".:iron-overlay-backdrop",
"../iron-a11y-keys-behavior:iron-a11y-keys-behavior",
"../polymer:polymer_bundled",
]
}
js_library("iron-scroll-manager") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-pages") {
deps = [
"../iron-resizable-behavior:iron-resizable-behavior",
"../iron-selector:iron-selectable",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-range-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-resizable-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-scroll-target-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-scroll-threshold") {
deps = [
"../iron-scroll-target-behavior:iron-scroll-target-behavior",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-multi-selectable") {
deps = [
".:iron-selectable",
"../polymer:polymer_bundled",
]
}
js_library("iron-selectable") {
deps = [
".:iron-selection",
"../polymer:polymer_bundled",
]
}
js_library("iron-selection") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("iron-selector") {
deps = [
".:iron-multi-selectable",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("mock-interactions") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("iron-validatable-behavior") {
deps = [
"../iron-meta:iron-meta",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("neon-animatable") {
deps = [
".:neon-animatable-behavior",
"../iron-resizable-behavior:iron-resizable-behavior",
"../polymer:polymer_bundled",
]
}
js_library("neon-animatable-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("neon-animated-pages") {
deps = [
".:neon-animation-runner-behavior",
"../iron-resizable-behavior:iron-resizable-behavior",
"../iron-selector:iron-selectable",
"../polymer:polymer_bundled",
]
}
js_library("neon-animation-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("neon-animation-runner-behavior") {
deps = [
".:neon-animatable-behavior",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("fade-in-animation") {
deps = [
"..:neon-animation-behavior",
"../../polymer:polymer_bundled",
]
}
js_library("fade-out-animation") {
deps = [
"..:neon-animation-behavior",
"../../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("paper-inky-focus-behavior") {
deps = [
".:paper-ripple-behavior",
"../iron-behaviors:iron-button-state",
"../iron-behaviors:iron-control-state",
"../polymer:polymer_bundled",
]
}
js_library("paper-ripple-behavior") {
deps = [
"../iron-behaviors:iron-button-state",
"../paper-ripple:paper-ripple",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("paper-input-addon-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("paper-input-container") {
deps = [
"../iron-flex-layout:iron-flex-layout",
"../paper-styles:default-theme",
"../paper-styles:typography",
"../polymer:polymer_bundled",
]
}
js_library("paper-input-error") {
deps = [
".:paper-input-addon-behavior",
"../paper-styles:default-theme",
"../paper-styles:typography",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("paper-progress") {
deps = [
"../iron-flex-layout:iron-flex-layout",
"../iron-range-behavior:iron-range-behavior",
"../paper-styles:color",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("paper-ripple") {
deps = [
"../iron-a11y-keys-behavior:iron-a11y-keys-behavior",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("paper-spinner-behavior") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("paper-spinner-lite") {
deps = [
".:paper-spinner-behavior",
".:paper-spinner-styles",
"../paper-styles:color",
"../polymer:polymer_bundled",
]
}
js_library("paper-spinner-styles") {
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("color") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("default-theme") {
deps = [
".:color",
"../polymer:polymer_bundled",
]
}
js_library("demo-pages") {
deps = [
".:color",
".:shadow",
".:typography",
"../iron-flex-layout:iron-flex-layout",
"../polymer:polymer_bundled",
]
}
js_library("shadow") {
deps = [
"../polymer:polymer_bundled",
]
}
js_library("typography") {
deps = [
"../font-roboto:roboto",
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("global") {
deps = [
"..:paper-styles-classes",
"../../polymer:polymer_bundled",
]
}
js_library("shadow") {
deps = [
"../../polymer:polymer_bundled",
]
}
js_library("typography") {
deps = [
"../../font-roboto:roboto",
"../../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("paper-item-styles") {
deps = [
"..:color",
"..:default-theme",
"..:typography",
"../../polymer:polymer_bundled",
]
}
js_library("paper-material-styles") {
deps = [
"..:shadow",
"../../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
#
# NOTE: Created with generate_gn_v3.py, please do not edit.
import("//third_party/closure_compiler/compile_js.gni")
js_library("paper-tooltip") {
deps = [
"../polymer:polymer_bundled",
]
}
# Copyright 2019 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.
import("//third_party/closure_compiler/compile_js.gni")
js_library("polymer_bundled") {
externs_list = [
"./externs/closure-types.js",
"./externs/polymer-dom-api-externs.js",
"./externs/polymer-externs.js",
"./externs/shadycss-externs.js",
"./externs/webcomponents-externs.js",
]
}
...@@ -345,12 +345,14 @@ ...@@ -345,12 +345,14 @@
"@types/estree": { "@types/estree": {
"version": "0.0.39", "version": "0.0.39",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==" "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
"dev": true
}, },
"@types/node": { "@types/node": {
"version": "12.0.3", "version": "12.0.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.3.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.3.tgz",
"integrity": "sha512-zkOxCS/fA+3SsdA+9Yun0iANxzhQRiNwTvJSr6N95JhuJ/x27z9G2URx1Jpt3zYFfCGUXZGL5UDxt5eyLE7wgw==" "integrity": "sha512-zkOxCS/fA+3SsdA+9Yun0iANxzhQRiNwTvJSr6N95JhuJ/x27z9G2URx1Jpt3zYFfCGUXZGL5UDxt5eyLE7wgw==",
"dev": true
}, },
"@webcomponents/shadycss": { "@webcomponents/shadycss": {
"version": "1.9.1", "version": "1.9.1",
...@@ -360,12 +362,14 @@ ...@@ -360,12 +362,14 @@
"acorn": { "acorn": {
"version": "6.1.1", "version": "6.1.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz",
"integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==" "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==",
"dev": true
}, },
"rollup": { "rollup": {
"version": "1.12.4", "version": "1.12.4",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.12.4.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.12.4.tgz",
"integrity": "sha512-sHg0F05oTMJzM592MWU8irsPx8LIFMKSCnEkcp6vp/gnj+oJ9GJEBW9hl8jUqy2L6Q2uUxFzPgvoExLbfuSODA==", "integrity": "sha512-sHg0F05oTMJzM592MWU8irsPx8LIFMKSCnEkcp6vp/gnj+oJ9GJEBW9hl8jUqy2L6Q2uUxFzPgvoExLbfuSODA==",
"dev": true,
"requires": { "requires": {
"@types/estree": "0.0.39", "@types/estree": "0.0.39",
"@types/node": "^12.0.2", "@types/node": "^12.0.2",
......
...@@ -37,7 +37,10 @@ ...@@ -37,7 +37,10 @@
"@polymer/paper-styles": "3.0.1", "@polymer/paper-styles": "3.0.1",
"@polymer/paper-tooltip": "3.0.1", "@polymer/paper-tooltip": "3.0.1",
"@polymer/polymer": "3.2.0", "@polymer/polymer": "3.2.0",
"@webcomponents/shadycss": "1.9.1", "@webcomponents/shadycss": "1.9.1"
},
"devDependencies": {
"acorn": "6.1.1",
"rollup": "1.12.4" "rollup": "1.12.4"
} }
} }
...@@ -26,7 +26,9 @@ pushd "$(dirname "$0")" > /dev/null ...@@ -26,7 +26,9 @@ pushd "$(dirname "$0")" > /dev/null
rm -rf node_modules rm -rf node_modules
npm install --production # Note: The --production flag is omitted, such that devDependencies
# referenced later by this script are also downloaded.
npm install
rsync -c --delete --delete-excluded -r -v --prune-empty-dirs \ rsync -c --delete --delete-excluded -r -v --prune-empty-dirs \
--exclude-from="rsync_exclude.txt" \ --exclude-from="rsync_exclude.txt" \
...@@ -90,5 +92,8 @@ python ../v1_0/rgbify_hex_vars.py --filter-prefix=google --replace \ ...@@ -90,5 +92,8 @@ python ../v1_0/rgbify_hex_vars.py --filter-prefix=google --replace \
components-chromium/paper-styles/color.js components-chromium/paper-styles/color.js
# TODO create components summary # TODO create components summary
# TODO generate gn
echo 'Creating GN files for interfaces and externs...'
../v1_0/generate_gn.sh 3 # polymer_version=3
# TODO find unused elements? # TODO find unused elements?
#!/usr/bin/env python
# Copyright 2019 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 datetime import date
import json
import os.path as path
import sys
_COMPILE_JS = '//third_party/closure_compiler/compile_js.gni'
_WEB_ANIMATIONS_BASE = 'web-animations.html'
_WEB_ANIMATIONS_EXTERNS = \
'//third_party/closure_compiler/externs/web_animations.js'
_COMPILED_RESOURCES_TEMPLATE = '''
# 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.
#
# NOTE: Created with %s, please do not edit.
import("%s")
%s
'''.strip()
_HERE_PATH = path.dirname(__file__)
_SRC_PATH = path.normpath(path.join(_HERE_PATH, '..', '..'))
sys.path.append(path.join(_SRC_PATH, 'third_party', 'node'))
import node
def main(created_by, input_files):
targets = ''
def _target_name(target_file):
return target_file[:-len('.js')]
def _extract_imports(input_file):
path_to_acorn = path.join('node_modules', 'acorn', 'bin', 'acorn');
ast = node.RunNode([path_to_acorn, '--module', input_file])
imports = map(lambda n: n['source']['raw'][1:-1],
filter(lambda n: n['type'] ==
'ImportDeclaration', json.loads(ast)['body']))
return set(imports)
for input_file in sorted(input_files, key=_target_name):
input_base = path.basename(input_file)
imports = _extract_imports(input_file)
dependencies = []
externs = ''
for i in sorted(imports):
import_dir, import_base = path.split(i.encode('ascii'))
if import_base == _WEB_ANIMATIONS_BASE:
externs += '\n externs_list = [ "%s" ]' % _WEB_ANIMATIONS_EXTERNS
continue
# Redirect dependencies to minified Polymer to the non-minified version.
if import_base == 'polymer_bundled.min.js':
import_base = 'polymer_bundled.js'
target = ':' + _target_name(import_base)
dependencies.append(import_dir + target)
targets += '\njs_library("%s") {' % _target_name(input_base)
if dependencies:
targets += '\n deps = ['
targets += '\n "%s",' % '",\n "'.join(dependencies)
targets += '\n ]'
targets += externs
targets += '\n}\n'
targets = targets.strip()
if targets:
current_year = date.today().year
print _COMPILED_RESOURCES_TEMPLATE % (current_year, created_by,
_COMPILE_JS, targets)
if __name__ == '__main__':
main(path.basename(sys.argv[0]), sys.argv[1:])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment