Support deps for bower_component rules

Combine bower components by unzipping their bower_components
directories including transitive dependencies over each other.

Change-Id: Ib1792ba0b17999b7df60babf6ce6a59c292c3eca
This commit is contained in:
Dave Borowitz 2015-11-16 10:42:58 -05:00
parent 3232f85eda
commit c913a9bc7b
4 changed files with 71 additions and 18 deletions

View File

@ -54,10 +54,12 @@ def bower_component(
package,
version,
license,
deps = [],
sha1 = '',
visibility = ['PUBLIC']):
download_name = '%s__download' % name
genrule(
name = name,
name = download_name,
cmd = ' '.join([
'$(exe //tools/js:download_bower)',
'-b', '"%s"' % run_npm_binary('//lib/js:bower'),
@ -67,8 +69,30 @@ def bower_component(
'-s', sha1,
'-o', '$OUT',
]),
out = '%s-%s.zip' % (name, version),
out = '%s.zip' % download_name,
license = license,
visibility = [],
)
renamed_name = '%s__renamed' % name
genrule(
name = renamed_name,
cmd = ' && '.join([
'cd $TMP',
'mkdir bower_components',
'cd bower_components',
'unzip $(location :%s)' % download_name,
'cd ..',
'zip -r $OUT bower_components',
]),
out = '%s.zip' % renamed_name,
visibility = [],
)
genrule(
name = name,
cmd = _combine_components([':%s' % renamed_name] + deps),
out = '%s-%s.zip' % (name, version),
visibility = visibility,
)
@ -77,19 +101,22 @@ def bower_components(
name,
deps,
visibility = ['PUBLIC']):
bc = '$TMP/bower_components'
cmds = ['mkdir %s' % bc, 'cd %s' % bc]
for dep in deps:
cmds.append('unzip $(location %s)' % dep)
cmds.extend(['cd $TMP', 'zip -r $OUT bower_components'])
genrule(
name = name,
cmd = ' && '.join(cmds),
cmd = _combine_components(deps),
out = '%s.bower_components.zip' % name,
visibility = visibility,
)
def _combine_components(deps):
cmds = ['cd $TMP']
for d in deps:
cmds.append('unzip -qo $(location %s)' % d)
cmds.append('zip -r $OUT bower_components')
return ' && '.join(cmds)
VULCANIZE_FLAGS = [
'--inline-scripts',
'--inline-css',

View File

@ -45,6 +45,10 @@ bower_component(
name = 'iron-a11y-keys',
package = 'PolymerElements/iron-a11y-keys',
version = '1.0.3',
deps = [
':iron-a11y-keys-behavior',
':polymer',
],
license = 'polymer',
sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
)
@ -53,6 +57,7 @@ bower_component(
name = 'iron-a11y-keys-behavior',
package = 'PolymerElements/iron-a11y-keys-behavior',
version = '1.0.8',
deps = [':polymer'],
license = 'polymer',
sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
)
@ -61,6 +66,10 @@ bower_component(
name = 'iron-ajax',
package = 'PolymerElements/iron-ajax',
version = '1.1.0',
deps = [
':polymer',
':promise-polyfill',
],
license = 'polymer',
sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
)
@ -69,6 +78,10 @@ bower_component(
name = 'iron-input',
package = 'PolymerElements/iron-input',
version = '1.0.6',
deps = [
':iron-validatable-behavior',
':polymer',
],
license = 'polymer',
sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
)
@ -77,6 +90,7 @@ bower_component(
name = 'iron-meta',
package = 'PolymerElements/iron-meta',
version = '1.1.1',
deps = [':polymer'],
license = 'polymer',
sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
)
@ -85,6 +99,10 @@ bower_component(
name = 'iron-validatable-behavior',
package = 'PolymerElements/iron-validatable-behavior',
version = '1.0.5',
deps = [
':iron-meta',
':polymer',
],
license = 'polymer',
sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
)
@ -101,6 +119,7 @@ bower_component(
name = 'polymer',
package = 'Polymer/polymer',
version = '1.2.2',
deps = [':webcomponentsjs'],
license = 'polymer',
sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
)
@ -109,6 +128,7 @@ bower_component(
name = 'promise-polyfill',
package = 'polymerlabs/promise-polyfill',
version = '1.0.0',
deps = [':polymer'],
license = 'promise-polyfill',
sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
)

View File

@ -3,15 +3,10 @@ include_defs('//lib/js.defs')
bower_components(
name = 'polygerrit_components',
deps = [
'//lib/js:iron-a11y-keys',
'//lib/js:iron-a11y-keys-behavior',
'//lib/js:iron-ajax',
'//lib/js:iron-input',
'//lib/js:iron-meta',
'//lib/js:iron-validatable-behavior',
'//lib/js:page',
'//lib/js:polymer',
'//lib/js:promise-polyfill',
'//lib/js:webcomponentsjs',
'//lib/js:polymer',
'//lib/js:page',
'//lib/js:iron-ajax',
'//lib/js:iron-a11y-keys',
'//lib/js:iron-input',
],
)

View File

@ -14,5 +14,16 @@
"web-component-tester": "*",
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0"
"polymer": "Polymer/polymer#^1.2.1",
"page": "visionmedia/page.js#~1.6.4",
"iron-ajax": "PolymerElements/iron-ajax#~1.0.9",
"iron-a11y-keys": "PolymerElements/iron-a11y-keys#~1.0.3",
"iron-input": "PolymerElements/iron-input#~1.0.6"
},
"devDependencies": {
"web-component-tester": "*",
"iron-test-helpers": "PolymerElements/iron-test-helpers#~1.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"iron-test-helpers": "PolymerElements/iron-test-helpers#~1.0.6"
}
}