👷 Config bazel cross-compile

This commit is contained in:
openwaygate authored and OpenWaygate committed 2025-05-31 22:58:44 +08:00
1 parent a9cc86f1e8
commit ef5a6448c0
3 files changed
+52 -1

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
.github
.idea
# Ignore all bazel-* symlinks. There is no full list since this can change
# based on the name of the directory bazel is cloned into.
bazel-*
# Bazelisk version file
.bazelversion
.DS_Store
+37 -1
View File
@@ -1,5 +1,5 @@
load("@gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_go//go:def.bzl", "go_binary", "go_cross_binary", "go_library")
gazelle(name = "gazelle")
@@ -39,3 +39,39 @@ go_binary(
embed = [":yutu_lib"],
visibility = ["//visibility:public"],
)
go_cross_binary(
name = "yutu-darwin-amd64",
platform = "@rules_go//go/toolchain:darwin_amd64",
target = "yutu",
)
go_cross_binary(
name = "yutu-darwin-arm64",
platform = "@rules_go//go/toolchain:darwin_arm64",
target = "yutu",
)
go_cross_binary(
name = "yutu-linux-amd64",
platform = "@rules_go//go/toolchain:linux_amd64",
target = "yutu",
)
go_cross_binary(
name = "yutu-linux-arm64",
platform = "@rules_go//go/toolchain:linux_arm64",
target = "yutu",
)
go_cross_binary(
name = "yutu-windows-amd64.exe",
platform = "@rules_go//go/toolchain:windows_amd64",
target = "yutu",
)
go_cross_binary(
name = "yutu-windows-arm64.exe",
platform = "@rules_go//go/toolchain:windows_arm64",
target = "yutu",
)
+6
View File
@@ -14,12 +14,18 @@ Here are some commands which may useful.
# run tests
## unit tests
❯ go test ./...
## or with bazel
❯ bazel test //...
## verify binary commands, detect shorthands conflicts, etc.
❯ ./scripts/command-test.sh
# build the binary
## install goreleaser: https://goreleaser.com/install
❯ GITHUB_REPOSITORY=eat-pray-ai/yutu goreleaser build --clean --auto-snapshot
# or with bazel
❯ bazel build //:yutu # build the binary for the current platform
❯ bazel build //... # build all targets
❯ bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //:yutu
# script to install yutu
❯ ./scripts/install.sh