fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

UebelAndreAdded bzlmod support to all extension rules. (#3037)a7aba2d0

main
2.1 KiB55 linesraw
1# Copyright 2018 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Dependencies for Rust proto rules"""
16
17load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
19load("//3rdparty/crates:defs.bzl", "crate_repositories")
20
21def rust_proto_protobuf_dependencies(bzlmod = False):
22    """Sets up dependencies for rules_rust's proto support.
23
24    Args:
25        bzlmod (bool): Whether this function is being called from a bzlmod context rather than a workspace context.
26
27    Returns:
28        A list of structs containing information about root module deps to report to bzlmod's extension_metadata.
29
30    """
31    if not bzlmod:
32        maybe(
33            http_archive,
34            name = "rules_proto",
35            sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
36            strip_prefix = "rules_proto-6.0.2",
37            url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz",
38        )
39
40        maybe(
41            http_archive,
42            name = "com_google_protobuf",
43            integrity = "sha256-fD69eq7dhvpdxHmg/agD9gLKr3jYr/fOg7ieG4rnRCo=",
44            strip_prefix = "protobuf-28.3",
45            urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protobuf-28.3.tar.gz"],
46        )
47
48    return crate_repositories()
49
50# buildifier: disable=unnamed-macro
51def rust_proto_protobuf_register_toolchains(register_toolchains = True):
52    """Register toolchains for proto compilation."""
53
54    if register_toolchains:
55        native.register_toolchains(str(Label("//:default_proto_toolchain")))