Skip to content

Commit b1e501c

Browse files
author
Motiejus Jakštys
committed
Finish migration to bzlmod
- bump bazel to 6.4.0 - bump rules_go, gazelle, platforms - enable bzlmod - clear WORKSPACE (cannot remove yet due to examples) - remove `gofmt`, #136 - remove Go MacOS x86_64 tests, #10
1 parent f3c605e commit b1e501c

File tree

15 files changed

+1524
-1055
lines changed

15 files changed

+1524
-1055
lines changed

.bazelrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
common --enable_bzlmod
2+
13
test --sandbox_default_allow_network=false
24
test --test_output=errors
35

@@ -7,4 +9,4 @@ build --worker_sandboxing
79
build --experimental_reuse_sandbox_directories
810
build --incompatible_enable_cc_toolchain_resolution
911
build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
10-
build --experimental_output_directory_naming_scheme=diff_against_baseline
12+
build --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.3.0
1+
6.4.0

.buildkite/pipeline.yml

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ steps:
2323
command: ci/prepare_git && ci/test_example rules_cc override_repository
2424
- label: "Test bzlmod example"
2525
command: ci/prepare_git && ci/test_example bzlmod override_module
26-
- label: "mod-tidy and update-repos"
27-
command: tools/mod-tidy && git diff --exit-code
2826
agents:
2927
- "queue=init"
3028
- "docker=*"

BUILD

-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,3 @@ alias(
99
name = "gazelle",
1010
actual = "//tools/gazelle:gazelle",
1111
)
12-
13-
alias(
14-
name = "gazelle-update-repos",
15-
actual = "//tools/gazelle:gazelle-update-repos",
16-
)

MODULE.bazel

+26-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module(
33
version = "2.1.3",
44
)
55

6-
bazel_dep(name = "platforms", version = "0.0.6")
6+
bazel_dep(name = "platforms", version = "0.0.8")
77

8-
bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True)
8+
bazel_dep(name = "rules_go", version = "0.43.0", dev_dependency = True)
99

1010
go_sdk = use_extension(
1111
"@rules_go//go:extensions.bzl",
@@ -14,7 +14,7 @@ go_sdk = use_extension(
1414
)
1515
use_repo(go_sdk, "go_default_sdk")
1616

17-
bazel_dep(name = "gazelle", version = "0.32.0", dev_dependency = True)
17+
bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True)
1818

