1"""Load dependencies needed to compile the protobuf library as a 3rd-party consumer.""" 2 3load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 5PROTOBUF_MAVEN_ARTIFACTS = [ 6 "com.google.code.findbugs:jsr305:3.0.2", 7 "com.google.code.gson:gson:2.8.9", 8 "com.google.errorprone:error_prone_annotations:2.3.2", 9 "com.google.j2objc:j2objc-annotations:1.3", 10 "com.google.guava:guava:31.1-jre", 11 "com.google.guava:guava-testlib:31.1-jre", 12 "com.google.truth:truth:1.1.2", 13 "junit:junit:4.13.2", 14 "org.mockito:mockito-core:4.3.1", 15] 16 17def _github_archive(repo, commit, **kwargs): 18 repo_name = repo.split("/")[-1] 19 http_archive( 20 urls = [repo + "/archive/" + commit + ".zip"], 21 strip_prefix = repo_name + "-" + commit, 22 **kwargs 23 ) 24 25def protobuf_deps(): 26 """Loads common dependencies needed to compile the protobuf library.""" 27 28 if not native.existing_rule("bazel_skylib"): 29 http_archive( 30 name = "bazel_skylib", 31 sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", 32 urls = [ 33 "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", 34 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", 35 ], 36 ) 37 38 if not native.existing_rule("com_google_absl"): 39 # Abseil LTS from November 2021 40 _github_archive( 41 name = "com_google_absl", 42 repo = "https://github.com/abseil/abseil-cpp", 43 commit = "215105818dfde3174fe799600bb0f3cae233d0bf", 44 sha256 = "b4e20d9e752a75c10636675691b1e9c2698e0764cb404987d0ffa77223041c19", 45 ) 46 47 if not native.existing_rule("zlib"): 48 http_archive( 49 name = "zlib", 50 build_file = "@com_google_protobuf//:third_party/zlib.BUILD", 51 sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff", 52 strip_prefix = "zlib-1.2.11", 53 urls = ["https://github.com/madler/zlib/archive/v1.2.11.tar.gz"], 54 ) 55 56 if not native.existing_rule("rules_cc"): 57 _github_archive( 58 name = "rules_cc", 59 repo = "https://github.com/bazelbuild/rules_cc", 60 commit = "818289e5613731ae410efb54218a4077fb9dbb03", 61 sha256 = "0adbd6f567291ad526e82c765e15aed33cea5e256eeba129f1501142c2c56610", 62 ) 63 64 if not native.existing_rule("rules_java"): 65 _github_archive( 66 name = "rules_java", 67 repo = "https://github.com/bazelbuild/rules_java", 68 commit = "981f06c3d2bd10225e85209904090eb7b5fb26bd", 69 sha256 = "7979ece89e82546b0dcd1dff7538c34b5a6ebc9148971106f0e3705444f00665", 70 ) 71 72 if not native.existing_rule("rules_proto"): 73 _github_archive( 74 name = "rules_proto", 75 repo = "https://github.com/bazelbuild/rules_proto", 76 commit = "f7a30f6f80006b591fa7c437fe5a951eb10bcbcf", 77 sha256 = "a4382f78723af788f0bc19fd4c8411f44ffe0a72723670a34692ffad56ada3ac", 78 ) 79 80 if not native.existing_rule("rules_python"): 81 http_archive( 82 name = "rules_python", 83 sha256 = "9fcf91dbcc31fde6d1edb15f117246d912c33c36f44cf681976bd886538deba6", 84 strip_prefix = "rules_python-0.8.0", 85 url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.8.0.tar.gz", 86 ) 87 88 if not native.existing_rule("rules_jvm_external"): 89 _github_archive( 90 name = "rules_jvm_external", 91 repo = "https://github.com/bazelbuild/rules_jvm_external", 92 commit = "906875b0d5eaaf61a8ca2c9c3835bde6f435d011", 93 sha256 = "744bd7436f63af7e9872948773b8b106016dc164acb3960b4963f86754532ee7", 94 ) 95 96 if not native.existing_rule("rules_pkg"): 97 http_archive( 98 name = "rules_pkg", 99 urls = [ 100 "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz", 101 "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz", 102 ], 103 sha256 = "8a298e832762eda1830597d64fe7db58178aa84cd5926d76d5b744d6558941c2", 104 ) 105 106 if not native.existing_rule("io_bazel_rules_kotlin"): 107 http_archive( 108 name = "io_bazel_rules_kotlin", 109 urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v1.5.0-beta-4/rules_kotlin_release.tgz"], 110 sha256 = "6cbd4e5768bdfae1598662e40272729ec9ece8b7bded8f0d2c81c8ff96dc139d", 111 ) 112 113 if not native.existing_rule("upb"): 114 _github_archive( 115 name = "upb", 116 repo = "https://github.com/protocolbuffers/upb", 117 commit = "a5477045acaa34586420942098f5fecd3570f577", 118 sha256 = "0d6af8c8c00b3d733721f8d890ef43dd40f537c2e815b529085c1a6c30a21084", 119 ) 120 121 if not native.existing_rule("six"): 122 http_archive( 123 name = "six", 124 build_file = "@//:six.BUILD", 125 sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", 126 urls = ["https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55"], 127 ) 128 129 if not native.existing_rule("rules_cc"): 130 http_archive( 131 name = "rules_cc", 132 sha256 = "29daf0159f0cf552fcff60b49d8bcd4f08f08506d2da6e41b07058ec50cfeaec", 133 strip_prefix = "rules_cc-b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e", 134 urls = ["https://github.com/bazelbuild/rules_cc/archive/b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e.tar.gz"], 135 ) 136 137 if not native.existing_rule("rules_java"): 138 http_archive( 139 name = "rules_java", 140 sha256 = "f5a3e477e579231fca27bf202bb0e8fbe4fc6339d63b38ccb87c2760b533d1c3", 141 strip_prefix = "rules_java-981f06c3d2bd10225e85209904090eb7b5fb26bd", 142 urls = ["https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz"], 143 ) 144 145 if not native.existing_rule("rules_proto"): 146 http_archive( 147 name = "rules_proto", 148 sha256 = "88b0a90433866b44bb4450d4c30bc5738b8c4f9c9ba14e9661deb123f56a833d", 149 strip_prefix = "rules_proto-b0cc14be5da05168b01db282fe93bdf17aa2b9f4", 150 urls = ["https://github.com/bazelbuild/rules_proto/archive/b0cc14be5da05168b01db282fe93bdf17aa2b9f4.tar.gz"], 151 ) 152