Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 41a3073

Browse files
authored
Add compressor/compressor_args attributes (#45)
Follow pkg_tar and add compressor/compressor_args attributes so we can use any external compressors, eg: pigz for gzip with multi-cpu support
1 parent c52b1ed commit 41a3073

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

docs/tar.md

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tar/private/tar.bzl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ _tar_attrs = {
8686
doc = "Compress the archive file with a supported algorithm.",
8787
values = _ACCEPTED_COMPRESSION_TYPES,
8888
),
89+
"compressor": attr.label(
90+
doc = "External tool which can compress the archive.",
91+
executable = True,
92+
cfg = "exec",
93+
),
94+
"compressor_args": attr.string(
95+
doc = "Arg list for `compressor`.",
96+
),
8997
"compute_unused_inputs": attr.int(
9098
doc = """
9199
Whether to discover and prune input files that will not contribute to the archive.
@@ -353,7 +361,10 @@ def _tar_impl(ctx):
353361
args.add_all(ctx.attr.args)
354362

355363
# Compression args
356-
_add_compression_args(ctx.attr.compress, args)
364+
if ctx.executable.compressor:
365+
args.add("--use-compress-program", "%s %s" % (ctx.executable.compressor.path, ctx.attr.compressor_args))
366+
else:
367+
_add_compression_args(ctx.attr.compress, args)
357368

358369
ext = _COMPRESSION_TO_EXTENSION[ctx.attr.compress] if ctx.attr.compress else ".tar"
359370

@@ -400,6 +411,7 @@ def _tar_impl(ctx):
400411
mnemonic = "Tar",
401412
unused_inputs_list = unused_inputs_file,
402413
toolchain = TAR_TOOLCHAIN_TYPE,
414+
tools = [ctx.executable.compressor] if ctx.executable.compressor else [],
403415
)
404416

405417
# TODO(3.0): Always return a list of providers.

0 commit comments

Comments
 (0)