Comment fix and other internal changes.
[google-protobuf.git] / protobuf_deps.bzl
blobd5d255bfdba4e8a08df0a79d1e0789e5744acb35
1 """Load dependencies needed to compile the protobuf library as a 3rd-party consumer.
3 The consumers should use the following WORKSPACE snippet, which loads dependencies
4 and sets up the repositories protobuf needs:
6 ```
7 http_archive(
8     name = "com_google_protobuf",
9     strip_prefix = "protobuf-VERSION",
10     sha256 = ...,
11     url = ...,
14 load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
16 protobuf_deps()
18 load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
20 rules_java_dependencies()
22 load("@rules_java//java:repositories.bzl", "rules_java_toolchains")
24 rules_java_toolchains()
26 load("@rules_python//python:repositories.bzl", "py_repositories")
28 py_repositories()
29 ```
30 """
32 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
33 load("//bazel/private:proto_bazel_features.bzl", "proto_bazel_features")  # buildifier: disable=bzl-visibility
34 load("//python/dist:python_downloads.bzl", "python_nuget_package", "python_source_archive")
35 load("//python/dist:system_python.bzl", "system_python")
37 PROTOBUF_MAVEN_ARTIFACTS = [
38     "com.google.caliper:caliper:1.0-beta-3",
39     "com.google.code.findbugs:jsr305:3.0.2",
40     "com.google.code.gson:gson:2.8.9",
41     "com.google.errorprone:error_prone_annotations:2.5.1",
42     "com.google.j2objc:j2objc-annotations:2.8",
43     "com.google.guava:guava:32.0.1-jre",
44     "com.google.guava:guava-testlib:32.0.1-jre",
45     "com.google.testparameterinjector:test-parameter-injector:1.18",
46     "com.google.truth:truth:1.1.2",
47     "junit:junit:4.13.2",
48     "org.mockito:mockito-core:4.3.1",
49     "biz.aQute.bnd:biz.aQute.bndlib:6.4.0",
50     "info.picocli:picocli:4.6.3",
53 def _github_archive(repo, commit, **kwargs):
54     repo_name = repo.split("/")[-1]
55     http_archive(
56         urls = [repo + "/archive/" + commit + ".zip"],
57         strip_prefix = repo_name + "-" + commit,
58         **kwargs
59     )
61 def protobuf_deps():
62     """Loads common dependencies needed to compile the protobuf library."""
64     if not native.existing_rule("bazel_features"):
65         http_archive(
66             name = "bazel_features",
67             sha256 = "95fb3cfd11466b4cad6565e3647a76f89886d875556a4b827c021525cb2482bb",
68             strip_prefix = "bazel_features-1.10.0",
69             url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.10.0/bazel_features-v1.10.0.tar.gz",
70         )
72     if not native.existing_rule("bazel_skylib"):
73         http_archive(
74             name = "bazel_skylib",
75             sha256 = "d00f1389ee20b60018e92644e0948e16e350a7707219e7a390fb0a99b6ec9262",
76             urls = [
77                 "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.0/bazel-skylib-1.7.0.tar.gz",
78                 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.0/bazel-skylib-1.7.0.tar.gz",
79             ],
80         )
82     if not native.existing_rule("com_google_absl"):
83         _github_archive(
84             name = "com_google_absl",
85             repo = "https://github.com/abseil/abseil-cpp",
86             commit = "4447c7562e3bc702ade25105912dce503f0c4010",  # Abseil LTS 20240722.0
87             sha256 = "d8342ad77aa9e16103c486b615460c24a695a1f04cdb760eb02fef780df99759",
88         )
90     if not native.existing_rule("zlib"):
91         http_archive(
92             name = "zlib",
93             build_file = Label("//third_party:zlib.BUILD"),
94             sha256 = "38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32",
95             strip_prefix = "zlib-1.3.1",
96             urls = [
97                 "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.xz",
98                 "https://zlib.net/zlib-1.3.1.tar.xz",
99             ],
100         )
102     if not native.existing_rule("jsoncpp"):
103         _github_archive(
104             name = "jsoncpp",
105             repo = "https://github.com/open-source-parsers/jsoncpp",
106             commit = "89e2973c754a9c02a49974d839779b151e95afd6",  # 1.9.6
107             sha256 = "02f0804596c1e18c064d890ac9497fa17d585e822fcacf07ff8a8aa0b344a7bd",
108             build_file = Label("//third_party:jsoncpp.BUILD"),
109         )
111     if not native.existing_rule("rules_cc"):
112         http_archive(
113             name = "rules_cc",
114             urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"],
115             sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
116             strip_prefix = "rules_cc-0.0.16",
117         )
119     if not native.existing_rule("rules_java"):
120         http_archive(
121             name = "rules_java",
122             urls = [
123                 "https://github.com/bazelbuild/rules_java/releases/download/8.6.1/rules_java-8.6.1.tar.gz",
124             ],
125             sha256 = "c5bc17e17bb62290b1fd8fdd847a2396d3459f337a7e07da7769b869b488ec26",
126         )
128     if not native.existing_rule("rules_shell"):
129         http_archive(
130             name = "rules_shell",
131             sha256 = "410e8ff32e018b9efd2743507e7595c26e2628567c42224411ff533b57d27c28",
132             strip_prefix = "rules_shell-0.2.0",
133             url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.2.0/rules_shell-v0.2.0.tar.gz",
134         )
136     if not native.existing_rule("proto_bazel_features"):
137         proto_bazel_features(name = "proto_bazel_features")
139     if not native.existing_rule("rules_python"):
140         http_archive(
141             name = "rules_python",
142             sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
143             strip_prefix = "rules_python-1.0.0",
144             url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
145         )
147     if not native.existing_rule("system_python"):
148         system_python(
149             name = "system_python",
150             minimum_python_version = "3.9",
151         )
153     if not native.existing_rule("rules_jvm_external"):
154         http_archive(
155             name = "rules_jvm_external",
156             strip_prefix = "rules_jvm_external-6.3",
157             sha256 = "c18a69d784bcd851be95897ca0eca0b57dc86bb02e62402f15736df44160eb02",
158             url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/6.3/rules_jvm_external-6.3.tar.gz",
159         )
161     if not native.existing_rule("rules_pkg"):
162         http_archive(
163             name = "rules_pkg",
164             urls = [
165                 "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/1.0.1/rules_pkg-1.0.1.tar.gz",
166                 "https://github.com/bazelbuild/rules_pkg/releases/download/1.0.1/rules_pkg-1.0.1.tar.gz",
167             ],
168             sha256 = "d20c951960ed77cb7b341c2a59488534e494d5ad1d30c4818c736d57772a9fef",
169         )
171     if not native.existing_rule("build_bazel_rules_apple"):
172         http_archive(
173             name = "build_bazel_rules_apple",
174             sha256 = "b892911288715b354e05b9a6fe9009635f7155991f24f27e779fe80d435c92bc",
175             url = "https://github.com/bazelbuild/rules_apple/releases/download/3.13.0/rules_apple.3.13.0.tar.gz",
176         )
178     if not native.existing_rule("build_bazel_apple_support"):
179         http_archive(
180             name = "build_bazel_apple_support",
181             sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80",
182             url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz",
183         )
185     if not native.existing_rule("rules_kotlin"):
186         http_archive(
187             name = "rules_kotlin",
188             sha256 = "3b772976fec7bdcda1d84b9d39b176589424c047eb2175bed09aac630e50af43",
189             url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.9.6/rules_kotlin-v1.9.6.tar.gz",
190         )
192     if not native.existing_rule("rules_license"):
193         http_archive(
194             name = "rules_license",
195             urls = [
196                 "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
197                 "https://github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz",
198             ],
199             sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38",
200         )
202     # Python Downloads
203     python_source_archive(
204         name = "python-3.9.0",
205         sha256 = "df796b2dc8ef085edae2597a41c1c0a63625ebd92487adaef2fed22b567873e8",
206     )
207     python_nuget_package(
208         name = "nuget_python_i686_3.9.0",
209         sha256 = "229abecbe49dc08fe5709e0b31e70edfb3b88f23335ebfc2904c44f940fd59b6",
210     )
211     python_nuget_package(
212         name = "nuget_python_x86-64_3.9.0",
213         sha256 = "6af58a733e7dfbfcdd50d55788134393d6ffe7ab8270effbf724bdb786558832",
214     )
215     python_nuget_package(
216         name = "nuget_python_i686_3.10.0",
217         sha256 = "e115e102eb90ce160ab0ef7506b750a8d7ecc385bde0a496f02a54337a8bc333",
218     )
219     python_nuget_package(
220         name = "nuget_python_x86-64_3.10.0",
221         sha256 = "4474c83c25625d93e772e926f95f4cd398a0abbb52793625fa30f39af3d2cc00",
222     )
223     native.register_toolchains("//bazel/private/toolchains:all")