chore: import upstream snapshot with attribution
cffconvert / validate (push) Has been skipped
License Check / license-check (push) Failing after 2s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:14:16 +08:00
commit 8a852e4b4e
36502 changed files with 9277225 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
# Copyright 2020 The TensorFlow Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
licenses(["notice"])
cc_library(
name = "grpc_all_cc",
visibility = ["//tensorflow/core/platform/cloud:__pkg__"],
deps = [
"@com_google_googleapis//google/monitoring/v3:monitoring_cc_grpc",
],
)
cc_library(
name = "protos_all_cc",
visibility = ["//tensorflow/core/platform/cloud:__pkg__"],
deps = [
"@com_google_googleapis//google/monitoring/v3:monitoring_cc_proto_headers_only",
],
)
cc_library(
name = "protos_all_cc_impl",
visibility = ["//tensorflow/core/platform/cloud:__pkg__"],
deps = [
"@com_google_googleapis//google/monitoring/v3:monitoring_cc_proto",
],
)
+90
View File
@@ -0,0 +1,90 @@
# Copyright 2020 The TensorFlow Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Utilities for building grpc and proto libraries from googleapis.
"""
load("@com_github_grpc_grpc//bazel:generate_cc.bzl", "generate_cc")
load("@rules_cc//cc:defs.bzl", native_cc_proto_library = "cc_proto_library")
def _tf_cc_headers(ctx):
if len(ctx.attr.deps) != 1:
fail("deps must have exactly 1 photo_library")
return [
CcInfo(
compilation_context = ctx.attr.deps[0][CcInfo].compilation_context,
),
DefaultInfo(
files = ctx.attr.deps[0][CcInfo].compilation_context.headers,
),
]
tf_cc_headers = rule(
implementation = _tf_cc_headers,
attrs = {
"deps": attr.label_list(providers = [CcInfo]),
},
)
def cc_proto_library(name, deps):
"""Generates a cc library and a header only cc library from a proto library
Args:
name: the name of the cc_library
deps: a list that contains exactly one proto_library
"""
native_cc_proto_library(
name = name,
deps = deps,
visibility = ["//visibility:public"],
)
tf_cc_headers(
name = name + "_headers_only",
deps = [":" + name],
visibility = ["//visibility:public"],
)
def cc_grpc_library(name, srcs, deps, service_namespace = "grpc", **kwargs):
"""Generates a cc library with grpc implementation and cc proto headers
Args:
name: the name of the cc_grpc_library to be created
srcs: the proto_libraries used to generate the cc_grpc_library
deps: the dependencies used to link into this cc_grpc_library, defined by
cc_proto_library
**kwargs: other args not used, for compatibility only
"""
if len(srcs) != 1:
fail("srcs must have exactly 1 photo_library", "srcs")
codegen_grpc_target = "_" + name + "_grpc_codegen"
generate_cc(
name = codegen_grpc_target,
srcs = srcs,
flags = [
"services_namespace=" + service_namespace,
],
plugin = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin",
well_known_protos = True,
generate_mocks = True,
)
grpc_proto_dep = "@com_github_grpc_grpc//:grpc++_codegen_proto"
native.cc_library(
name = name,
srcs = [":" + codegen_grpc_target],
hdrs = [":" + codegen_grpc_target],
deps = [dep + "_headers_only" for dep in deps] + [grpc_proto_dep],
visibility = ["//visibility:public"],
)
+19
View File
@@ -0,0 +1,19 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
exports_files(["LICENSE"])
+47
View File
@@ -0,0 +1,47 @@
# Copyright 2020 The TensorFlow Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Utilities for configuring googleapis in workspace external dependency.
"""
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
def config_googleapis():
"""Configures external dependency googleapis to use Google's C++ gRPC APIs
To avoid ODR violation, the cc proto libraries (*.pb.cc) must be
statically linked to libtensorflow_framework.so, whereas cc grpc libraries
(*.grpc.pb.cc) must be statically linked to _pywrap_tensorflow.so.
To achieve this, Bazel rules are overridden to
(1) generate headers-only proto library, and
(2) build grpc library depending on the cc headers instead of the cc proto
library.
"""
switched_rules_by_language(
name = "com_google_googleapis_imports",
cc = True,
grpc = True,
rules_override = {
"cc_proto_library": [
"@org_tensorflow//third_party/googleapis:build_rules.bzl",
"",
],
"cc_grpc_library": [
"@org_tensorflow//third_party/googleapis:build_rules.bzl",
"",
],
},
)
+12
View File
@@ -0,0 +1,12 @@
"""Loads the googleapis library, used by TF."""
load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls")
def repo():
tf_http_archive(
name = "com_google_googleapis",
build_file = "//third_party/googleapis:googleapis.BUILD",
sha256 = "249d83abc5d50bf372c35c49d77f900bff022b2c21eb73aa8da1458b6ac401fc",
strip_prefix = "googleapis-6b3fdcea8bc5398be4e7e9930c693f0ea09316a0",
urls = tf_mirror_urls("https://github.com/googleapis/googleapis/archive/6b3fdcea8bc5398be4e7e9930c693f0ea09316a0.tar.gz"),
)