forked from hswaw/hscloud

Counteracts: - --incompatible_depset_is_not_iterable=false - --incompatible_new_actions_api=false Change-Id: Ib0e63b717f643e4e3b57684b53d3165d5925daac
21 lines
758 B
Python
21 lines
758 B
Python
def _copy_go_binary_impl(ctx):
|
|
output = ctx.actions.declare_file(ctx.label.name)
|
|
for f in ctx.attr.src.files.to_list():
|
|
# go_binary rules have two outputs, a library and the binary itself.
|
|
# The following is a horrible hack to avoid copying the library.
|
|
if f.path.endswith(".a"):
|
|
continue
|
|
ctx.actions.run_shell(
|
|
inputs=[f],
|
|
outputs=[output],
|
|
mnemonic="CopyGoBinary",
|
|
command="mkdir -p %s && cp %s %s" % (output.dirname, f.path, output.path))
|
|
return [DefaultInfo(executable=output)]
|
|
|
|
copy_go_binary = rule(
|
|
implementation=_copy_go_binary_impl,
|
|
attrs={
|
|
"src": attr.label(mandatory=True, allow_files=True),
|
|
},
|
|
executable=True,
|
|
)
|