2020-12-23 08:10:37 +01:00
|
|
|
"""
|
|
|
|
Replace @com_google_protobuf with a platform binary.
|
|
|
|
|
|
|
|
Avoids the long initial compile, but will fail if anything depends on the protobuf library.
|
|
|
|
"""
|
|
|
|
|
|
|
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
|
|
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
|
|
|
|
|
|
|
def _impl(rctx):
|
|
|
|
rctx.file("BUILD.bazel", """
|
|
|
|
alias(
|
|
|
|
name = "protoc",
|
|
|
|
actual = select({
|
2021-07-10 15:58:53 +02:00
|
|
|
"@ankidesktop//platforms:windows_x86_64": "@protoc_bin_windows//:bin/protoc.exe",
|
2021-10-15 15:20:43 +02:00
|
|
|
"@ankidesktop//platforms:macos_arm64": "@protoc_bin_macos//:bin/protoc",
|
2021-07-10 15:58:53 +02:00
|
|
|
"@ankidesktop//platforms:macos_x86_64": "@protoc_bin_macos//:bin/protoc",
|
|
|
|
"@ankidesktop//platforms:linux_x86_64": "@protoc_bin_linux_x86_64//:bin/protoc",
|
|
|
|
"@ankidesktop//platforms:linux_arm64": "@protoc_bin_linux_arm64//:bin/protoc"
|
2020-12-23 08:10:37 +01:00
|
|
|
}),
|
|
|
|
visibility = ["//visibility:public"]
|
|
|
|
)
|
|
|
|
""")
|
|
|
|
|
|
|
|
_setup_protoc = repository_rule(
|
|
|
|
implementation = _impl,
|
2021-11-01 02:36:44 +01:00
|
|
|
local = False,
|
2020-12-23 08:10:37 +01:00
|
|
|
attrs = {},
|
|
|
|
)
|
|
|
|
|
|
|
|
def setup_protobuf_binary(name):
|
|
|
|
maybe(
|
|
|
|
http_archive,
|
|
|
|
name = "protoc_bin_macos",
|
|
|
|
urls = [
|
2022-02-27 04:13:28 +01:00
|
|
|
"https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-osx-x86_64.zip",
|
2020-12-23 08:10:37 +01:00
|
|
|
],
|
2022-02-27 04:13:28 +01:00
|
|
|
sha256 = "d8b55cf1e887917dd43c447d77bd5bd213faff1e18ac3a176b35558d86f7ffff",
|
2020-12-23 08:10:37 +01:00
|
|
|
build_file_content = """exports_files(["bin/protoc"])""",
|
|
|
|
)
|
|
|
|
|
|
|
|
maybe(
|
|
|
|
http_archive,
|
2020-12-29 09:38:50 +01:00
|
|
|
name = "protoc_bin_linux_x86_64",
|
2020-12-23 08:10:37 +01:00
|
|
|
urls = [
|
2022-02-27 04:13:28 +01:00
|
|
|
"https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip",
|
2020-12-23 08:10:37 +01:00
|
|
|
],
|
2022-02-27 04:13:28 +01:00
|
|
|
sha256 = "058d29255a08f8661c8096c92961f3676218704cbd516d3916ec468e139cbd87",
|
2020-12-23 08:10:37 +01:00
|
|
|
build_file_content = """exports_files(["bin/protoc"])""",
|
|
|
|
)
|
|
|
|
|
2020-12-29 09:40:04 +01:00
|
|
|
maybe(
|
|
|
|
http_archive,
|
|
|
|
name = "protoc_bin_linux_arm64",
|
|
|
|
urls = [
|
2022-02-27 04:13:28 +01:00
|
|
|
"https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-aarch_64.zip",
|
2020-12-29 09:40:04 +01:00
|
|
|
],
|
2022-02-27 04:13:28 +01:00
|
|
|
sha256 = "95584939e733bdd6ffb8245616b2071f565cd4c28163b6c21c8f936a9ee20861",
|
2020-12-29 09:40:04 +01:00
|
|
|
build_file_content = """exports_files(["bin/protoc"])""",
|
|
|
|
)
|
|
|
|
|
2020-12-23 08:10:37 +01:00
|
|
|
maybe(
|
|
|
|
http_archive,
|
|
|
|
name = "protoc_bin_windows",
|
|
|
|
urls = [
|
2022-02-27 04:13:28 +01:00
|
|
|
"https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-win64.zip",
|
2020-12-23 08:10:37 +01:00
|
|
|
],
|
2022-02-27 04:13:28 +01:00
|
|
|
sha256 = "828d2bdfe410e988cfc46462bcabd34ffdda8cc172867989ec647eadc55b03b5",
|
2020-12-23 08:10:37 +01:00
|
|
|
build_file_content = """exports_files(["bin/protoc.exe"])""",
|
|
|
|
)
|
|
|
|
|
|
|
|
if not native.existing_rule(name):
|
|
|
|
_setup_protoc(
|
|
|
|
name = name,
|
|
|
|
)
|