Add taskrunner2 macro

This commit is contained in:
Mustafa Gezen 2023-08-22 14:58:04 +02:00
parent 7f162d8f68
commit 5d3cea7da3
4 changed files with 44 additions and 0 deletions

View File

@ -1,6 +1,8 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
exports_files(["runner.sh"])
go_library(
name = "taskrunner2_lib",
srcs = ["main.go"],

View File

@ -0,0 +1,29 @@
def taskrunner2(name, targets = [], watch_targets = []):
args = []
for target in targets:
args.append("-t")
args.append(target)
for target in watch_targets:
args.append("-w")
args.append(target)
# generate args output
native.genrule(
name = name + "_args",
outs = ["args"],
cmd = "echo " + " ".join(args) + " > $@",
visibility = ["//visibility:private"],
)
native.sh_binary(
name = name,
srcs = [
"//devtools/taskrunner2:runner.sh",
],
data = [
"//devtools/taskrunner2",
":" + name + "_args",
],
)

4
devtools/taskrunner2/runner.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
ARGS_PATH="$(find . -name "args")"
devtools/taskrunner2/taskrunner2_/taskrunner2 $(cat "${ARGS_PATH}")

View File

@ -0,0 +1,9 @@
load("//devtools/taskrunner2:defs.bzl", "taskrunner2")
taskrunner2(
name = "mothership",
watch_targets = [
"//tools/mothership/cmd/mship_api",
"//tools/mothership/ui",
],
)