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-10-21 12:09:00 +02:00
|
|
|
"https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-osx-universal_binary.zip",
|
2020-12-23 08:10:37 +01:00
|
|
|
],
|
2022-10-21 12:09:00 +02:00
|
|
|
sha256 = "e3324d3bc2e9bc967a0bec2472e0ec73b26f952c7c87f2403197414f780c3c6c",
|
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-10-21 12:09:00 +02:00
|
|
|
"https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-linux-x86_64.zip",
|
2020-12-23 08:10:37 +01:00
|
|
|
],
|
2022-10-21 12:09:00 +02:00
|
|
|
sha256 = "f90d0dd59065fef94374745627336d622702b67f0319f96cee894d41a974d47a",
|
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-10-21 12:09:00 +02:00
|
|
|
"https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-linux-aarch_64.zip",
|
2020-12-29 09:40:04 +01:00
|
|
|
],
|
2022-10-21 12:09:00 +02:00
|
|
|
sha256 = "f3d8eb5839d6186392d8c7b54fbeabbb6fcdd90618a500b77cb2e24faa245cad",
|
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-10-21 12:09:00 +02:00
|
|
|
"https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-win64.zip",
|
2020-12-23 08:10:37 +01:00
|
|
|
],
|
2022-10-21 12:09:00 +02:00
|
|
|
sha256 = "3657053024faa439ff5f8c1dd2ee06bac0f9b9a3d660e99944f015a7451e87ec",
|
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,
|
|
|
|
)
|