1"""Load dependencies needed to compile the protobuf library as a 3rd-party consumer. 2 3The consumers should use the following WORKSPACE snippet, which loads dependencies 4and sets up the repositories protobuf needs: 5 6``` 7http_archive( 8 name = "protobuf", 9 strip_prefix = "protobuf-VERSION", 10 sha256 = ..., 11 url = ..., 12) 13 14load("@protobuf//:protobuf_deps.bzl", "protobuf_deps") 15 16protobuf_deps() 17``` 18""" 19 20load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 21load("//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility 22load("//python/dist:python_downloads.bzl", "python_nuget_package", "python_source_archive") 23load("//python/dist:system_python.bzl", "system_python") 24 25PROTOBUF_MAVEN_ARTIFACTS = [ 26 "com.google.caliper:caliper:1.0-beta-3", 27 "com.google.code.findbugs:jsr305:3.0.2", 28 "com.google.code.gson:gson:2.8.9", 29 "com.google.errorprone:error_prone_annotations:2.5.1", 30 "com.google.j2objc:j2objc-annotations:2.8", 31 "com.google.guava:guava:32.0.1-jre", 32 "com.google.guava:guava-testlib:32.0.1-jre", 33 "com.google.truth:truth:1.1.2", 34 "junit:junit:4.13.2", 35 "org.mockito:mockito-core:4.3.1", 36 "biz.aQute.bnd:biz.aQute.bndlib:6.4.0", 37 "info.picocli:picocli:4.6.3", 38] 39 40def _github_archive(repo, commit, **kwargs): 41 repo_name = repo.split("/")[-1] 42 http_archive( 43 urls = [repo + "/archive/" + commit + ".zip"], 44 strip_prefix = repo_name + "-" + commit, 45 **kwargs 46 ) 47 48def protobuf_deps(): 49 """Loads common dependencies needed to compile the protobuf library.""" 50 51 if not native.existing_rule("bazel_skylib"): 52 http_archive( 53 name = "bazel_skylib", 54 sha256 = "d00f1389ee20b60018e92644e0948e16e350a7707219e7a390fb0a99b6ec9262", 55 urls = [ 56 "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.0/bazel-skylib-1.7.0.tar.gz", 57 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.0/bazel-skylib-1.7.0.tar.gz", 58 ], 59 ) 60 61 if not native.existing_rule("com_google_absl"): 62 _github_archive( 63 name = "com_google_absl", 64 repo = "https://github.com/abseil/abseil-cpp", 65 # TODO: use Layout::WithStaticSizes in SerialArenaChunk when we update 66 # abseil to new release. 67 commit = "4a2c63365eff8823a5221db86ef490e828306f9d", # Abseil LTS 20240116.0 68 sha256 = "f49929d22751bf70dd61922fb1fd05eb7aec5e7a7f870beece79a6e28f0a06c1", 69 ) 70 71 if not native.existing_rule("zlib"): 72 http_archive( 73 name = "zlib", 74 build_file = Label("//:third_party/zlib.BUILD"), 75 sha256 = "38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32", 76 strip_prefix = "zlib-1.3.1", 77 urls = [ 78 "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.xz", 79 "https://zlib.net/zlib-1.3.1.tar.xz", 80 ], 81 ) 82 83 if not native.existing_rule("jsoncpp"): 84 _github_archive( 85 name = "jsoncpp", 86 repo = "https://github.com/open-source-parsers/jsoncpp", 87 commit = "5defb4ed1a4293b8e2bf641e16b156fb9de498cc", # 1.9.5 88 sha256 = "a03d3136ff6dd092143bba8d3ded641e87b44e6c0b1f632b368f6cc8587524b5", 89 build_file = Label("//:third_party/jsoncpp.BUILD"), 90 ) 91 92 if not native.existing_rule("rules_cc"): 93 http_archive( 94 name = "rules_cc", 95 urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"], 96 sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df", 97 strip_prefix = "rules_cc-0.0.16", 98 ) 99 100 if not native.existing_rule("rules_java"): 101 http_archive( 102 name = "rules_java", 103 url = "https://github.com/bazelbuild/rules_java/releases/download/7.12.2/rules_java-7.12.2.tar.gz", 104 sha256 = "a9690bc00c538246880d5c83c233e4deb83fe885f54c21bb445eb8116a180b83", 105 ) 106 107 if not native.existing_rule("rules_shell"): 108 http_archive( 109 name = "rules_shell", 110 sha256 = "410e8ff32e018b9efd2743507e7595c26e2628567c42224411ff533b57d27c28", 111 strip_prefix = "rules_shell-0.2.0", 112 url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.2.0/rules_shell-v0.2.0.tar.gz", 113 ) 114 115 if not native.existing_rule("proto_bazel_features"): 116 proto_bazel_features(name = "proto_bazel_features") 117 118 if not native.existing_rule("rules_python"): 119 http_archive( 120 name = "rules_python", 121 sha256 = "d70cd72a7a4880f0000a6346253414825c19cdd40a28289bdf67b8e6480edff8", 122 strip_prefix = "rules_python-0.28.0", 123 url = "https://github.com/bazelbuild/rules_python/releases/download/0.28.0/rules_python-0.28.0.tar.gz", 124 ) 125 126 if not native.existing_rule("system_python"): 127 system_python( 128 name = "system_python", 129 minimum_python_version = "3.8", 130 ) 131 132 if not native.existing_rule("rules_jvm_external"): 133 http_archive( 134 name = "rules_jvm_external", 135 strip_prefix = "rules_jvm_external-6.3", 136 sha256 = "c18a69d784bcd851be95897ca0eca0b57dc86bb02e62402f15736df44160eb02", 137 url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/6.3/rules_jvm_external-6.3.tar.gz", 138 ) 139 140 if not native.existing_rule("rules_pkg"): 141 http_archive( 142 name = "rules_pkg", 143 urls = [ 144 "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/1.0.1/rules_pkg-1.0.1.tar.gz", 145 "https://github.com/bazelbuild/rules_pkg/releases/download/1.0.1/rules_pkg-1.0.1.tar.gz", 146 ], 147 sha256 = "d20c951960ed77cb7b341c2a59488534e494d5ad1d30c4818c736d57772a9fef", 148 ) 149 150 if not native.existing_rule("build_bazel_rules_apple"): 151 http_archive( 152 name = "build_bazel_rules_apple", 153 sha256 = "9c4f1e1ec4fdfeac5bddb07fa0e872c398e3d8eb0ac596af9c463f9123ace292", 154 url = "https://github.com/bazelbuild/rules_apple/releases/download/3.2.1/rules_apple.3.2.1.tar.gz", 155 ) 156 157 if not native.existing_rule("build_bazel_apple_support"): 158 http_archive( 159 name = "build_bazel_apple_support", 160 sha256 = "100d12617a84ebc7ee7a10ecf3b3e2fdadaebc167ad93a21f820a6cb60158ead", 161 url = "https://github.com/bazelbuild/apple_support/releases/download/1.12.0/apple_support.1.12.0.tar.gz", 162 ) 163 164 if not native.existing_rule("rules_kotlin"): 165 http_archive( 166 name = "rules_kotlin", 167 sha256 = "3b772976fec7bdcda1d84b9d39b176589424c047eb2175bed09aac630e50af43", 168 url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.9.6/rules_kotlin-v1.9.6.tar.gz", 169 ) 170 171 if not native.existing_rule("rules_license"): 172 http_archive( 173 name = "rules_license", 174 urls = [ 175 "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz", 176 "https://github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz", 177 ], 178 sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38", 179 ) 180 181 # Python Downloads 182 python_source_archive( 183 name = "python-3.8.0", 184 sha256 = "f1069ad3cae8e7ec467aa98a6565a62a48ef196cb8f1455a245a08db5e1792df", 185 ) 186 python_nuget_package( 187 name = "nuget_python_i686_3.8.0", 188 sha256 = "87a6481f5eef30b42ac12c93f06f73bd0b8692f26313b76a6615d1641c4e7bca", 189 ) 190 python_nuget_package( 191 name = "nuget_python_x86-64_3.8.0", 192 sha256 = "96c61321ce90dd053c8a04f305a5f6cc6d91350b862db34440e4a4f069b708a0", 193 ) 194 python_nuget_package( 195 name = "nuget_python_i686_3.9.0", 196 sha256 = "229abecbe49dc08fe5709e0b31e70edfb3b88f23335ebfc2904c44f940fd59b6", 197 ) 198 python_nuget_package( 199 name = "nuget_python_x86-64_3.9.0", 200 sha256 = "6af58a733e7dfbfcdd50d55788134393d6ffe7ab8270effbf724bdb786558832", 201 ) 202 python_nuget_package( 203 name = "nuget_python_i686_3.10.0", 204 sha256 = "e115e102eb90ce160ab0ef7506b750a8d7ecc385bde0a496f02a54337a8bc333", 205 ) 206 python_nuget_package( 207 name = "nuget_python_x86-64_3.10.0", 208 sha256 = "4474c83c25625d93e772e926f95f4cd398a0abbb52793625fa30f39af3d2cc00", 209 ) 210 native.register_toolchains("//bazel/private/toolchains:all") 211