shorten rules.bzl

This commit is contained in:
Motiejus Jakštys 2021-05-24 00:11:58 +03:00
parent 8385d2325d
commit 7b4c7ba04f

View File

@ -16,7 +16,7 @@ def _rootfs_impl(ctx):
ctx.actions.run( ctx.actions.run(
outputs = [out], outputs = [out],
inputs = ctx.files.src, inputs = ctx.files.src,
executable = ctx.files._undocker[0], executable = ctx.executable._undocker,
arguments = [ arguments = [
"rootfs", "rootfs",
ctx.files.src[0].path, ctx.files.src[0].path,
@ -24,14 +24,14 @@ def _rootfs_impl(ctx):
], ],
mnemonic = "RootFS", mnemonic = "RootFS",
) )
return [DefaultInfo( return DefaultInfo(
files = depset([out]), files = depset([out]),
runfiles = ctx.runfiles(files = ctx.files.src), runfiles = ctx.runfiles(files = ctx.files.src),
)] )
rootfs = rule( rootfs = rule(
_rootfs_impl,
doc = "Generate a rootfs from a docker container image", doc = "Generate a rootfs from a docker container image",
implementation = _rootfs_impl,
attrs = { attrs = {
"src": _input_container, "src": _input_container,
"_undocker": _undocker_cli, "_undocker": _undocker_cli,
@ -43,7 +43,7 @@ def _lxcconfig_impl(ctx):
ctx.actions.run( ctx.actions.run(
outputs = [out], outputs = [out],
inputs = ctx.files.src, inputs = ctx.files.src,
executable = ctx.files._undocker[0], executable = ctx.executable._undocker,
arguments = [ arguments = [
"lxcconfig", "lxcconfig",
ctx.files.src[0].path, ctx.files.src[0].path,
@ -51,14 +51,14 @@ def _lxcconfig_impl(ctx):
], ],
mnemonic = "LXCConfig", mnemonic = "LXCConfig",
) )
return [DefaultInfo( return DefaultInfo(
files = depset([out]), files = depset([out]),
runfiles = ctx.runfiles(files = ctx.files.src), runfiles = ctx.runfiles(files = ctx.files.src),
)] )
lxcconfig = rule( lxcconfig = rule(
_lxcconfig_impl,
doc = "Generate lxc config from a docker container image", doc = "Generate lxc config from a docker container image",
implementation = _lxcconfig_impl,
attrs = { attrs = {
"src": _input_container, "src": _input_container,
"_undocker": _undocker_cli, "_undocker": _undocker_cli,