|
| 1 | +# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel |
| 2 | +# https://github.com/protocolbuffers/protobuf/issues/14313 |
| 3 | + |
| 4 | +module( |
| 5 | + name = "protobuf", |
| 6 | + version = "33.4.envoy", |
| 7 | + compatibility_level = 1, |
| 8 | + repo_name = "com_google_protobuf", |
| 9 | +) |
| 10 | + |
| 11 | +# LOWER BOUND dependency versions. |
| 12 | +# Bzlmod follows MVS: |
| 13 | +# https://bazel.build/versions/6.0.0/build/bzlmod#version-resolution |
| 14 | +# Thus the highest version in their module graph is resolved. |
| 15 | + |
| 16 | +# These dependencies must be declared before the other rules dependencies. |
| 17 | +bazel_dep(name = "rules_apple", version = "3.16.0", repo_name = "build_bazel_rules_apple") |
| 18 | +bazel_dep(name = "apple_support", version = "1.15.1", repo_name = "build_bazel_apple_support") |
| 19 | + |
| 20 | +# Keep apple_support on 1.15.1 for now to avoid this issue: |
| 21 | +# https://github.com/bazelbuild/apple_support/issues/316 |
| 22 | +single_version_override( |
| 23 | + module_name = "apple_support", |
| 24 | + version = "1.15.1", |
| 25 | +) |
| 26 | + |
| 27 | +#ifndef PROTO2_OPENSOURCE |
| 28 | +# LINT.IfChange |
| 29 | +#endif // PROTO2_OPENSOURCE |
| 30 | +# protoc dependencies |
| 31 | +bazel_dep(name = "abseil-cpp", version = "20250512.1") |
| 32 | +bazel_dep(name = "rules_cc", version = "0.0.17") |
| 33 | +bazel_dep(name = "zlib", version = "1.3.1.bcr.5") |
| 34 | +#ifndef PROTO2_OPENSOURCE |
| 35 | +# LINT.ThenChange(//depot/google3/third_party/protobuf/compiler/notices.h) |
| 36 | +#endif // PROTO2_OPENSOURCE |
| 37 | + |
| 38 | +# other dependencies |
| 39 | +bazel_dep(name = "bazel_features", version = "1.33.0", repo_name = "proto_bazel_features") |
| 40 | +bazel_dep(name = "bazel_skylib", version = "1.7.1") |
| 41 | +bazel_dep(name = "jsoncpp", version = "1.9.6") |
| 42 | +bazel_dep(name = "rules_java", version = "8.6.1") |
| 43 | +bazel_dep(name = "rules_jvm_external", version = "6.7") |
| 44 | +bazel_dep(name = "rules_kotlin", version = "1.9.6") |
| 45 | +bazel_dep(name = "rules_license", version = "1.0.0") |
| 46 | +bazel_dep(name = "rules_pkg", version = "1.0.1") |
| 47 | +bazel_dep(name = "rules_python", version = "1.6.0") |
| 48 | + |
| 49 | +# Pin to rules_proto to 7.1.0 to avoid toolchain incompatibilities when |
| 50 | +# --incompatible_enable_proto_toolchain_resolution=true in Bazel 7. |
| 51 | +# rules_proto 7.0.2 from deps incorrectly rules_proto's toolchain_type but protobuf's toolchain, but |
| 52 | +# 7.1.0 uses protobuf's toolchain and toolchain_type. |
| 53 | +bazel_dep(name = "rules_proto", version = "7.1.0") |
| 54 | + |
| 55 | +bazel_dep(name = "rules_shell", version = "0.2.0") |
| 56 | +bazel_dep(name = "platforms", version = "0.0.11") |
| 57 | + |
| 58 | +# Define toolchains that use pre-built protoc binaries. |
| 59 | +prebuilt_protoc = use_extension("//bazel/private:prebuilt_protoc_extension.bzl", "protoc") |
| 60 | +use_repo( |
| 61 | + prebuilt_protoc, |
| 62 | + "prebuilt_protoc.linux_aarch_64", |
| 63 | + "prebuilt_protoc.osx_aarch_64", |
| 64 | + "prebuilt_protoc.linux_ppcle_64", |
| 65 | + "prebuilt_protoc.linux_s390_64", |
| 66 | + "prebuilt_protoc.linux_x86_32", |
| 67 | + "prebuilt_protoc.linux_x86_64", |
| 68 | + "prebuilt_protoc.osx_x86_64", |
| 69 | + "prebuilt_protoc.win32", |
| 70 | + "prebuilt_protoc.win64", |
| 71 | +) |
| 72 | + |
| 73 | +# However this registration only matters if the config_setting for prefer_prebuilt_protoc is true, |
| 74 | +# using --@protobuf//bazel/toolchains:prefer_prebuilt_protoc |
| 75 | +register_toolchains("//bazel/private/toolchains/prebuilt:all") |
| 76 | + |
| 77 | +# From-source protobuf toolchains |
| 78 | +# Fallback if nothing is already registered |
| 79 | +register_toolchains("//bazel/private/toolchains:all") |
| 80 | + |
| 81 | +# Keep this list minimal; these dependencies will be part of the common `maven` install and could affect end-user projects. |
| 82 | +PROTOBUF_MAVEN_ARTIFACTS = [ |
| 83 | + "com.google.code.findbugs:jsr305:3.0.2", |
| 84 | + "com.google.code.gson:gson:2.8.9", |
| 85 | + "com.google.errorprone:error_prone_annotations:2.5.1", |
| 86 | + "com.google.j2objc:j2objc-annotations:2.8", |
| 87 | + "com.google.guava:guava:32.0.1-jre", |
| 88 | +] |
| 89 | + |
| 90 | +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") |
| 91 | +maven.install( |
| 92 | + artifacts = PROTOBUF_MAVEN_ARTIFACTS, |
| 93 | + lock_file = "//:maven_install.json", |
| 94 | + repositories = [ |
| 95 | + "https://repo1.maven.org/maven2", |
| 96 | + "https://repo.maven.apache.org/maven2", |
| 97 | + ], |
| 98 | +) |
| 99 | + |
| 100 | +# Use the default "maven" namespace because protobuf java targets are exposed to users |
| 101 | +# See https://github.com/protocolbuffers/protobuf/issues/21177 |
| 102 | +use_repo(maven, "maven") |
| 103 | + |
| 104 | +# Temporarily pin transitive dependency for https://github.com/bazelbuild/bazel/issues/24426 |
| 105 | +bazel_dep(name = "re2", version = "2024-07-02.bcr.1") |
| 106 | + |
| 107 | +# For clang-cl configuration |
| 108 | +cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension") |
| 109 | +use_repo(cc_configure, "local_config_cc") |
0 commit comments