This is an automated email from the ASF dual-hosted git repository. alexey pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push: new 8732664a9 [thrift] Add support for extra Thrift options to THRIFT_GENERATE_CPP() 8732664a9 is described below commit 8732664a9354bab55c22f78e2747eb4a8dfd8258 Author: kedeng <kdeng...@gmail.com> AuthorDate: Mon Jun 23 15:27:53 2025 +0800 [thrift] Add support for extra Thrift options to THRIFT_GENERATE_CPP() The Thrift compiler's `-nowarn` flag suppresses warnings like: [WARNING:/data/code/kudu/src/kudu/hms/hive_metastore.thrift:2184] No field key specified for o2, resulting protocol may have conflicts or not be backwards compatible! However, using `-nowarn` globally for all Thrift invocations would also hide valuable warnings from unrelated files, which is discouraged by both practice and the Thrift CLI itself. This change introduces an `EXTRA_OPTIONS` argument to the THRIFT_GENERATE_CPP() CMake macro, allowing per-file customization of compiler flags. As a first use case, the `-nowarn` flag is applied only to `hive_metastore.thrift`, which is copied from the Hive project and cannot be modified for compatibility reasons. Change-Id: Ifdb8b650f9b8ed1cdea9dd0cf1a80ef264ccc7d7 Reviewed-on: http://gerrit.cloudera.org:8080/23063 Tested-by: Alexey Serbin <ale...@apache.org> Reviewed-by: Alexey Serbin <ale...@apache.org> --- cmake_modules/FindThrift.cmake | 9 ++++++++- src/kudu/hms/CMakeLists.txt | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmake_modules/FindThrift.cmake b/cmake_modules/FindThrift.cmake index 03ff9b3fd..65c931019 100644 --- a/cmake_modules/FindThrift.cmake +++ b/cmake_modules/FindThrift.cmake @@ -63,7 +63,7 @@ function(THRIFT_GENERATE_CPP SRCS HDRS TGTS) set(options FB303) set(one_value_args SOURCE_ROOT BINARY_ROOT) - set(multi_value_args EXTRA_THRIFT_PATHS THRIFT_FILES) + set(multi_value_args EXTRA_THRIFT_PATHS THRIFT_FILES EXTRA_OPTIONS) cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}") @@ -112,6 +112,12 @@ function(THRIFT_GENERATE_CPP SRCS HDRS TGTS) list(APPEND ${HDRS} fb303_types.h FacebookService.h) endif() + # The `EXTRA_OPTIONS` argument allows passing additional flags to the Thrift compiler + # for specific invocations. This is useful to suppress warnings only for selected files. + # + # For example, the `-nowarn` flag is used with `hive_metastore.thrift`, which is copied + # from the Hive project and cannot be modified. This avoids noisy warnings about missing + # field IDs without globally muting all warnings in unrelated Thrift files. add_custom_command( OUTPUT ${THRIFT_CC_OUT} ${THRIFT_H_OUT} DEPENDS ${ABS_FIL} @@ -123,6 +129,7 @@ function(THRIFT_GENERATE_CPP SRCS HDRS TGTS) -I ${ARG_SOURCE_ROOT} # Used to find built-in .thrift files (e.g. fb303.thrift) -I ${THIRDPARTY_INSTALL_CURRENT_DIR} + ${ARG_EXTRA_OPTIONS} ${EXTRA_THRIFT_PATH_ARGS} ${ABS_FIL} COMMENT "Running C++ thrift compiler on ${FIL}" VERBATIM ) diff --git a/src/kudu/hms/CMakeLists.txt b/src/kudu/hms/CMakeLists.txt index eb76c6849..839cace40 100644 --- a/src/kudu/hms/CMakeLists.txt +++ b/src/kudu/hms/CMakeLists.txt @@ -22,6 +22,7 @@ THRIFT_GENERATE_CPP( HMS_THRIFT_SRCS HMS_THRIFT_HDRS HMS_THRIFT_TGTS THRIFT_FILES hive_metastore.thrift + EXTRA_OPTIONS -nowarn FB303) add_library(hms_thrift ${HMS_THRIFT_SRCS})