From 5c4951b7444f74d5cb4be5c5c015270bebddf44d Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 16 Sep 2022 16:47:31 -0700 Subject: [PATCH] Added version macros --- BUILD | 1 + CMakeLists.txt | 2 ++ build_autogenerated.yaml | 2 ++ gRPC-C++.podspec | 1 + include/grpcpp/grpcpp.h | 1 + include/grpcpp/version_info.h | 27 ++++++++++++++++ src/cpp/common/version_cc.cc | 5 +-- .../include/grpcpp/version_info.h.template | 29 +++++++++++++++++ .../src/cpp/common/version_cc.cc.template | 31 ------------------- tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + 11 files changed, 66 insertions(+), 35 deletions(-) create mode 100644 include/grpcpp/version_info.h create mode 100644 templates/include/grpcpp/version_info.h.template delete mode 100644 templates/src/cpp/common/version_cc.cc.template diff --git a/BUILD b/BUILD index 135a5c083c526..756eb1f3dd789 100644 --- a/BUILD +++ b/BUILD @@ -361,6 +361,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/server_builder.h", "include/grpcpp/server_context.h", "include/grpcpp/server_posix.h", + "include/grpcpp/version_info.h", "include/grpcpp/support/async_stream.h", "include/grpcpp/support/async_unary_call.h", "include/grpcpp/support/byte_buffer.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index d7ab59a3c9a67..aa766b0bd2d48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3470,6 +3470,7 @@ foreach(_hdr include/grpcpp/support/sync_stream.h include/grpcpp/support/time.h include/grpcpp/support/validate_service_config.h + include/grpcpp/version_info.h include/grpcpp/xds_server_builder.h ) string(REPLACE "include/" "" _path ${_hdr}) @@ -4139,6 +4140,7 @@ foreach(_hdr include/grpcpp/support/sync_stream.h include/grpcpp/support/time.h include/grpcpp/support/validate_service_config.h + include/grpcpp/version_info.h ) string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 38246159d31ed..a9a40392e4a1e 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -2855,6 +2855,7 @@ libs: - include/grpcpp/support/sync_stream.h - include/grpcpp/support/time.h - include/grpcpp/support/validate_service_config.h + - include/grpcpp/version_info.h - include/grpcpp/xds_server_builder.h headers: - src/core/ext/transport/binder/client/binder_connector.h @@ -3267,6 +3268,7 @@ libs: - include/grpcpp/support/sync_stream.h - include/grpcpp/support/time.h - include/grpcpp/support/validate_service_config.h + - include/grpcpp/version_info.h headers: - src/cpp/client/create_channel_internal.h - src/cpp/common/channel_filter.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 677b0d17901d8..3da47e864ccad 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -191,6 +191,7 @@ Pod::Spec.new do |s| 'include/grpcpp/support/sync_stream.h', 'include/grpcpp/support/time.h', 'include/grpcpp/support/validate_service_config.h', + 'include/grpcpp/version_info.h', 'include/grpcpp/xds_server_builder.h' end diff --git a/include/grpcpp/grpcpp.h b/include/grpcpp/grpcpp.h index 9d707e29d7e75..d692b7f0038da 100644 --- a/include/grpcpp/grpcpp.h +++ b/include/grpcpp/grpcpp.h @@ -58,6 +58,7 @@ #include #include #include +#include // IWYU pragma: end_exports namespace grpc { diff --git a/include/grpcpp/version_info.h b/include/grpcpp/version_info.h new file mode 100644 index 0000000000000..417a766f7aed1 --- /dev/null +++ b/include/grpcpp/version_info.h @@ -0,0 +1,27 @@ +// Copyright 2022 gRPC authors. +// +// 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. + +/* This file is autogenerated from: + templates/include/grpcpp/version_info.h.template */ + +#ifndef GRPCPP_VERSION_INFO_H +#define GRPCPP_VERSION_INFO_H + +#define GRPC_CPP_VERSION_MAJOR 1 +#define GRPC_CPP_VERSION_MINOR 51 +#define GRPC_CPP_VERSION_PATCH 0 +#define GRPC_CPP_VERSION_TAG "dev" +#define GRPC_CPP_VERSION_STRING "1.51.0-dev" + +#endif // GRPCPP_VERSION_INFO_H diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 4d7c8f024ebc9..79a60fcf066f5 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -16,14 +16,11 @@ * */ -/* This file is autogenerated from: - templates/src/cpp/common/version_cc.cc.template */ - #include #include #include namespace grpc { -std::string Version() { return "1.51.0-dev"; } +std::string Version() { return GRPC_CPP_VERSION_STRING; } } // namespace grpc diff --git a/templates/include/grpcpp/version_info.h.template b/templates/include/grpcpp/version_info.h.template new file mode 100644 index 0000000000000..38415ce1fb8f0 --- /dev/null +++ b/templates/include/grpcpp/version_info.h.template @@ -0,0 +1,29 @@ +%YAML 1.2 +--- | + // Copyright 2022 gRPC authors. + // + // 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. + + /* This file is autogenerated from: + templates/include/grpcpp/version_info.h.template */ + + #ifndef GRPCPP_VERSION_INFO_H + #define GRPCPP_VERSION_INFO_H + + #define GRPC_CPP_VERSION_MAJOR ${settings.cpp_version.major} + #define GRPC_CPP_VERSION_MINOR ${settings.cpp_version.minor} + #define GRPC_CPP_VERSION_PATCH ${settings.cpp_version.patch} + #define GRPC_CPP_VERSION_TAG "${settings.cpp_version.tag or ''}" + #define GRPC_CPP_VERSION_STRING "${settings.cpp_version}" + + #endif // GRPCPP_VERSION_INFO_H diff --git a/templates/src/cpp/common/version_cc.cc.template b/templates/src/cpp/common/version_cc.cc.template deleted file mode 100644 index 5fcf6e44174a3..0000000000000 --- a/templates/src/cpp/common/version_cc.cc.template +++ /dev/null @@ -1,31 +0,0 @@ -%YAML 1.2 ---- | - /* - * - * Copyright 2016 gRPC authors. - * - * 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. - * - */ - - /* This file is autogenerated from: - templates/src/cpp/common/version_cc.cc.template */ - - #include - - #include - #include - - namespace grpc { - std::string Version() { return "${settings.cpp_version}"; } - } // namespace grpc diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index db825d9b997df..166a03b74ee45 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -1056,6 +1056,7 @@ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ +include/grpcpp/version_info.h \ include/grpcpp/xds_server_builder.h # This tag can be used to specify the character encoding of the source files diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index c14162ee081a6..dcf59ee6a4884 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1056,6 +1056,7 @@ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ include/grpcpp/support/validate_service_config.h \ +include/grpcpp/version_info.h \ include/grpcpp/xds_server_builder.h \ src/core/ext/filters/census/grpc_context.cc \ src/core/ext/filters/channel_idle/channel_idle_filter.cc \