]> go.fuhry.dev Git - runtime.git/commitdiff
add go_cross_binaries macro and start enabling some cmds on other platforms main
authorDan Fuhry <dan@fuhry.com>
Sun, 15 Mar 2026 01:57:09 +0000 (21:57 -0400)
committerDan Fuhry <dan@fuhry.com>
Sun, 15 Mar 2026 01:57:09 +0000 (21:57 -0400)
bazel/cross.bzl [new file with mode: 0644]
cmd/apcups_exporter/BUILD.bazel
cmd/machines_agent/BUILD.bazel
cmd/sase_ws_proxy_client/BUILD.bazel

diff --git a/bazel/cross.bzl b/bazel/cross.bzl
new file mode 100644 (file)
index 0000000..1aa4b79
--- /dev/null
@@ -0,0 +1,36 @@
+load("@rules_go//go:def.bzl", "go_cross_binary")
+
+def _go_cross_target(
+    base_target,
+    platform,
+):
+    go_cross_binary(
+        name = "{}_{}".format(base_target, platform),
+        platform = "@rules_go//go/toolchain:{}".format(platform),
+        target = ":{}".format(base_target),
+    )
+
+def go_cross_binaries(
+    base_target,
+    mac = False,
+    openbsd = False,
+    linux_arm = False,
+):
+    """
+    go_cross_binaries 
+
+    Args:
+        base_target: base go_binary target
+        mac: generate targets for macOS
+        openbsd: generate targets for OpenBSD
+        linux_arm: generate targets for Linux arm64
+    """
+    if mac:
+        for arch in ["amd64", "arm64"]:
+            _go_cross_target(base_target, "darwin_{}".format(arch))
+    
+    if openbsd:
+        _go_cross_target(base_target, "openbsd_amd64")
+    
+    if linux_arm:
+        _go_cross_target(base_target, "linux_arm64")
\ No newline at end of file
index 6d7512fe613e660ea20304b5537d495657ea8cd6..30ef5316c460fc804b5891495acb5243d234615f 100644 (file)
@@ -1,4 +1,5 @@
 load("@rules_go//go:def.bzl", "go_binary", "go_library")
+load("//bazel:cross.bzl", "go_cross_binaries")
 load("//bazel:svc.bzl", "systemd_service")
 
 go_library(
@@ -45,3 +46,8 @@ systemd_service(
     user = "daemon",
     deps = ["apcupsd.service"],
 )
+
+go_cross_binaries(
+    base_target = "apcups_exporter",
+    linux_arm = True,
+)
index 9cb4a859c63cf031620006377c72c0a088a52b9a..7fed79bb2689e9def477077735866d2fcd282312 100644 (file)
@@ -1,4 +1,5 @@
 load("@rules_go//go:def.bzl", "go_binary", "go_library")
+load("//bazel:cross.bzl", "go_cross_binaries")
 
 go_library(
     name = "machines_agent_lib",
@@ -18,3 +19,8 @@ go_binary(
     embed = [":machines_agent_lib"],
     visibility = ["//visibility:public"],
 )
+
+go_cross_binaries(
+    base_target = "machines_agent",
+    openbsd = True,
+)
index bd2c944b73023c4337e5a10e05c0a01cf0ee48cc..a97c3f86006cd2931663ab0364b3bd2b336bfca1 100644 (file)
@@ -1,4 +1,5 @@
 load("@rules_go//go:def.bzl", "go_binary", "go_library")
+load("//bazel:cross.bzl", "go_cross_binaries")
 
 go_library(
     name = "sase_ws_proxy_client_lib",
@@ -16,3 +17,8 @@ go_binary(
     embed = [":sase_ws_proxy_client_lib"],
     visibility = ["//visibility:public"],
 )
+
+go_cross_binaries(
+    base_target = "sase_ws_proxy_client",
+    mac = True,
+)