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: stop requiring MANIFEST to deduce runfiles directory #937

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 3 additions & 16 deletions lib/private/tar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,6 @@ def _add_compression_args(compress, args):
if compress == "zstd":
args.add("--zstd")

def _calculate_runfiles_dir(default_info):
manifest = default_info.files_to_run.runfiles_manifest

# Newer versions of Bazel put the manifest besides the runfiles with the suffix .runfiles_manifest.
# For example, the runfiles directory is named my_binary.runfiles then the manifest is beside the
# runfiles directory and named my_binary.runfiles_manifest
# Older versions of Bazel put the manifest file named MANIFEST in the runfiles directory
# See similar logic:
# https://github.com/aspect-build/rules_js/blob/c50bd3f797c501fb229cf9ab58e0e4fc11464a2f/js/private/bash.bzl#L63
if manifest.short_path.endswith("_manifest") or manifest.short_path.endswith("/MANIFEST"):
# Trim last 9 characters, as that's the length in both cases
return manifest.short_path[:-9]
fail("manifest path {} seems malformed".format(manifest.short_path))

def _tar_impl(ctx):
bsdtar = ctx.toolchains[TAR_TOOLCHAIN_TYPE]
inputs = ctx.files.srcs[:]
Expand Down Expand Up @@ -224,10 +210,11 @@ def _mtree_impl(ctx):

for s in ctx.attr.srcs:
default_info = s[DefaultInfo]
if not default_info.files_to_run.runfiles_manifest:
if not default_info.files_to_run.executable:
continue

runfiles_dir = _calculate_runfiles_dir(default_info)
# Expect a .runfiles directory for each executable.
runfiles_dir = default_info.files_to_run.executable.short_path + ".runfiles"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need to be prefixed with ctx.workspace_name.


# copy workspace name here just in case to prevent ctx
# to be transferred to execution phase.
Expand Down
Loading