1# Copyright 2021 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# This file uses repository rules to fetch external dependencies. 16# 17# We require that all uses of repository rules are effectively deterministic - 18# they may fail, but otherwise must always produce exactly the same output for 19# given parameters. For the http_archive rule, this means that you must specify 20# a sha256 parameter; consequently, make sure to use stable URLs, rather than 21# e.g. one that names a git branch. 22# 23# This is so that all(*) inputs to the build are fully determined (i.e. a 24# change to build inputs requires a change to our sources), which avoids 25# confusing outcomes from caching. If it is ever productive to clear your Bazel 26# cache, that's a bug. 27# 28# (*) A Bazel build depends on local compiler toolchains (and Bazel itself), so 29# it can be useful to pick a particular container image too (like some version 30# of http://l.gcr.io/bazel). 31# 32# The repository namespace 33# ------------------------ 34# 35# Bazel's handling of @repository_names// is very broken. There is a single, 36# global namespace for repositories. Conflicts are silently ignored. This is 37# problematic for common dependencies. As much as possible, we use TensorFlow's 38# dependencies. Things become especially difficult if we try to use our own 39# version of grpc or protobuf. Current overrides: 40# 41# - @com_github_gflags_gflags: tf uses 2.2.1 and we need 2.2.2 apparently. 42# - @com_google_googletest: Need to patch in support for absl flags 43 44workspace(name = "com_google_fcp") 45 46load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 47 48# Needed for user-defined configs 49http_archive( 50 name = "bazel_skylib", 51 sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", 52 urls = [ 53 "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", 54 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", 55 ], 56) 57 58load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") 59 60bazel_skylib_workspace() 61 62# GoogleTest/GoogleMock framework. Used by most unit-tests. 63http_archive( 64 name = "com_google_googletest", 65 patches = ["//fcp/patches:googletest.patch"], 66 sha256 = "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2", 67 strip_prefix = "googletest-release-1.12.1", 68 urls = ["https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz"], 69) 70 71http_archive( 72 name = "com_github_gflags_gflags", 73 sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf", 74 strip_prefix = "gflags-2.2.2", 75 urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"], 76) 77 78http_archive( 79 name = "com_github_google_glog", 80 sha256 = "21bc744fb7f2fa701ee8db339ded7dce4f975d0d55837a97be7d46e8382dea5a", 81 strip_prefix = "glog-0.5.0", 82 urls = ["https://github.com/google/glog/archive/v0.5.0.zip"], 83) 84 85http_archive( 86 name = "com_github_grpc_grpc", 87 sha256 = "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a", 88 strip_prefix = "grpc-1.50.0", 89 urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.50.0.tar.gz"], 90) 91 92# TensorFlow 2.11.0 pins an old version of upb that's compatible with their old 93# version of gRPC, but not with the newer version we use. Pin the version that 94# would be added by gRPC 1.50.0. 95http_archive( 96 name = "upb", 97 sha256 = "017a7e8e4e842d01dba5dc8aa316323eee080cd1b75986a7d1f94d87220e6502", 98 strip_prefix = "upb-e4635f223e7d36dfbea3b722a4ca4807a7e882e2", 99 urls = [ 100 "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz", 101 "https://github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz", 102 ], 103) 104 105# The version provided by TensorFlow 2.11 doesn't support equality checks for 106# absl::Status. 107http_archive( 108 name = "pybind11_abseil", 109 sha256 = "6481888831cd548858c09371ea892329b36c8d4d961f559876c64e009d0bc630", 110 strip_prefix = "pybind11_abseil-3922b3861a2b27d4111e3ac971e6697ea030a36e", 111 url = "https://github.com/pybind/pybind11_abseil/archive/3922b3861a2b27d4111e3ac971e6697ea030a36e.tar.gz", 112) 113 114http_archive( 115 name = "pybind11_protobuf", 116 sha256 = "fe2b8bf12a65997b853709a5e719f7561b2e86a4cdbb9d8b051e654dd0fd8d11", 117 strip_prefix = "pybind11_protobuf-a50899c2eb604fc5f25deeb8901eff6231b8b3c0", 118 url = "https://github.com/pybind/pybind11_protobuf/archive/a50899c2eb604fc5f25deeb8901eff6231b8b3c0.tar.gz", 119) 120 121# Define the @io_grpc_grpc_java repository, which is used by the 122# @com_google_googleapis repository to define the Java protobuf targets such as 123# @com_google_googleapis//google/rpc:rpc_java_proto). The pattern we use here is 124# the same as @com_google_googleapis' WORKSPACE file uses. 125# 126# Note that the @com_google_googleapis repository is actually defined 127# transitively by the @org_tensorflow workspace rules. 128http_archive( 129 name = "com_google_api_gax_java", 130 sha256 = "7c172c20dc52c09f42b3077a5195dc5fbcb30e023831918593d1b81a1aea650e", 131 strip_prefix = "gax-java-2.20.0", 132 urls = ["https://github.com/googleapis/gax-java/archive/v2.20.0.zip"], 133) 134 135load("@com_google_api_gax_java//:repository_rules.bzl", "com_google_api_gax_java_properties") 136 137com_google_api_gax_java_properties( 138 name = "com_google_api_gax_java_properties", 139 file = "@com_google_api_gax_java//:dependencies.properties", 140) 141 142load("@com_google_api_gax_java//:repositories.bzl", "com_google_api_gax_java_repositories") 143 144com_google_api_gax_java_repositories() 145 146# Tensorflow v2.12.0 147http_archive( 148 name = "org_tensorflow", 149 patch_tool = "patch", 150 patches = [ 151 # This patch enables googleapi Java and Python proto rules such as 152 # @com_google_googleapis//google/rpc:rpc_java_proto. 153 "//fcp/patches:tensorflow_googleapis_proto_rules.patch", 154 # This patch works around failures in GitHub infrastructure to 155 # download versions of LLVM pointed to by non-HEAD TensorFlow. 156 # TODO(team): Remove this patch when resolved. 157 "//fcp/patches:tensorflow_llvm_url.patch", 158 # TensorFlow's custom pybind11 BUILD file is missing the osx config 159 # setting expected by pybind11_bazel. 160 "//fcp/patches:tensorflow_pybind11_osx.patch", 161 # This patch removes tf_custom_op_py_library's dependency on the Bazel 162 # version of TensorFlow since for all of our Python code, we rely on a 163 # system-provided TensorFlow. 164 "//fcp/patches:tensorflow_tf_custom_op_py_library.patch", 165 # gRPC v1.48.0-pre1 and later include zconf.h in addition to zlib.h; 166 # TensorFlow's build rule for zlib only exports the latter. 167 "//fcp/patches:tensorflow_zlib.patch", 168 ], 169 sha256 = "c030cb1905bff1d2446615992aad8d8d85cbe90c4fb625cee458c63bf466bc8e", 170 strip_prefix = "tensorflow-2.12.0", 171 urls = [ 172 "https://github.com/tensorflow/tensorflow/archive/v2.12.0.tar.gz", 173 ], 174) 175 176# The following is copied from TensorFlow's own WORKSPACE, see 177# https://github.com/tensorflow/tensorflow/blob/v2.8.0/WORKSPACE#L9 178 179load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3") 180 181tf_workspace3() 182 183load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2") 184 185tf_workspace2() 186 187load("@org_tensorflow//tensorflow:workspace1.bzl", "tf_workspace1") 188 189tf_workspace1() 190 191load("@org_tensorflow//tensorflow:workspace0.bzl", "tf_workspace0") 192 193tf_workspace0() 194 195load("//fcp/tensorflow/system_provided_tf:system_provided_tf.bzl", "system_provided_tf") 196 197system_provided_tf( 198 name = "system_provided_tf", 199) 200 201http_archive( 202 name = "com_google_benchmark", 203 sha256 = "23082937d1663a53b90cb5b61df4bcc312f6dee7018da78ba00dd6bd669dfef2", 204 strip_prefix = "benchmark-1.5.1", 205 urls = [ 206 "https://github.com/google/benchmark/archive/v1.5.1.tar.gz", 207 ], 208) 209 210# Cpp ProtoDataStore 211http_archive( 212 name = "protodatastore_cpp", 213 sha256 = "d2627231fce0c9944100812b42d33203f7e03e78215d10123e78041b491005c3", 214 strip_prefix = "protodatastore-cpp-0cd8b124bc65bcac105bce4a706923218ae5d625", 215 url = "https://github.com/google/protodatastore-cpp/archive/0cd8b124bc65bcac105bce4a706923218ae5d625.zip", 216) 217 218# libcurl is used in the http client. 219http_archive( 220 name = "libcurl", 221 build_file = "//third_party:curl.BUILD.bzl", 222 sha256 = "e9d74b8586e0d2e6b45dc948bbe77525a1fa7f7c004ad5192f12e72c365e376e", 223 strip_prefix = "curl-curl-7_84_0", 224 url = "https://github.com/curl/curl/archive/refs/tags/curl-7_84_0.zip", 225) 226 227# We use only the http test server. 228http_archive( 229 name = "tensorflow_serving", 230 patch_tool = "patch", 231 patches = [ 232 "//fcp/patches:tensorflow_serving.patch", 233 ], 234 sha256 = "6b428100be7ec4bb34fc7910b7f549b6556854016a3c4cbda5613b5c114797b3", 235 strip_prefix = "serving-2.9.0", 236 url = "https://github.com/tensorflow/serving/archive/refs/tags/2.9.0.zip", 237) 238 239load("@tensorflow_serving//tensorflow_serving:workspace.bzl", "tf_serving_workspace") 240 241tf_serving_workspace() 242 243# Java Maven-based repositories. 244http_archive( 245 name = "rules_jvm_external", 246 sha256 = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca", 247 strip_prefix = "rules_jvm_external-4.2", 248 url = "https://github.com/bazelbuild/rules_jvm_external/archive/4.2.zip", 249) 250 251load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") 252 253rules_jvm_external_deps() 254 255load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") 256 257rules_jvm_external_setup() 258 259load("@rules_jvm_external//:defs.bzl", "maven_install") 260 261maven_install( 262 name = "fcp_maven", 263 artifacts = [ 264 "com.google.code.findbugs:jsr305:3.0.2", 265 "com.google.errorprone:error_prone_annotations:2.11.0", 266 "com.google.guava:guava:31.0.1-jre", 267 "com.google.truth:truth:1.1.3", 268 "junit:junit:4.13", 269 "org.mockito:mockito-core:4.3.1", 270 ], 271 repositories = [ 272 "https://maven.google.com", 273 "https://repo1.maven.org/maven2", 274 ], 275) 276 277# The version of googleapis imported by TensorFlow doesn't provide 278# `py_proto_library` targets for //google/longrunning. 279http_archive( 280 name = "googleapis_for_longrunning", 281 patches = [ 282 "//fcp/patches:googleapis_longrunning.patch", 283 ], 284 sha256 = "c1db0b022cdfc5b5ce5f05b0f00568e2d927c9890429ec9c35bda12f52d93065", 285 strip_prefix = "googleapis-2d8030c4102f97bc6be4ddab74c7cbfe88d8c016", 286 url = "https://github.com/googleapis/googleapis/archive/2d8030c4102f97bc6be4ddab74c7cbfe88d8c016.tar.gz", 287) 288