From 2b6b0619a714b72918a8185d74eb0485c3babec5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 19 Jul 2021 14:46:30 -0700 Subject: [PATCH] Add a library that just contains port_platform.h (#26715) --- BUILD | 16 +++++++++++++++- src/core/lib/gprpp/match.h | 2 +- src/core/lib/gprpp/overload.h | 2 +- tools/run_tests/sanity/check_port_platform.py | 2 -- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index 02938a85465..fae71d54bf0 100644 --- a/BUILD +++ b/BUILD @@ -715,6 +715,16 @@ grpc_cc_library( visibility = ["@grpc:public"], ) +# A library that vends only port_platform, so that libraries that don't need +# anything else from gpr can still be portable! +grpc_cc_library( + name = "gpr_platform", + language = "c++", + public_hdrs = [ + "include/grpc/impl/codegen/port_platform.h", + ], +) + grpc_cc_library( name = "grpc_trace", srcs = ["src/core/lib/debug/trace.cc"], @@ -750,6 +760,7 @@ grpc_cc_library( name = "overload", language = "c++", public_hdrs = ["src/core/lib/gprpp/overload.h"], + deps = ["gpr_platform"], ) grpc_cc_library( @@ -759,7 +770,10 @@ grpc_cc_library( ], language = "c++", public_hdrs = ["src/core/lib/gprpp/match.h"], - deps = ["overload"], + deps = [ + "gpr_platform", + "overload", + ], ) grpc_cc_library( diff --git a/src/core/lib/gprpp/match.h b/src/core/lib/gprpp/match.h index e7790afb325..caec932cc84 100644 --- a/src/core/lib/gprpp/match.h +++ b/src/core/lib/gprpp/match.h @@ -15,7 +15,7 @@ #ifndef GRPC_CORE_LIB_GPRPP_MATCH_H #define GRPC_CORE_LIB_GPRPP_MATCH_H -// Portable code. port_platform.h is not required. +#include #include "absl/types/variant.h" #include "src/core/lib/gprpp/overload.h" diff --git a/src/core/lib/gprpp/overload.h b/src/core/lib/gprpp/overload.h index 544c2a00d76..d2f7be7d9bf 100644 --- a/src/core/lib/gprpp/overload.h +++ b/src/core/lib/gprpp/overload.h @@ -15,7 +15,7 @@ #ifndef GRPC_CORE_LIB_GPRPP_OVERLOAD_H #define GRPC_CORE_LIB_GPRPP_OVERLOAD_H -// Portable code. port_platform.h is not required. +#include #include diff --git a/tools/run_tests/sanity/check_port_platform.py b/tools/run_tests/sanity/check_port_platform.py index 341b3bdfc05..ba959111923 100755 --- a/tools/run_tests/sanity/check_port_platform.py +++ b/tools/run_tests/sanity/check_port_platform.py @@ -44,8 +44,6 @@ def check_port_platform_inclusion(directory_root): with open(path) as f: all_lines_in_file = f.readlines() for index, l in enumerate(all_lines_in_file): - if l == '// Portable code. port_platform.h is not required.\n': - break if '#include' in l: if l not in [ '#include \n',