diff --git a/BUILD b/BUILD index 834ce86580e46..658060958cfef 100644 --- a/BUILD +++ b/BUILD @@ -39,6 +39,11 @@ exports_files([ "etc/roots.pem", ]) +exports_files( + glob(["include/**"]), + visibility = ["//:__subpackages__"], +) + config_setting( name = "grpc_no_ares", values = {"define": "grpc_no_ares=true"}, @@ -7775,6 +7780,20 @@ grpc_cc_library( ], ) +# This is an EXPERIMENTAL target subject to change. +grpc_cc_library( + name = "grpcpp_gcp_observability", + hdrs = [ + "include/grpcpp/ext/gcp_observability.h", + ], + language = "c++", + tags = ["nofixdeps"], + visibility = ["@grpc:grpcpp_gcp_observability"], + deps = [ + "//src/cpp/ext/gcp:observability", + ], +) + grpc_cc_library( name = "json", srcs = [ diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 7f4bb3ac71ce3..08bcf7849ed6f 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -94,6 +94,7 @@ def _update_visibility(visibility): "endpoint_tests": PRIVATE, "grpclb": PRIVATE, "grpc_opencensus_plugin": PUBLIC, + "grpcpp_gcp_observability": PUBLIC, "grpc_resolver_fake": PRIVATE, "grpc++_test": PRIVATE, "http": PRIVATE, diff --git a/src/cpp/ext/gcp/observability.h b/include/grpcpp/ext/gcp_observability.h similarity index 67% rename from src/cpp/ext/gcp/observability.h rename to include/grpcpp/ext/gcp_observability.h index b562e1cabf5c0..942a56392b511 100644 --- a/src/cpp/ext/gcp/observability.h +++ b/include/grpcpp/ext/gcp_observability.h @@ -14,12 +14,8 @@ // limitations under the License. // -#ifndef GRPC_INTERNAL_CPP_EXT_GCP_OBSERVABILITY_GCP_OBSERVABILITY_H -#define GRPC_INTERNAL_CPP_EXT_GCP_OBSERVABILITY_GCP_OBSERVABILITY_H - -// TODO(yashykt): This file would have been in the top include/grpcpp directory -// instead of in src/, but I'm not yet sure about the naming, so keeping it here -// till we decide. +#ifndef GRPCPP_EXT_GCP_OBSERVABILITY_H +#define GRPCPP_EXT_GCP_OBSERVABILITY_H #include "absl/status/status.h" @@ -32,4 +28,4 @@ absl::Status GcpObservabilityInit(); } // namespace experimental } // namespace grpc -#endif // GRPC_INTERNAL_CPP_EXT_GCP_OBSERVABILITY_GCP_OBSERVABILITY_H +#endif // GRPCPP_EXT_GCP_OBSERVABILITY_H diff --git a/src/cpp/ext/gcp/BUILD b/src/cpp/ext/gcp/BUILD index be3f9d2885379..835b948275823 100644 --- a/src/cpp/ext/gcp/BUILD +++ b/src/cpp/ext/gcp/BUILD @@ -28,14 +28,13 @@ package( ], ) -# This is an EXPERIMENTAL target subject to change. grpc_cc_library( name = "observability", srcs = [ "observability.cc", ], hdrs = [ - "observability.h", + "//:include/grpcpp/ext/gcp_observability.h", ], external_deps = [ "absl/status", @@ -50,7 +49,7 @@ grpc_cc_library( ], language = "c++", tags = ["nofixdeps"], - visibility = ["//test:__subpackages__"], + visibility = ["//:__subpackages__"], deps = [ ":observability_config", "//:gpr", diff --git a/src/cpp/ext/gcp/observability.cc b/src/cpp/ext/gcp/observability.cc index 14f2d789e5546..6452338c463bc 100644 --- a/src/cpp/ext/gcp/observability.cc +++ b/src/cpp/ext/gcp/observability.cc @@ -16,14 +16,13 @@ #include -#include "src/cpp/ext/gcp/observability.h" - #include #include #include #include +#include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/types/optional.h" #include "google/devtools/cloudtrace/v2/tracing.grpc.pb.h" @@ -34,6 +33,7 @@ #include "opencensus/trace/sampler.h" #include "opencensus/trace/trace_config.h" +#include #include #include #include diff --git a/test/cpp/ext/gcp/BUILD b/test/cpp/ext/gcp/BUILD index 4b385889d9c42..31a85613926e5 100644 --- a/test/cpp/ext/gcp/BUILD +++ b/test/cpp/ext/gcp/BUILD @@ -28,7 +28,7 @@ grpc_cc_test( ], language = "C++", deps = [ - "//src/cpp/ext/gcp:observability", + "//:grpcpp_gcp_observability", "//test/cpp/util:test_util", ], ) diff --git a/test/cpp/ext/gcp/observability_test.cc b/test/cpp/ext/gcp/observability_test.cc index 95a028bf9b70a..757e38a8cf326 100644 --- a/test/cpp/ext/gcp/observability_test.cc +++ b/test/cpp/ext/gcp/observability_test.cc @@ -14,11 +14,11 @@ // limitations under the License. // -#include "src/cpp/ext/gcp/observability.h" - #include "gmock/gmock.h" #include "gtest/gtest.h" +#include + #include "src/core/lib/config/core_configuration.h" #include "test/core/util/test_config.h" diff --git a/tools/distrib/fix_build_deps.py b/tools/distrib/fix_build_deps.py index 1671c1a867961..d7ab1d2dc0777 100755 --- a/tools/distrib/fix_build_deps.py +++ b/tools/distrib/fix_build_deps.py @@ -296,15 +296,22 @@ def grpc_cc_library(name, proto_hdr = '%s%s' % ((parsing_path + '/' if parsing_path else ''), proto.replace('.proto', '.pb.h')) skip_headers[name].add(proto_hdr) + + # Convert the source or header target to a relative path. + def get_filename(name, parsing_path): + filename = '%s%s' % ( + (parsing_path + '/' if + (parsing_path and not name.startswith('//')) else ''), name) + filename = filename.replace('//:', '') + return filename + for hdr in hdrs + public_hdrs: - filename = '%s%s' % ((parsing_path + '/' if parsing_path else ''), hdr) - vendors[filename].append(name) + vendors[get_filename(hdr, parsing_path)].append(name) inc = set() original_deps[name] = frozenset(deps) original_external_deps[name] = frozenset(external_deps) for src in hdrs + public_hdrs + srcs: - filename = '%s%s' % ((parsing_path + '/' if parsing_path else ''), src) - for line in open(filename): + for line in open(get_filename(src, parsing_path)): m = re.search(r'^#include <(.*)>', line) if m: inc.add(m.group(1)) @@ -408,7 +415,7 @@ def score_best(proposed, existing): 'load': lambda filename, *args: None, 'licenses': lambda licenses: None, 'package': lambda **kwargs: None, - 'exports_files': lambda files: None, + 'exports_files': lambda files, visibility=None: None, 'config_setting': lambda **kwargs: None, 'selects': FakeSelects(), 'python_config_settings': lambda **kwargs: None, @@ -418,6 +425,7 @@ def score_best(proposed, existing): 'grpc_fuzzer': grpc_cc_library, 'grpc_proto_fuzzer': grpc_cc_library, 'select': lambda d: d["//conditions:default"], + 'glob': lambda files: None, 'grpc_end2end_tests': lambda: None, 'grpc_upb_proto_library': lambda name, **kwargs: None, 'grpc_upb_proto_reflection_library': lambda name, **kwargs: None, @@ -498,7 +506,10 @@ def best(self, scorer): choices = new_choices best = None - final_scorer = lambda x: (total_avoidness(x), scorer(x), total_score(x)) + + def final_scorer(x): + return (total_avoidness(x), scorer(x), total_score(x)) + for choice in choices: if best is None or final_scorer(choice) < final_scorer(best): best = choice