1# Copyright 2018 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"""Load dependencies needed to compile and test the google-cloud-cpp library.""" 16 17load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") 18 19def google_cloud_cpp_deps(): 20 """Loads dependencies need to compile the google-cloud-cpp library. 21 22 Application developers can call this function from their WORKSPACE file 23 to obtain all the necessary dependencies for google-cloud-cpp, including 24 gRPC and its dependencies. This function only loads dependencies that 25 have not been previously loaded, allowing application developers to 26 override the version of the dependencies they want to use. 27 """ 28 29 # Load rules_cc, used by googletest 30 if "rules_cc" not in native.existing_rules(): 31 http_archive( 32 name = "rules_cc", 33 strip_prefix = "rules_cc-a508235df92e71d537fcbae0c7c952ea6957a912", 34 urls = [ 35 "https://github.com/bazelbuild/rules_cc/archive/a508235df92e71d537fcbae0c7c952ea6957a912.tar.gz", 36 ], 37 sha256 = "d21d38c4b8e81eed8fa95ede48dd69aba01a3b938be6ac03d2b9dc61886a7183", 38 ) 39 40 # Load Abseil 41 if "com_google_absl" not in native.existing_rules(): 42 http_archive( 43 name = "com_google_absl", 44 strip_prefix = "abseil-cpp-20200225.2", 45 urls = [ 46 "https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz", 47 ], 48 sha256 = "f41868f7a938605c92936230081175d1eae87f6ea2c248f41077c8f88316f111", 49 ) 50 51 # Load a version of googletest that we know works. 52 if "com_google_googletest" not in native.existing_rules(): 53 http_archive( 54 name = "com_google_googletest", 55 strip_prefix = "googletest-release-1.10.0", 56 urls = [ 57 "https://github.com/google/googletest/archive/release-1.10.0.tar.gz", 58 ], 59 sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb", 60 ) 61 62 # Load a version of benchmark that we know works. 63 if "com_google_benchmark" not in native.existing_rules(): 64 http_archive( 65 name = "com_google_benchmark", 66 strip_prefix = "benchmark-1.5.0", 67 urls = [ 68 "https://github.com/google/benchmark/archive/v1.5.0.tar.gz", 69 ], 70 sha256 = "3c6a165b6ecc948967a1ead710d4a181d7b0fbcaa183ef7ea84604994966221a", 71 ) 72 73 # Load the googleapis dependency. 74 if "com_google_googleapis" not in native.existing_rules(): 75 http_archive( 76 name = "com_google_googleapis", 77 urls = [ 78 "https://github.com/googleapis/googleapis/archive/370e9f9ac14dbc73f56e15257bccc06dfebd4196.tar.gz", 79 ], 80 strip_prefix = "googleapis-370e9f9ac14dbc73f56e15257bccc06dfebd4196", 81 sha256 = "71ebb74007fd32626896fa2056c31d436c5e96774ac160482b5f25df5a90c6b9", 82 build_file = "@com_github_googleapis_google_cloud_cpp//bazel:googleapis.BUILD", 83 ) 84 85 # Load protobuf. 86 if "com_google_protobuf" not in native.existing_rules(): 87 http_archive( 88 name = "com_google_protobuf", 89 strip_prefix = "protobuf-3.11.3", 90 urls = [ 91 "https://github.com/google/protobuf/archive/v3.11.3.tar.gz", 92 ], 93 sha256 = "cf754718b0aa945b00550ed7962ddc167167bd922b842199eeb6505e6f344852", 94 ) 95 96 # Load opencensus. 97 if "io_opencensus_cpp" not in native.existing_rules(): 98 http_archive( 99 name = "io_opencensus_cpp", 100 urls = [ 101 "https://github.com/census-instrumentation/opencensus-cpp/archive/c900c4d723ef596f357b0e695e68e2fa725eec90.tar.gz", 102 ], 103 strip_prefix = "opencensus-cpp-c900c4d723ef596f357b0e695e68e2fa725eec90", 104 sha256 = "040753b92d0ea57e2e9ffe7fc51f4c954cfb352204dc967c04ae6100842d6f45", 105 ) 106 107 # Load gRPC and its dependencies, using a similar pattern to this function. 108 if "com_github_grpc_grpc" not in native.existing_rules(): 109 http_archive( 110 name = "com_github_grpc_grpc", 111 strip_prefix = "grpc-1.29.1", 112 urls = [ 113 "https://github.com/grpc/grpc/archive/v1.29.1.tar.gz", 114 ], 115 sha256 = "0343e6dbde66e9a31c691f2f61e98d79f3584e03a11511fad3f10e3667832a45", 116 ) 117 118 # We use the cc_proto_library() rule from @com_google_protobuf, which 119 # assumes that grpc_cpp_plugin and grpc_lib are in the //external: module 120 native.bind( 121 name = "grpc_cpp_plugin", 122 actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin", 123 ) 124 125 native.bind( 126 name = "grpc_lib", 127 actual = "@com_github_grpc_grpc//:grpc++", 128 ) 129 130 # We need libcurl for the Google Cloud Storage client. 131 if "com_github_curl_curl" not in native.existing_rules(): 132 http_archive( 133 name = "com_github_curl_curl", 134 urls = [ 135 "https://curl.haxx.se/download/curl-7.69.1.tar.gz", 136 ], 137 strip_prefix = "curl-7.69.1", 138 sha256 = "01ae0c123dee45b01bbaef94c0bc00ed2aec89cb2ee0fd598e0d302a6b5e0a98", 139 build_file = "@com_github_googleapis_google_cloud_cpp//bazel:curl.BUILD", 140 ) 141 142 # We need the nlohmann_json library 143 if "com_github_nlohmann_json" not in native.existing_rules(): 144 http_archive( 145 name = "com_github_nlohmann_json", 146 urls = [ 147 "https://github.com/nlohmann/json/releases/download/v3.9.0/include.zip", 148 ], 149 sha256 = "5b9b819aed31626aefe2eace23498cafafc1691890556cd36d2a8002f6905009", 150 build_file = "@com_github_googleapis_google_cloud_cpp//bazel:nlohmann_json.BUILD", 151 ) 152 153 # Load google/crc32c, a library to efficiently compute CRC32C checksums. 154 if "com_github_google_crc32c" not in native.existing_rules(): 155 http_archive( 156 name = "com_github_google_crc32c", 157 strip_prefix = "crc32c-1.0.6", 158 urls = [ 159 "https://github.com/google/crc32c/archive/1.0.6.tar.gz", 160 ], 161 sha256 = "6b3b1d861bb8307658b2407bc7a4c59e566855ef5368a60b35c893551e4788e9", 162 build_file = "@com_github_googleapis_google_cloud_cpp//bazel:crc32c.BUILD", 163 ) 164