Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@ bazel_dep(name = "platforms", version = "0.0.4")
### INTERNAL ONLY - lines after this are not included in the release packaging.

# Gazelle extension is experimental
bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.33.0")
bazel_dep(name = "gazelle", repo_name = "bazel_gazelle", version = "0.26.0")
# Note that io_bazel_rules_go 0.34.0 is currently (2022-09-12) a continuously
# updated version (i.e. >= 0.35.0 in reality), which is what we need for
# buildools. See https://github.com/bazelbuild/bazel-skylib/issues/386#issuecomment-1243958234
bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.34.0")

# We need https://github.com/bazelbuild/bazel-gazelle/pull/1331 for buildtools
bazel_dep(name = "gazelle", repo_name = "bazel_gazelle", version = "0.27.0-pre")

git_override(
commit = "55ba8e3f2aaad0f43d82d02eba90ccf7a7fe9c73",
module_name = "gazelle",
remote = "https://github.com/bazelbuild/bazel-gazelle",
)

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")

Expand Down
32 changes: 27 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
maybe(
name = "io_bazel_rules_go",
repo_rule = http_archive,
sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
],
)

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

go_rules_dependencies()

go_register_toolchains(version = "1.17.1")
go_register_toolchains(version = "1.19.1")

# Below this line is for documentation generation only,
# and should thus not be included by dependencies on
Expand Down Expand Up @@ -80,6 +80,28 @@ http_archive(
# Another Gazelle repository hint.
# gazelle:repository go_repository name=bazel_gazelle importpath=github.com/bazelbuild/bazel-gazelle/testtools

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

gazelle_dependencies()

# Buildozer & deps
http_archive(
name = "com_google_protobuf",
sha256 = "4dd35e788944b7686aac898f77df4e9a54da0ca694b8801bd6b2a9ffc1b3085e",
strip_prefix = "protobuf-3.19.2",
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v3.19.2.tar.gz",
],
)

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

protobuf_deps()

go_repository(
name = "com_github_bazelbuild_buildtools",
build_naming_convention = "go_default_library",
importpath = "github.com/bazelbuild/buildtools",
sum = "h1:fmdo+fvvWlhldUcqkhAMpKndSxMN3vH5l7yow5cEaiQ=",
version = "v0.0.0-20220531122519-a43aed7014c8",
)
23 changes: 23 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//:bzl_library.bzl", "bzl_library")
load("//rules:diff_test.bzl", "diff_test")
load(":build_test_tests.bzl", "build_test_test_suite")
load(":collections_tests.bzl", "collections_test_suite")
load(":dicts_tests.bzl", "dicts_test_suite")
Expand Down Expand Up @@ -100,3 +101,25 @@ sh_test(
name = "shell_spawn_e2e_test",
srcs = [":shell_spawn_e2e_test_src"],
)

genrule(
name = "version_from_module.bazel",
srcs = ["//:MODULE.bazel"],
outs = ["version_from_module.bazel.out"],
cmd = "cat '$<' | $(location @com_github_bazelbuild_buildtools//buildozer) 'print version' '-:bazel_skylib' > '$@'",
tools = ["@com_github_bazelbuild_buildtools//buildozer"],
)

genrule(
name = "version_from_version.bzl",
srcs = ["//:version.bzl"],
outs = ["version_from_version.bzl.out"],
cmd = "sed -n 's/ *version = \"\\(.*\\)\"/\\1/p' '$<' > '$@'",
)

diff_test(
name = "bazel_skylib_version_consistency_test",
failure_message = "The values of 'version' in version.bzl and MODULE.bazel do not match",
file1 = ":version_from_module.bazel",
file2 = ":version_from_version.bzl",
)