Skip to content

Commit

Permalink
Finish migration to bzlmod
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Motiejus Jakštys committed Dec 15, 2023
1 parent f3c605e commit b1e501c
Show file tree
Hide file tree
Showing 15 changed files with 1,524 additions and 1,055 deletions.
4 changes: 3 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
common --enable_bzlmod

test --sandbox_default_allow_network=false
test --test_output=errors

Expand All @@ -7,4 +9,4 @@ build --worker_sandboxing
build --experimental_reuse_sandbox_directories
build --incompatible_enable_cc_toolchain_resolution
build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build --experimental_output_directory_naming_scheme=diff_against_baseline
build --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.0
6.4.0
2 changes: 0 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ steps:
command: ci/prepare_git && ci/test_example rules_cc override_repository
- label: "Test bzlmod example"
command: ci/prepare_git && ci/test_example bzlmod override_module
- label: "mod-tidy and update-repos"
command: tools/mod-tidy && git diff --exit-code
agents:
- "queue=init"
- "docker=*"
5 changes: 0 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,3 @@ alias(
name = "gazelle",
actual = "//tools/gazelle:gazelle",
)

alias(
name = "gazelle-update-repos",
actual = "//tools/gazelle:gazelle-update-repos",
)
29 changes: 26 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module(
version = "2.1.3",
)

bazel_dep(name = "platforms", version = "0.0.6")
bazel_dep(name = "platforms", version = "0.0.8")

bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True)
bazel_dep(name = "rules_go", version = "0.43.0", dev_dependency = True)

go_sdk = use_extension(
"@rules_go//go:extensions.bzl",
Expand All @@ -14,7 +14,7 @@ go_sdk = use_extension(
)
use_repo(go_sdk, "go_default_sdk")

bazel_dep(name = "gazelle", version = "0.32.0", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True)

go_deps = use_extension(
"@gazelle//:extensions.bzl",
Expand All @@ -25,4 +25,27 @@ go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_bazelbuild_buildtools",
"com_github_stretchr_testify",
)

toolchains = use_extension("//toolchain:ext.bzl", "toolchains")
use_repo(toolchains, "zig_sdk")

register_toolchains(
# if no `--platform` is specified, these toolchains will be used for
# (linux,darwin,windows)x(amd64,arm64)
"@zig_sdk//toolchain:linux_amd64_gnu.2.28",
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
"@zig_sdk//toolchain:darwin_amd64",
"@zig_sdk//toolchain:darwin_arm64",
"@zig_sdk//toolchain:windows_amd64",
"@zig_sdk//toolchain:windows_arm64",

# amd64 toolchains for libc-aware platforms:
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.28",
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.31",
"@zig_sdk//libc_aware/toolchain:linux_amd64_musl",
# arm64 toolchains for libc-aware platforms:
"@zig_sdk//libc_aware/toolchain:linux_arm64_gnu.2.28",
"@zig_sdk//libc_aware/toolchain:linux_arm64_musl",
)
86 changes: 0 additions & 86 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,86 +0,0 @@
workspace(name = "hermetic_cc_toolchain")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULESGO_VERSION = "v0.39.1"

http_archive(
name = "io_bazel_rules_go",
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip".format(RULESGO_VERSION),
"https://github.com/bazelbuild/rules_go/releases/download/{0}/rules_go-{0}.zip".format(RULESGO_VERSION),
],
)

PROTOBUF_VERSION = "23.0"

http_archive(
name = "com_google_protobuf",
sha256 = "b29fc5fc13926f347b7a8b676ae1e63f7ccdb92c2fc8ca326bc3a883dcc168ac",
strip_prefix = "protobuf-{}".format(PROTOBUF_VERSION),
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v{0}/protobuf-{0}.tar.gz".format(PROTOBUF_VERSION),
],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

GAZELLE_VERSION = "v0.30.0"

http_archive(
name = "bazel_gazelle",
sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/{0}/bazel-gazelle-{0}.tar.gz".format(GAZELLE_VERSION),
"https://github.com/bazelbuild/bazel-gazelle/releases/download/{0}/bazel-gazelle-{0}.tar.gz".format(GAZELLE_VERSION),
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

go_rules_dependencies()

# use latest stable.
go_download_sdk(
name = "go_sdk",
version = "1.20.4",
)

go_register_toolchains()

load("//:repositories.bzl", "go_repositories")

# gazelle:repository_macro repositories.bzl%go_repositories
go_repositories()

gazelle_dependencies(go_repository_default_config = "@//:WORKSPACE")

load(
"//toolchain:defs.bzl",
zig_toolchains = "toolchains",
)

zig_toolchains()

register_toolchains(
# if no `--platform` is specified, these toolchains will be used for
# (linux,darwin,windows)x(amd64,arm64)
"@zig_sdk//toolchain:linux_amd64_gnu.2.28",
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
"@zig_sdk//toolchain:darwin_amd64",
"@zig_sdk//toolchain:darwin_arm64",
"@zig_sdk//toolchain:windows_amd64",
"@zig_sdk//toolchain:windows_arm64",

# amd64 toolchains for libc-aware platforms:
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.28",
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.31",
"@zig_sdk//libc_aware/toolchain:linux_amd64_musl",
# arm64 toolchains for libc-aware platforms:
"@zig_sdk//libc_aware/toolchain:linux_arm64_gnu.2.28",
"@zig_sdk//libc_aware/toolchain:linux_arm64_musl",
)
9 changes: 6 additions & 3 deletions ci/lint
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ mapfile -t zigfiles < <(git ls-files '*.zig')
>&2 echo "--- zig fmt ${zigfiles[*]}"
$ZIG fmt "${zigfiles[@]}"

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

>&2 echo "--- buildifier :bazel:"
tools/buildifier -r -mode fix "$PWD"
Expand Down
Loading

0 comments on commit b1e501c

Please sign in to comment.