Skip to content

Commit

Permalink
[antlir2][install] skip split on directories
Browse files Browse the repository at this point in the history
Summary:
The split action doesn't do anything with directories (mabe it should some day,
but it doesn't now). So don't bother spending a ton of time copying around
potentially giant files if we're not even doing anything with them.

Test Plan:
```
❯ buck2 test fbcode//antlir/antlir2/features/install/...
Buck UI: https://www.internalfb.com/buck2/676a4a35-9f2f-4e7f-b5bd-caa00e0d0031
Test UI: https://www.internalfb.com/intern/testinfra/testrun/5348024821107010
Tests finished: Pass 46. Fail 0. Fatal 0. Skip 0. Build failure 0
```

Reviewed By: justintrudell

Differential Revision: D68844391

fbshipit-source-id: f0a98351c7b564f6ceb76db1d0fbe2c1c36a7ae9
  • Loading branch information
vmagro authored and facebook-github-bot committed Jan 30, 2025
1 parent 4b5f9bb commit dccabc8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions antlir/antlir2/features/install/install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
mode = ctx.attrs.mode
if ctx.attrs.text != None:
src = ctx.actions.write("install_text", ctx.attrs.text)

# If the user is installing a directory, we require they include a trailing
# '/' in `dst` because there is otherwise no way to tell
dst_is_dir = ctx.attrs.dst.endswith("/")

if type(src) == "dependency":
is_executable = RunInfo in src
expect(LayerInfo not in src, "Layers ({}) cannot be used as install `src`, consider using feature.mount instead".format(src.label))
Expand All @@ -169,9 +174,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
# in buck2, since we put a dep on the binary directly onto the layer
# itself, which forces a rebuild when appropriate.
mode = ctx.attrs.default_binary_mode or 0o555
elif ctx.attrs.dst.endswith("/"):
# If the user is installing a directory, we require they include
# a trailing '/' in `dst`
elif dst_is_dir:
mode = ctx.attrs.default_directory_mode or 0o755
else:
mode = ctx.attrs.default_file_mode or 0o444
Expand Down Expand Up @@ -217,8 +220,9 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
standalone = binaries_require_repo.is_standalone(src)

# Non-standalone (aka dev-mode) binaries don't get stripped, they just
# get symlinked
if ctx.attrs.split_debuginfo and (standalone or ctx.attrs.never_use_dev_binary_symlink):
# get symlinked. The split action does not (currently) support directory
# sources, so just skip it
if not dst_is_dir and ctx.attrs.split_debuginfo and (standalone or ctx.attrs.never_use_dev_binary_symlink):
split_anon_target = split_binary_anon(
ctx = ctx,
src = src,
Expand Down

0 comments on commit dccabc8

Please sign in to comment.