Skip to content
Merged
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
10 changes: 5 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ module(

bazel_dep(
name = "bazel_features",
version = "1.9.1",
version = "1.21.0",
)
bazel_dep(
name = "bazel_skylib",
version = "1.5.0",
version = "1.7.1",
)
bazel_dep(
name = "platforms",
version = "0.0.10",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
version = "0.0.17",
)
bazel_dep(
name = "rules_license",
version = "0.0.8",
version = "1.0.0",
)
bazel_dep(
name = "apple_support",
version = "1.13.0",
version = "1.17.1",
repo_name = "build_bazel_apple_support",
)

Expand Down
4 changes: 4 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ rules_rust_dependencies()

rust_register_toolchains()

load("@rules_rust//rust:repositories_transitive.bzl", "rules_rust_transitive_dependencies")

rules_rust_transitive_dependencies()

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")

crate_universe_dependencies(bootstrap = True)
Expand Down
5 changes: 4 additions & 1 deletion crate_universe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ bzl_library(
name = "bzl_lib",
srcs = [":bzl_srcs"],
visibility = ["//visibility:public"],
deps = ["//rust:bzl_lib"],
deps = [
"//rust:bzl_lib",
"@bazel_features//:features",
],
)

filegroup(
Expand Down
20 changes: 17 additions & 3 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ bzl_library(
"@bazel_tools//tools:bzl_srcs",
],
deps = [
"@bazel_features//:deps",
"@bazel_features//:features",
"@bazel_skylib//lib:paths",
"@bazel_skylib//lib:selects",
"@bazel_skylib//lib:structs",
Expand Down Expand Up @@ -172,11 +170,27 @@ stardoc(
deps = [":all_docs"],
)

# This target exists to avoid this issue:
# https://github.com/bazelbuild/rules_cc/issues/279
bzl_library(
name = "bindgen_lib",
srcs = [
"@com_google_protobuf//:bzl_srcs",
"@rules_cc//cc:bzl_srcs",
],
deps = [
"@com_google_protobuf//bazel:cc_proto_library_bzl",
"@rules_cc//cc/common",
"@rules_cc//cc/toolchains:toolchain_rules",
"@rules_rust_bindgen//:bzl_lib",
],
)

stardoc(
name = "rust_bindgen",
out = "rust_bindgen.md",
input = "@rules_rust_bindgen//:defs.bzl",
deps = ["@rules_rust_bindgen//:bzl_lib"],
deps = [":bindgen_lib"],
)

stardoc(
Expand Down
14 changes: 12 additions & 2 deletions docs/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"""rules_rust docs"""

module(
name = "rules_rust_docs",
version = "0.0.0",
)

bazel_dep(name = "rules_rust", version = "0.54.1")
local_path_override(
module_name = "rules_rust",
Expand Down Expand Up @@ -39,6 +44,11 @@ bazel_dep(
version = "0.6.2",
)
bazel_dep(
name = "bazel_features",
version = "1.14.0",
name = "protobuf",
version = "27.0",
repo_name = "com_google_protobuf",
)
bazel_dep(
name = "rules_cc",
version = "0.0.17",
)
4 changes: 4 additions & 0 deletions examples/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ rust_register_toolchains(
edition = "2018",
)

load("@rules_rust//rust:repositories_transitive.bzl", "rules_rust_transitive_dependencies")

rules_rust_transitive_dependencies()

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")

crate_universe_dependencies(bootstrap = True)
Expand Down
4 changes: 4 additions & 0 deletions examples/ios/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ rust_register_toolchains(
],
)

load("@rules_rust//rust:repositories_transitive.bzl", "rules_rust_transitive_dependencies")

rules_rust_transitive_dependencies()

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

http_archive(
Expand Down
4 changes: 4 additions & 0 deletions examples/ios_build/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ rust_register_toolchains(
],
)

load("@rules_rust//rust:repositories_transitive.bzl", "rules_rust_transitive_dependencies")

rules_rust_transitive_dependencies()

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")

crate_universe_dependencies(bootstrap = True)
Expand Down
1 change: 0 additions & 1 deletion extensions/bindgen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ bzl_library(
deps = [
"//3rdparty:bzl_lib",
"//private:bzl_lib",
"@rules_rust//rust:bzl_lib",
],
)

Expand Down
7 changes: 0 additions & 7 deletions extensions/prost/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ def rust_prost_dependencies(bzlmod = False):
strip_prefix = "protobuf-3.18.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v3.18.0/protobuf-all-3.18.0.tar.gz"],
)
maybe(
http_archive,
name = "bazel_features",
sha256 = "5d7e4eb0bb17aee392143cd667b67d9044c270a9345776a5e5a3cccbc44aa4b3",
strip_prefix = "bazel_features-1.13.0",
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.13.0/bazel_features-v1.13.0.tar.gz",
)
maybe(
http_archive,
name = "zlib",
Expand Down
8 changes: 0 additions & 8 deletions extensions/protobuf/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ def rust_proto_protobuf_dependencies(bzlmod = False):
],
)

maybe(
http_archive,
name = "bazel_features",
sha256 = "5d7e4eb0bb17aee392143cd667b67d9044c270a9345776a5e5a3cccbc44aa4b3",
strip_prefix = "bazel_features-1.13.0",
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.13.0/bazel_features-v1.13.0.tar.gz",
)

return crate_repositories()

# buildifier: disable=unnamed-macro
Expand Down
Empty file.
25 changes: 25 additions & 0 deletions rust/private/3rdparty/rules_cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/cc/defs.bzl b/cc/defs.bzl
index 4fccdcc..d848ede 100644
--- a/cc/defs.bzl
+++ b/cc/defs.bzl
@@ -13,7 +13,7 @@
# limitations under the License.
"""Starlark rules for building C++ projects."""

-load("@com_google_protobuf//bazel:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library")
+load("//cc/private:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library")
load("//cc:cc_binary.bzl", _cc_binary = "cc_binary")
load("//cc:cc_import.bzl", _cc_import = "cc_import")
load("//cc:cc_library.bzl", _cc_library = "cc_library")
diff --git a/cc/private/cc_proto_library.bzl b/cc/private/cc_proto_library.bzl
new file mode 100644
index 0000000..bd94272
--- /dev/null
+++ b/cc/private/cc_proto_library.bzl
@@ -0,0 +1,6 @@
+"""Avoid the following issue by providing a native reexport:
+https://github.com/bazelbuild/rules_cc/issues/274
+"""
+
+def cc_proto_library(**kwargs):
+ native.cc_proto_library(**kwargs)
6 changes: 6 additions & 0 deletions rust/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ bzl_library(
srcs = ["@bazel_tools//tools:bzl_srcs"],
)

bzl_library(
name = "rules_cc_bzl_lib",
srcs = ["@rules_cc//cc:bzl_srcs"],
)

bzl_library(
name = "bzl_lib",
srcs = glob(["**/*.bzl"]),
visibility = ["//rust:__subpackages__"],
deps = [
":bazel_tools_bzl_lib",
":rules_cc_bzl_lib",
"//rust/platform:bzl_lib",
"@bazel_skylib//lib:paths",
"@bazel_skylib//rules:common_settings",
Expand Down
38 changes: 27 additions & 11 deletions rust/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,46 @@ def rules_rust_dependencies():
],
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
)

# Avoid the following issue https://github.com/bazelbuild/rules_cc/issues/274
rules_cc_kwargs = {}
if native.bazel_version.startswith(("6", "7")):
rules_cc_kwargs.update({
"patch_args": ["-p1"],
"patches": [Label("//rust/private/3rdparty:rules_cc.patch")],
})
maybe(
http_archive,
name = "rules_cc",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-0.0.9",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
strip_prefix = "rules_cc-0.0.17",
**rules_cc_kwargs
)
maybe(
http_archive,
name = "rules_license",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.8/rules_license-0.0.8.tar.gz",
"https://github.com/bazelbuild/rules_license/releases/download/0.0.8/rules_license-0.0.8.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
"https://github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
],
sha256 = "241b06f3097fd186ff468832150d6cc142247dc42a32aaefb56d0099895fd229",
sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38",
)
maybe(
http_archive,
name = "bazel_features",
sha256 = "af3d4fb1cf4f25942cb4a933b1ad93a0ea9fe9ee70c2af7f369fb72a67c266e5",
strip_prefix = "bazel_features-1.21.0",
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.21.0/bazel_features-v1.21.0.tar.gz",
)

maybe(
http_archive,
name = "bazel_skylib",
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
],
)

Expand All @@ -90,8 +106,8 @@ def rules_rust_dependencies():
maybe(
http_archive,
name = "build_bazel_apple_support",
sha256 = "1c4031e72b456a048d8177f59a5581808c07585fa9e255c6f5fefb8752af7e40",
url = "https://github.com/bazelbuild/apple_support/releases/download/1.13.0/apple_support.1.13.0.tar.gz",
sha256 = "b53f6491e742549f13866628ddffcc75d1f3b2d6987dc4f14a16b242113c890b",
url = "https://github.com/bazelbuild/apple_support/releases/download/1.17.1/apple_support.1.17.1.tar.gz",
)

# process_wrapper needs a low-dependency way to process json.
Expand Down
9 changes: 9 additions & 0 deletions rust/repositories_transitive.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Transitive repositories for Rust dependencies."""

load("@bazel_features//:deps.bzl", "bazel_features_deps")
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies")

def rules_rust_transitive_dependencies():
"""Rust transitive repositories."""
rules_cc_dependencies()
bazel_features_deps()