diff --git a/docs/tar.md b/docs/tar.md index ccdda5288..eb786e084 100644 --- a/docs/tar.md +++ b/docs/tar.md @@ -94,7 +94,7 @@ Rule that executes BSD `tar`. Most users should use the [`tar`](#tar) macro, rat | args | Additional flags permitted by BSD tar; see the man page. | List of strings | optional | `[]` | | compress | Compress the archive file with a supported algorithm. | String | optional | `""` | | compute_unused_inputs | Whether to discover and prune input files that will not contribute to the archive.

Unused inputs are discovered by comparing the set of input files in `srcs` to the set of files referenced by `mtree`. Files not used for content by the mtree specification will not be read by the `tar` tool when creating the archive and can be pruned from the input set using the `unused_inputs_list` [mechanism](https://bazel.build/contribute/codebase#input-discovery).

Benefits: pruning unused input files can reduce the amount of work the build system must perform. Pruned files are not included in the action cache key; changes to them do not invalidate the cache entry, which can lead to higher cache hit rates. Actions do not need to block on the availability of pruned inputs, which can increase the available parallelism of builds. Pruned files do not need to be transferred to remote-execution workers, which can reduce network costs.

Risks: pruning an actually-used input file can lead to unexpected, incorrect results. The comparison performed between `srcs` and `mtree` is currently inexact and may fail to handle handwritten or externally-derived mtree specifications. However, it is safe to use this feature when the lines found in `mtree` are derived from one or more `mtree_spec` rules, filtered and/or merged on whole-line basis only.

Possible values:

- `compute_unused_inputs = 1`: Always perform unused input discovery and pruning. - `compute_unused_inputs = 0`: Never discover or prune unused inputs. - `compute_unused_inputs = -1`: Discovery and pruning of unused inputs is controlled by the --[no]@aspect_bazel_lib//lib:tar_compute_unused_inputs flag. | Integer | optional | `-1` | -| mode | A mode indicator from the following list, copied from the tar manpage:

- create: Create a new archive containing the specified items. - append: Like `create`, but new entries are appended to the archive. Note that this only works on uncompressed archives stored in regular files. The -f option is required. - list: List archive contents to stdout. - update: Like `append`, but new entries are added only if they have a modification date newer than the corresponding entry in the archive. Note that this only works on uncompressed archives stored in regular files. The -f option is required. - extract: Extract to disk from the archive. If a file with the same name appears more than once in the archive, each copy will be extracted, with later copies overwriting (replacing) earlier copies. | String | optional | `"create"` | +| mode | A mode indicator from the following list, copied from the tar manpage:

- create: Create a new archive containing the specified items.

Other modes may be added in the future. | String | optional | `"create"` | | mtree | An mtree specification file | Label | required | | diff --git a/lib/private/tar.bzl b/lib/private/tar.bzl index 21958fe2d..623953dce 100644 --- a/lib/private/tar.bzl +++ b/lib/private/tar.bzl @@ -57,18 +57,19 @@ _tar_attrs = { doc = """A mode indicator from the following list, copied from the tar manpage: - create: Create a new archive containing the specified items. - - append: Like `create`, but new entries are appended to the archive. - Note that this only works on uncompressed archives stored in regular files. - The -f option is required. - - list: List archive contents to stdout. - - update: Like `append`, but new entries are added only if they have a - modification date newer than the corresponding entry in the archive. - Note that this only works on uncompressed archives stored in - regular files. The -f option is required. - - extract: Extract to disk from the archive. If a file with the same name - appears more than once in the archive, each copy will be extracted, - with later copies overwriting (replacing) earlier copies. - """, + + Other modes may be added in the future.""", + # - append: Like `create`, but new entries are appended to the archive. + # Note that this only works on uncompressed archives stored in regular files. + # The -f option is required. + # - list: List archive contents to stdout. + # - update: Like `append`, but new entries are added only if they have a + # modification date newer than the corresponding entry in the archive. + # Note that this only works on uncompressed archives stored in + # regular files. The -f option is required. + # - extract: Extract to disk from the archive. If a file with the same name + # appears more than once in the archive, each copy will be extracted, + # with later copies overwriting (replacing) earlier copies. values = ["create"], # TODO: support other modes: ["append", "list", "update", "extract"] default = "create", ),