From 3c42452e7703ecd3b4946cb5e2e54544b2183561 Mon Sep 17 00:00:00 2001 From: jian Date: Thu, 26 Dec 2024 13:24:28 +0800 Subject: [PATCH] support enable warning when compiling pb.cc (#1050) Co-authored-by: jefferydeng --- doc/en/config.md | 1 + doc/zh_CN/config.md | 4 ++++ src/blade/config.py | 1 + src/blade/proto_library_target.py | 5 +++-- vim/syntax/blade_config.vim | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/en/config.md b/doc/en/config.md index 4ec2fb28..e443cbb3 100644 --- a/doc/en/config.md +++ b/doc/en/config.md @@ -394,6 +394,7 @@ proto_library_config(     protoc='protoc', #protoc compiler path     protobuf_libs='//thirdparty/protobuf:protobuf', #protobuf library path, Blade deps format     protobuf_path='thirdparty', # import proto search path, relative to BLADE_ROOT + protobuf_cc_warning='', # enable warning(disable -w) or not when compiling pb.cc, yes or no     protobuf_include_path = 'thirdparty', # extra -I path when compiling pb.cc ) ``` diff --git a/doc/zh_CN/config.md b/doc/zh_CN/config.md index 3b8d6995..2eab0520 100644 --- a/doc/zh_CN/config.md +++ b/doc/zh_CN/config.md @@ -378,6 +378,10 @@ Java 构建相关的配置: import 时的 proto 搜索路径,相对于 BLADE_ROOT。 +- `protobuf_cc_warning`: string = '' + + 编译pb.cc 时是否开启warnings, yes或者no + - `protobuf_include_path` : string = 编译 pb.cc 时额外的 -I 路径。 diff --git a/src/blade/config.py b/src/blade/config.py index 41813a65..d1f62f15 100644 --- a/src/blade/config.py +++ b/src/blade/config.py @@ -230,6 +230,7 @@ def __init__(self): 'protobuf_libs': [], 'protobuf_path': '', 'protobuf_incs': [], + 'protobuf_cc_warning': '', 'protobuf_java_incs': [], 'protobuf_php_path': '', 'protoc_php_plugin': '', diff --git a/src/blade/proto_library_target.py b/src/blade/proto_library_target.py index feca800a..a673558b 100644 --- a/src/blade/proto_library_target.py +++ b/src/blade/proto_library_target.py @@ -100,6 +100,8 @@ def __init__(self, """ # pylint: disable=too-many-locals srcs = var_to_list(srcs) + proto_config = config.get_section('proto_library_config') + super(ProtoLibrary, self).__init__( name=name, type='proto_library', @@ -108,7 +110,7 @@ def __init__(self, deps=deps, visibility=visibility, tags=tags, - warning='', + warning=proto_config['protobuf_cc_warning'], defs=[], incs=[], export_incs=[], @@ -123,7 +125,6 @@ def __init__(self, self.attr['public_protos'] = [self._source_file_path(s) for s in srcs] self._add_tags('lang:proto', 'type:library') - proto_config = config.get_section('proto_library_config') protobuf_libs = var_to_list(proto_config['protobuf_libs']) protobuf_java_libs = var_to_list(proto_config['protobuf_java_libs']) protobuf_python_libs = var_to_list(proto_config['protobuf_python_libs']) diff --git a/vim/syntax/blade_config.vim b/vim/syntax/blade_config.vim index ab305092..5c85b152 100644 --- a/vim/syntax/blade_config.vim +++ b/vim/syntax/blade_config.vim @@ -139,6 +139,7 @@ syn keyword bladeArg fbthrift_incs syn keyword bladeTarget proto_library_config syn keyword bladeArg protobuf_go_path syn keyword bladeArg protobuf_incs +syn keyword bladeArg protobuf_cc_warning syn keyword bladeArg protobuf_java_incs syn keyword bladeArg protobuf_java_libs syn keyword bladeArg protobuf_libs