Skip to content

Commit 4448ad1

Browse files
Add Windows ARM64 and Refactored Targets (#601)
* bzlmod: removed legacy repo_name override for rules_go and gazelle * applied buildifier reformat * ws: update godoc to reference bazel 7.2.1 instead of 6.3.0 * re-generate targets using gazelle * add "gazelle:ignore" to root BUILD file to prevent gazelle from generating a new go_test target * update aspect_rules_js to latest 1.x version * add windows-arm target / refactor root BUILD to dinamically generate go_binary targets (stripped and not stripped)
1 parent 99ab439 commit 4448ad1

File tree

12 files changed

+76
-107
lines changed

12 files changed

+76
-107
lines changed

BUILD

Lines changed: 40 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
2-
load("@bazel_gazelle//:def.bzl", "gazelle")
31
load("@aspect_rules_js//npm:defs.bzl", "npm_package", "stamped_package_json")
2+
load("@gazelle//:def.bzl", "gazelle")
3+
load("@rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
44

5+
# gazelle:ignore
56
# gazelle:prefix github.com/bazelbuild/bazelisk
67
gazelle(name = "gazelle")
78

@@ -72,33 +73,43 @@ go_binary(
7273
visibility = ["//visibility:public"],
7374
)
7475

75-
go_binary(
76-
name = "bazelisk-darwin-amd64",
77-
out = "bazelisk-darwin_amd64",
78-
embed = [":bazelisk_lib"],
79-
gc_linkopts = [
80-
"-s",
81-
"-w",
82-
],
83-
goarch = "amd64",
84-
goos = "darwin",
85-
pure = "on",
86-
visibility = ["//visibility:public"],
87-
)
76+
[
77+
go_binary(
78+
name = "bazelisk-%s-%s" % (os, arch),
79+
out = "bazelisk-%s_%s" % (os, arch),
80+
embed = [":bazelisk_lib"],
81+
gc_linkopts = [
82+
"-s",
83+
"-w",
84+
],
85+
goarch = arch,
86+
goos = os,
87+
pure = "on",
88+
visibility = ["//visibility:public"],
89+
)
90+
for os, arch in [
91+
("darwin", "amd64"),
92+
("darwin", "arm64"),
93+
("linux", "amd64"),
94+
("linux", "arm64")
95+
]
96+
]
8897

89-
go_binary(
90-
name = "bazelisk-darwin-arm64",
91-
out = "bazelisk-darwin_arm64",
92-
embed = [":bazelisk_lib"],
93-
gc_linkopts = [
94-
"-s",
95-
"-w",
96-
],
97-
goarch = "arm64",
98-
goos = "darwin",
99-
pure = "on",
100-
visibility = ["//visibility:public"],
101-
)
98+
[
99+
go_binary(
100+
name = "bazelisk-%s-%s" % (os, arch),
101+
out = "bazelisk-%s_%s.exe" % (os, arch),
102+
embed = [":bazelisk_lib"],
103+
goarch = arch,
104+
goos = os,
105+
pure = "on",
106+
visibility = ["//visibility:public"],
107+
)
108+
for os, arch in [
109+
("windows", "amd64"),
110+
("windows", "arm64")
111+
]
112+
]
102113

103114
genrule(
104115
name = "bazelisk-darwin-universal",
@@ -114,44 +125,6 @@ genrule(
114125
],
115126
)
116127

117-
go_binary(
118-
name = "bazelisk-linux-amd64",
119-
out = "bazelisk-linux_amd64",
120-
embed = [":bazelisk_lib"],
121-
gc_linkopts = [
122-
"-s",
123-
"-w",
124-
],
125-
goarch = "amd64",
126-
goos = "linux",
127-
pure = "on",
128-
visibility = ["//visibility:public"],
129-
)
130-
131-
go_binary(
132-
name = "bazelisk-linux-arm64",
133-
out = "bazelisk-linux_arm64",
134-
embed = [":bazelisk_lib"],
135-
gc_linkopts = [
136-
"-s",
137-
"-w",
138-
],
139-
goarch = "arm64",
140-
goos = "linux",
141-
pure = "on",
142-
visibility = ["//visibility:public"],
143-
)
144-
145-
go_binary(
146-
name = "bazelisk-windows-amd64",
147-
out = "bazelisk-windows_amd64.exe",
148-
embed = [":bazelisk_lib"],
149-
goarch = "amd64",
150-
goos = "windows",
151-
pure = "on",
152-
visibility = ["//visibility:public"],
153-
)
154-
155128
stamped_package_json(
156129
name = "package",
157130
# This key is defined by /stamp.sh
@@ -170,6 +143,7 @@ npm_package(
170143
":bazelisk-linux-amd64",
171144
":bazelisk-linux-arm64",
172145
":bazelisk-windows-amd64",
146+
":bazelisk-windows-arm64",
173147
":package",
174148
],
175149
package = "@bazel/bazelisk",

MODULE.bazel

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
module(name = "bazelisk", version="")
1+
module(
2+
name = "bazelisk",
3+
version = "",
4+
)
25

3-
bazel_dep(name = "gazelle", version = "0.38.0", repo_name = "bazel_gazelle")
6+
bazel_dep(name = "gazelle", version = "0.38.0")
47
bazel_dep(name = "platforms", version = "0.0.10")
5-
bazel_dep(name = "rules_go", version = "0.49.0", repo_name = "io_bazel_rules_go")
6-
bazel_dep(name = "aspect_rules_js", version = "1.39.1")
8+
bazel_dep(name = "rules_go", version = "0.49.0")
9+
bazel_dep(name = "aspect_rules_js", version = "1.42.3")
710

8-
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
11+
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
912
go_sdk.download(version = "1.22.5")
1013

11-
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
14+
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
1215
go_deps.from_file(go_mod = "//:go.mod")
1316
use_repo(
1417
go_deps,
18+
"com_github_bgentry_go_netrc",
1519
"com_github_hashicorp_go_version",
1620
"com_github_mitchellh_go_homedir",
17-
"com_github_bgentry_go_netrc",
1821
"org_golang_x_term",
1922
)

build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ go build
2727
//:bazelisk-darwin-universal \
2828
//:bazelisk-linux-amd64 \
2929
//:bazelisk-linux-arm64 \
30-
//:bazelisk-windows-amd64
30+
//:bazelisk-windows-amd64 \
31+
//:bazelisk-windows-arm64
3132
echo
3233

3334
cp bazel-out/*-opt*/bin/bazelisk-darwin_amd64 bin/bazelisk-darwin-amd64
@@ -36,6 +37,7 @@ cp bazel-out/*-opt*/bin/bazelisk-darwin_universal bin/bazelisk-darwin
3637
cp bazel-out/*-opt*/bin/bazelisk-linux_amd64 bin/bazelisk-linux-amd64
3738
cp bazel-out/*-opt*/bin/bazelisk-linux_arm64 bin/bazelisk-linux-arm64
3839
cp bazel-out/*-opt*/bin/bazelisk-windows_amd64.exe bin/bazelisk-windows-amd64.exe
40+
cp bazel-out/*-opt*/bin/bazelisk-windows_arm64.exe bin/bazelisk-windows-arm64.exe
3941
rm -f bazelisk
4042

4143
### Build release artifacts using `go build`.
@@ -45,6 +47,7 @@ rm -f bazelisk
4547
# GOOS=darwin GOARCH=arm64 go build -o bin/bazelisk-darwin-arm64
4648
# lipo -create -output bin/bazelisk-darwin bin/bazelisk-darwin-amd64 bin/bazelisk-darwin-arm64
4749
# GOOS=windows GOARCH=amd64 go build -o bin/bazelisk-windows-amd64.exe
50+
# GOOS=windows GOARCH=arm64 go build -o bin/bazelisk-windows-arm64.exe
4851

4952
### Print some information about the generated binaries.
5053
echo "== Bazelisk binaries are ready =="

config/BUILD

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library")
1+
load("@rules_go//go:def.bzl", "go_library")
22

33
go_library(
44
name = "config",
55
srcs = ["config.go"],
66
importpath = "github.com/bazelbuild/bazelisk/config",
77
visibility = ["//visibility:public"],
8-
deps = [
9-
"//ws",
10-
"@com_github_mitchellh_go_homedir//:go_default_library",
11-
],
8+
deps = ["//ws"],
129
)

core/BUILD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
44
name = "core",
@@ -15,7 +15,7 @@ go_library(
1515
"//platforms",
1616
"//versions",
1717
"//ws",
18-
"@com_github_mitchellh_go_homedir//:go_default_library",
18+
"@com_github_mitchellh_go_homedir//:go-homedir",
1919
],
2020
)
2121

@@ -28,5 +28,6 @@ go_test(
2828
embed = [":core"],
2929
deps = [
3030
"//config",
31+
"//platforms",
3132
],
3233
)

httputil/BUILD

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@bazel_gazelle//:def.bzl", "gazelle")
2-
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
1+
load("@gazelle//:def.bzl", "gazelle")
2+
load("@rules_go//go:def.bzl", "go_library", "go_test")
33

44
# gazelle:prefix github.com/bazelbuild/bazelisk/httputil
55
gazelle(name = "gazelle")
@@ -15,15 +15,13 @@ go_library(
1515
deps = [
1616
"//config",
1717
"//httputil/progress",
18-
"@com_github_bgentry_go_netrc//netrc:go_default_library",
19-
"@com_github_mitchellh_go_homedir//:go_default_library",
18+
"@com_github_bgentry_go_netrc//netrc",
19+
"@com_github_mitchellh_go_homedir//:go-homedir",
2020
],
2121
)
2222

2323
go_test(
2424
name = "httputil_test",
25-
srcs = [
26-
"httputil_test.go",
27-
],
25+
srcs = ["httputil_test.go"],
2826
embed = [":httputil"],
2927
)

httputil/progress/BUILD

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
load("@bazel_gazelle//:def.bzl", "gazelle")
2-
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
1+
load("@gazelle//:def.bzl", "gazelle")
2+
load("@rules_go//go:def.bzl", "go_library", "go_test")
33

44
# gazelle:prefix github.com/bazelbuild/bazelisk/httputil/progress
55
gazelle(name = "gazelle")
66

77
go_library(
88
name = "progress",
9-
srcs = [
10-
"progress.go",
11-
],
9+
srcs = ["progress.go"],
1210
importpath = "github.com/bazelbuild/bazelisk/httputil/progress",
1311
visibility = ["//visibility:public"],
1412
deps = [
1513
"//config",
16-
"@org_golang_x_term//:go_default_library",
14+
"@org_golang_x_term//:term",
1715
],
1816
)
1917

2018
go_test(
2119
name = "progress_test",
22-
srcs = [
23-
"progress_test.go",
24-
],
20+
srcs = ["progress_test.go"],
2521
embed = [":progress"],
2622
)

platforms/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
22

33
go_library(
44
name = "platforms",
@@ -8,7 +8,7 @@ go_library(
88
deps = [
99
"//config",
1010
"//versions",
11-
"@com_github_hashicorp_go_version//:go_default_library",
11+
"@com_github_hashicorp_go_version//:go-version",
1212
],
1313
)
1414

repositories/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library")
1+
load("@rules_go//go:def.bzl", "go_library")
22

33
go_library(
44
name = "repositories",

versions/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library")
1+
load("@rules_go//go:def.bzl", "go_library")
22

33
go_library(
44
name = "versions",
55
srcs = ["versions.go"],
66
importpath = "github.com/bazelbuild/bazelisk/versions",
77
visibility = ["//visibility:public"],
88
deps = [
9-
"@com_github_hashicorp_go_version//:go_default_library",
9+
"@com_github_hashicorp_go_version//:go-version",
1010
],
1111
)

0 commit comments

Comments
 (0)