1919
go_deps = use_extension(
2020
"@gazelle//:extensions.bzl",
@@ -25,4 +25,27 @@ go_deps.from_file(go_mod = "//:go.mod")
2525
use_repo(
2626
go_deps,
2727
"com_github_bazelbuild_buildtools",
28+
"com_github_stretchr_testify",
29+
)
30+
31+
toolchains = use_extension("//toolchain:ext.bzl", "toolchains")
32+
use_repo(toolchains, "zig_sdk")
33+
34+
register_toolchains(
35+
# if no `--platform` is specified, these toolchains will be used for
36+
# (linux,darwin,windows)x(amd64,arm64)
37+
"@zig_sdk//toolchain:linux_amd64_gnu.2.28",
38+
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
39+
"@zig_sdk//toolchain:darwin_amd64",
40+
"@zig_sdk//toolchain:darwin_arm64",
41+
"@zig_sdk//toolchain:windows_amd64",
42+
"@zig_sdk//toolchain:windows_arm64",
43+
44+
# amd64 toolchains for libc-aware platforms:
45+
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.28",
46+
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.31",
47+
"@zig_sdk//libc_aware/toolchain:linux_amd64_musl",
48+
# arm64 toolchains for libc-aware platforms:
49+
"@zig_sdk//libc_aware/toolchain:linux_arm64_gnu.2.28",
50+
"@zig_sdk//libc_aware/toolchain:linux_arm64_musl",
2851
)

WORKSPACE

-86
Original file line numberDiff line numberDiff line change
@@ -1,86 +0,0 @@
1-
workspace(name = "hermetic_cc_toolchain")
2-
3-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4-
5-
RULESGO_VERSION = "v0.39.1"
6-
7-
http_archive(
8-
name = "io_bazel_rules_go",
9-
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
10-
urls = [
11-
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip".format(RULESGO_VERSION),
12-
"https://github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip".format(RULESGO_VERSION),
13-
],
14-
)
15-
16-
PROTOBUF_VERSION = "23.0"
17-
18-
http_archive(
19-
name = "com_google_protobuf",
20-
sha256 = "b29fc5fc13926f347b7a8b676ae1e63f7ccdb92c2fc8ca326bc3a883dcc168ac",
21-
strip_prefix = "protobuf-{}".format(PROTOBUF_VERSION),
22-
urls = [
23-
"https://github.com/protocolbuffers/protobuf/releases/download/v{0}/protobuf-{0}.tar.gz".format(PROTOBUF_VERSION),
24-
],
25-
)
26-
27-
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
28-
29-
protobuf_deps()
30-
31-
GAZELLE_VERSION = "v0.30.0"
32-
33-
http_archive(
34-
name = "bazel_gazelle",
35-
sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405",
36-
urls = [
37-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/{0}/bazel-gazelle-{0}.tar.gz".format(GAZELLE_VERSION),
38-
"https://github.com/bazelbuild/bazel-gazelle/releases/download/{0}/bazel-gazelle-{0}.tar.gz".format(GAZELLE_VERSION),
39-
],
40-
)
41-
42-
load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies")
43-
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
44-
45-
go_rules_dependencies()
46-
47-
# use latest stable.
48-
go_download_sdk(
49-
name = "go_sdk",
50-
version = "1.20.4",
51-
)
52-
53-
go_register_toolchains()
54-
55-
load("//:repositories.bzl", "go_repositories")
56-
57-
# gazelle:repository_macro repositories.bzl%go_repositories
58-
go_repositories()
59-
60-
gazelle_dependencies(go_repository_default_config = "@//:WORKSPACE")
61-
62-
load(
63-
"//toolchain:defs.bzl",
64-
zig_toolchains = "toolchains",
65-
)
66-
67-
zig_toolchains()
68-
69-
register_toolchains(
70-
# if no `--platform` is specified, these toolchains will be used for
71-
# (linux,darwin,windows)x(amd64,arm64)
72-
"@zig_sdk//toolchain:linux_amd64_gnu.2.28",
73-
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
74-
"@zig_sdk//toolchain:darwin_amd64",
75-
"@zig_sdk//toolchain:darwin_arm64",
76-
"@zig_sdk//toolchain:windows_amd64",
77-
"@zig_sdk//toolchain:windows_arm64",
78-
79-
# amd64 toolchains for libc-aware platforms:
80-
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.28",
81-
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.31",
82-
"@zig_sdk//libc_aware/toolchain:linux_amd64_musl",
83-
# arm64 toolchains for libc-aware platforms:
84-
"@zig_sdk//libc_aware/toolchain:linux_arm64_gnu.2.28",
85-
"@zig_sdk//libc_aware/toolchain:linux_arm64_musl",
86-
)

ci/lint

+6-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ mapfile -t zigfiles < <(git ls-files '*.zig')
2626
>&2 echo "--- zig fmt ${zigfiles[*]}"
2727
$ZIG fmt "${zigfiles[@]}"
2828

29-
>&2 echo "--- go fmt :go:"
30-
mapfile -t gofiles < <(git ls-files '**/*.go')
31-
tools/bazel run @go_sdk//:bin/gofmt -- -w "${gofiles[@]}"
29+
# TODO
30+
# https://github.com/uber/hermetic_cc_toolchain/issues/136
31+
>&2 echo "--- Skipping go fmt :go:"
32+
#>&2 echo "--- go fmt :go:"
33+
#mapfile -t gofiles < <(git ls-files '**/*.go')
34+
#tools/bazel run @rules_go//go -- fmt -w "${gofiles[@]}"
3235

3336
>&2 echo "--- buildifier :bazel:"
3437
tools/buildifier -r -mode fix "$PWD"

0 commit comments

Comments
 (0)