|
| 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 | + |
| 17 | +def google_cloud_cpp_deps(): |
| 18 | + """Loads dependencies need to compile the google-cloud-cpp library. |
| 19 | +
|
| 20 | + Application developers can call this function from their WORKSPACE file |
| 21 | + to obtain all the necessary dependencies for google-cloud-cpp, including |
| 22 | + gRPC and its dependencies. This function only loads dependencies that |
| 23 | + have not been previously loaded, allowing application developers to |
| 24 | + override the version of the dependencies they want to use. |
| 25 | + """ |
| 26 | + |
| 27 | + # Load a newer version of google test than what gRPC does. |
| 28 | + if "com_google_googletest" not in native.existing_rules(): |
| 29 | + native.new_http_archive( |
| 30 | + name = "com_google_googletest", |
| 31 | + build_file = "@com_github_googlecloudplatform_google_cloud_cpp//bazel:googletest.BUILD", |
| 32 | + strip_prefix = "googletest-4bd8c4638ada823a8da2569735cc0a9402fb8052", |
| 33 | + url = "https://github.com/google/googletest/archive/4bd8c4638ada823a8da2569735cc0a9402fb8052.tar.gz", |
| 34 | + sha256 = "9f842f79d92dfa694d9811918efb36a0bcd82d7b32f37a8f852dddde264c0f55", |
| 35 | + ) |
| 36 | + |
| 37 | + # Load the googleapis dependency. |
| 38 | + if "com_github_googleapis_googleapis" not in native.existing_rules(): |
| 39 | + native.new_http_archive( |
| 40 | + name = "com_github_googleapis_googleapis", |
| 41 | + url = "https://github.com/google/googleapis/archive/f81082ea1e2f85c43649bee26e0d9871d4b41cdb.zip", |
| 42 | + strip_prefix="googleapis-f81082ea1e2f85c43649bee26e0d9871d4b41cdb", |
| 43 | + sha256 = "824870d87a176f26bcef663e92051f532fac756d1a06b404055dc078425f4378", |
| 44 | + build_file = "@com_github_googlecloudplatform_google_cloud_cpp//bazel:googleapis.BUILD", |
| 45 | + workspace_file = "@com_github_googlecloudplatform_google_cloud_cpp//bazel:googleapis.WORKSPACE", |
| 46 | + ) |
| 47 | + |
| 48 | + # Load gRPC and its dependencies, using a similar pattern to this function. |
| 49 | + # This implictly loads "com_google_protobuf", which we use. |
| 50 | + if "com_github_grpc_grpc" not in native.existing_rules(): |
| 51 | + native.http_archive( |
| 52 | + name = "com_github_grpc_grpc", |
| 53 | + strip_prefix = "grpc-1.10.0", |
| 54 | + urls = [ |
| 55 | + "https://mirror.bazel.build/github.com/grpc/grpc/archive/v1.10.0.tar.gz", |
| 56 | + "https://github.com/grpc/grpc/archive/v1.10.0.tar.gz", |
| 57 | + ], |
| 58 | + sha256 = "39a73de6fa2a03bdb9c43c89a4283e09880833b3c1976ef3ce3edf45c8cacf72" |
| 59 | + ) |
| 60 | + |
| 61 | + # We use the cc_proto_library() rule from @com_google_protobuf, which |
| 62 | + # assumes that grpc_cpp_plugin and grpc_lib are in the //external: module |
| 63 | + native.bind( |
| 64 | + name = "grpc_cpp_plugin", |
| 65 | + actual = "@com_github_grpc_grpc//:grpc_cpp_plugin" |
| 66 | + ) |
| 67 | + |
| 68 | + native.bind( |
| 69 | + name = "grpc_lib", |
| 70 | + actual = "@com_github_grpc_grpc//:grpc++" |
| 71 | + ) |
0 commit comments