Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exports in web_library #611

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions closure/webfiles/web_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ load(
"WebFilesInfo",
"create_argfile",
"difference",
"extract_providers",
"long_path",
"unfurl",
"collect_runfiles",
)

def _web_library(ctx):
Expand All @@ -40,12 +42,12 @@ def _web_library(ctx):
fail("when \"*\" is suppressed no other items should be present")

# process what came before
deps = unfurl(ctx.attr.deps, provider = WebFilesInfo)
deps = unfurl(extract_providers(ctx.attr.deps, provider = WebFilesInfo))
webpaths = []
manifests = []
for dep in deps:
webpaths.append(dep[WebFilesInfo].webpaths)
manifests += [dep[WebFilesInfo].manifests]
webpaths.append(dep.webpaths)
manifests.append(dep.manifests)

# process what comes now
new_webpaths = []
Expand Down Expand Up @@ -103,13 +105,11 @@ def _web_library(ctx):
args.append(category)
inputs.extend(ctx.files.srcs)
for dep in deps:
inputs.append(dep[WebFilesInfo].dummy)
for f in dep.files.to_list():
inputs.append(f)
direct_manifests += [dep[WebFilesInfo].manifest]
inputs.append(dep[WebFilesInfo].manifest)
inputs.append(dep.dummy)
direct_manifests.append(dep.manifest)
inputs.append(dep.manifest)
args.append("--direct_dep")
args.append(dep[WebFilesInfo].manifest.path)
args.append(dep.manifest.path)
for man in difference(manifests, depset(direct_manifests)):
inputs.append(man)
args.append("--transitive_dep")
Expand Down Expand Up @@ -147,30 +147,26 @@ def _web_library(ctx):
),
)

transitive_runfiles = depset(
transitive = [ctx.attr.server.data_runfiles.files] +
[dep.data_runfiles.files for dep in deps],
)

return [
DefaultInfo(
files = depset([ctx.outputs.executable, ctx.outputs.dummy]),
runfiles = ctx.runfiles(
runfiles = collect_runfiles(
ctx,
files = ctx.files.srcs + ctx.files.data + [
manifest,
params_file,
ctx.outputs.executable,
ctx.outputs.dummy,
],
transitive_files = transitive_runfiles,
extra_runfiles_attrs = ["server", "exports"],
),
),
WebFilesInfo(
manifest = manifest,
manifests = manifests,
webpaths = depset(transitive = webpaths),
dummy = ctx.outputs.dummy,
exports = unfurl(ctx.attr.exports),
exports = unfurl(extract_providers(ctx.attr.exports, WebFilesInfo)),
),
]

Expand Down
Loading