@@ -86,6 +86,14 @@ _tar_attrs = {
86
86
doc = "Compress the archive file with a supported algorithm." ,
87
87
values = _ACCEPTED_COMPRESSION_TYPES ,
88
88
),
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
+ ),
89
97
"compute_unused_inputs" : attr .int (
90
98
doc = """
91
99
Whether to discover and prune input files that will not contribute to the archive.
@@ -353,7 +361,10 @@ def _tar_impl(ctx):
353
361
args .add_all (ctx .attr .args )
354
362
355
363
# 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 )
357
368
358
369
ext = _COMPRESSION_TO_EXTENSION [ctx .attr .compress ] if ctx .attr .compress else ".tar"
359
370
@@ -400,6 +411,7 @@ def _tar_impl(ctx):
400
411
mnemonic = "Tar" ,
401
412
unused_inputs_list = unused_inputs_file ,
402
413
toolchain = TAR_TOOLCHAIN_TYPE ,
414
+ tools = [ctx .executable .compressor ] if ctx .executable .compressor else [],
403
415
)
404
416
405
417
# TODO(3.0): Always return a list of providers.
0 commit comments