js.bzl: Avoid using deprecated depset union

Change-Id: I3b3d9321fe162597eb6fd8d40fc7340dd4dce74d
This commit is contained in:
David Ostrovsky 2019-03-03 10:58:10 +01:00
parent cc79f8d9b8
commit 83fab68dc5

@ -141,20 +141,20 @@ bower_archive = repository_rule(
) )
def _bower_component_impl(ctx): def _bower_component_impl(ctx):
transitive_zipfiles = depset([ctx.file.zipfile]) transitive_zipfiles = depset(
for d in ctx.attr.deps: direct = [ctx.file.zipfile],
transitive_zipfiles += d.transitive_zipfiles transitive = [d.transitive_zipfiles for d in ctx.attr.deps],
)
transitive_licenses = depset() transitive_licenses = depset(
if ctx.file.license: direct = [ctx.file.license],
transitive_licenses += depset([ctx.file.license]) transitive = [d.transitive_licenses for d in ctx.attr.deps],
)
for d in ctx.attr.deps: transitive_versions = depset(
transitive_licenses += d.transitive_licenses direct = ctx.files.version_json,
transitive = [d.transitive_versions for d in ctx.attr.deps],
transitive_versions = depset(ctx.files.version_json) )
for d in ctx.attr.deps:
transitive_versions += d.transitive_versions
return struct( return struct(
transitive_zipfiles = transitive_zipfiles, transitive_zipfiles = transitive_zipfiles,
@ -193,14 +193,14 @@ def _js_component(ctx):
mnemonic = "GenBowerZip", mnemonic = "GenBowerZip",
) )
licenses = depset() licenses = []
if ctx.file.license: if ctx.file.license:
licenses += depset([ctx.file.license]) licenses.append(ctx.file.license)
return struct( return struct(
transitive_zipfiles = list([ctx.outputs.zip]), transitive_zipfiles = list([ctx.outputs.zip]),
transitive_versions = depset(), transitive_versions = depset(),
transitive_licenses = licenses, transitive_licenses = depset(licenses),
) )
js_component = rule( js_component = rule(
@ -243,15 +243,16 @@ def _bower_component_bundle_impl(ctx):
"""A bunch of bower components zipped up.""" """A bunch of bower components zipped up."""
zips = depset() zips = depset()
for d in ctx.attr.deps: for d in ctx.attr.deps:
zips += d.transitive_zipfiles files = d.transitive_zipfiles
versions = depset() # TODO(davido): Make sure the field always contains a depset
for d in ctx.attr.deps: if type(files) == "list":
versions += d.transitive_versions files = depset(files)
zips = depset(transitive = [zips, files])
licenses = depset() versions = depset(transitive = [d.transitive_versions for d in ctx.attr.deps])
for d in ctx.attr.deps:
licenses += d.transitive_versions licenses = depset(transitive = [d.transitive_versions for d in ctx.attr.deps])
out_zip = ctx.outputs.zip out_zip = ctx.outputs.zip
out_versions = ctx.outputs.version_json out_versions = ctx.outputs.version_json