Skip to content

Commit

Permalink
fix: srcs is not mandatory (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn authored and gregmagolan committed Mar 23, 2024
1 parent d9c7cb7 commit c2937eb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/tar.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions lib/private/tar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ _tar_attrs = {
If any of the srcs are binaries with runfiles, those are copied into the resulting tar as well.
""",
mandatory = True,
allow_files = True,
),
"mode": attr.string(
Expand Down Expand Up @@ -88,7 +87,7 @@ _tar_attrs = {
}

_mtree_attrs = {
"srcs": attr.label_list(doc = "Files that are placed into the tar", mandatory = True, allow_files = True),
"srcs": attr.label_list(doc = "Files that are placed into the tar", allow_files = True),
"out": attr.output(doc = "Resulting specification file to write"),
}

Expand Down
32 changes: 32 additions & 0 deletions lib/tests/tar/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,35 @@ assert_archive_contains(
"LICENSE",
],
)

# Case 10: Can reference generated files
tar(
name = "tar_location_expansion",
srcs = ["@bazel_skylib//:LICENSE"],
out = "10.tar",
mtree = [
"a uid=0 gid=0 time=1672560000 mode=0755 type=file content=$(location @bazel_skylib//:LICENSE)",
],
)

assert_tar_listing(
name = "test_tar_location_expansion",
actual = "tar_location_expansion",
expected = [
"-rwxr-xr-x 0 0 0 11358 Jan 1 2023 a",
],
)

# Case 11: Can create tar without srcs
tar(
name = "create_tmp",
mtree = ["./tmp time=1501783453.0 mode=1777 gid=0 uid=0 type=dir"],
)

assert_tar_listing(
name = "test_create_create_tmp",
actual = "create_tmp",
expected = [
"drwxrwxrwt 0 0 0 0 Aug 3 2017 ./tmp/",
],
)

0 comments on commit c2937eb

Please sign in to comment.