Skip to content

Commit

Permalink
Fix bazel @ HEAD compat (#351)
Browse files Browse the repository at this point in the history
This required adding some loads, and also updating some deps. The
biggest annoyance here was copying the linking logic from rules_apple
since we were doing testing with that relying on bazel itself before. We
might want to revisit this in the future, but IIRC the intent was to
test the toolchain with "real" linking logic so we don't want to just
toss it
  • Loading branch information
keith authored Dec 12, 2024
1 parent ca8b66c commit 1e48772
Show file tree
Hide file tree
Showing 15 changed files with 354 additions and 9 deletions.
23 changes: 19 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,30 @@ module(
bazel_dep(name = "bazel_features", version = "1.10.0")
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "rules_cc", version = "0.0.8")

apple_cc_configure = use_extension("//crosstool:setup.bzl", "apple_cc_configure_extension")
use_repo(apple_cc_configure, "local_config_apple_cc", "local_config_apple_cc_toolchains")

register_toolchains("@local_config_apple_cc_toolchains//:all")

bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
bazel_dep(
name = "stardoc",
version = "0.6.2",
version = "0.7.2",
dev_dependency = True,
repo_name = "io_bazel_stardoc",
)

apple_cc_configure = use_extension("//crosstool:setup.bzl", "apple_cc_configure_extension")
use_repo(apple_cc_configure, "local_config_apple_cc", "local_config_apple_cc_toolchains")
# TODO: Remove when https://github.com/bazelbuild/stardoc/pull/269 is in a release
bazel_dep(name = "rules_jvm_external", version = "6.6", dev_dependency = True)
bazel_dep(name = "protobuf", version = "29.1", dev_dependency = True)

register_toolchains("@local_config_apple_cc_toolchains//:all")
# TODO: Remove override when a protobuf release is available that supports
# Bazel 8
archive_override(
module_name = "protobuf",
integrity = "sha256-YhxaemCfJrKK2is5/vAitBuM4dosZZ2aT01UxfppMJg=",
strip_prefix = "protobuf-bb287be772454d63b411b73d60b1d92daa879f2e",
urls = ["https://github.com/protocolbuffers/protobuf/archive/bb287be772454d63b411b73d60b1d92daa879f2e.zip"],
)
13 changes: 13 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ stardoc_external_deps()
load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install")

stardoc_pinned_maven_install()

http_archive(
name = "rules_shell",
sha256 = "d8cd4a3a91fc1dc68d4c7d6b655f09def109f7186437e3f50a9b60ab436a0c53",
strip_prefix = "rules_shell-0.3.0",
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.3.0/rules_shell-v0.3.0.tar.gz",
)

load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")

rules_shell_dependencies()

rules_shell_toolchains()
2 changes: 2 additions & 0 deletions crosstool/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")

package(default_visibility = ["//visibility:public"])

# Files which shouldn't be publicly visible and dependencies of all objc_* or ios_* rules should be excluded.
Expand Down
13 changes: 12 additions & 1 deletion doc/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

_DOC_SRCS = {
"rules": [
Expand All @@ -27,7 +28,7 @@ write_file(
[
stardoc(
name = file + "_doc",
out = file + ".md_",
out = file + ".md_pre",
header_template = file + "_header.vm",
input = "//rules:rules.doc.bzl",
symbol_names = symbols,
Expand All @@ -40,6 +41,16 @@ write_file(
] in _DOC_SRCS.items()
]

[
genrule(
name = "fix_stardoc_" + file,
srcs = [file + ".md_pre"],
outs = [file + ".md_"],
cmd = "sed '/rules.doc.bzl/,+1d' $(SRCS) > $(OUTS)",
)
for file in _DOC_SRCS.keys()
]

[
diff_test(
name = "test_" + file,
Expand Down
1 change: 1 addition & 0 deletions lib/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_cc//cc:defs.bzl", "objc_library")

licenses(["notice"])

Expand Down
8 changes: 8 additions & 0 deletions lib/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ def apple_support_dependencies():
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.10.0/bazel_features-v1.10.0.tar.gz",
)

_maybe(
http_archive,
name = "rules_cc",
sha256 = "ae46b722a8b8e9b62170f83bfb040cbf12adb732144e689985a66b26410a7d6f",
strip_prefix = "rules_cc-0.0.8",
url = "https://github.com/bazelbuild/rules_cc/releases/download/0.0.8/rules_cc-0.0.8.tar.gz",
)

apple_cc_configure()
2 changes: 2 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("//rules:apple_genrule.bzl", "apple_genrule")
load(":apple_support_test.bzl", "apple_support_test")
load(":available_xcodes_test.bzl", "available_xcodes_test")
Expand Down
1 change: 1 addition & 0 deletions test/header_parsing/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library")

package(features = ["parse_headers"])

Expand Down
1 change: 1 addition & 0 deletions test/layering_check/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test", "objc_library")

package(features = ["layering_check"])

Expand Down
Loading

0 comments on commit 1e48772

Please sign in to comment.