• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 The TensorFlow Authors. All rights reserved.
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"""
16Utilities for configuring googleapis in workspace external dependency.
17"""
18
19load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
20
21def config_googleapis():
22    """Configures external dependency googleapis to use Google's C++ gRPC APIs
23
24    To avoid ODR violation, the cc proto libraries (*.pb.cc) must be
25    statically linked to libtensorflow_framework.so, whereas cc grpc libraries
26    (*.grpc.pb.cc) must be statically linked to _pywrap_tensorflow.so.
27
28    To achieve this, Bazel rules are overridden to
29      (1) generate headers-only proto library, and
30      (2) build grpc library depending on the cc headers instead of the cc proto
31          library.
32    """
33    switched_rules_by_language(
34        name = "com_google_googleapis_imports",
35        cc = True,
36        grpc = True,
37        rules_override = {
38            "cc_proto_library": [
39                "@org_tensorflow//third_party/googleapis:build_rules.bzl",
40                "",
41            ],
42            "cc_grpc_library": [
43                "@org_tensorflow//third_party/googleapis:build_rules.bzl",
44                "",
45            ],
46        },
47    )
48