Merge pull request #19965 from veblush/strict-build

Add check_attrs & clean-up build.yaml
pull/19946/head
Esun Kim 6 years ago committed by GitHub
commit b1d4583a51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      CMakeLists.txt
  2. 2435
      build.yaml
  3. 2
      src/benchmark/gen_build_yaml.py
  4. 6
      src/boringssl/gen_build_yaml.py
  5. 2
      src/c-ares/gen_build_yaml.py
  6. 2
      src/objective-c/tests/run_one_test_bazel.sh
  7. 2
      src/zlib/gen_build_yaml.py
  8. 2
      test/core/bad_client/gen_build_yaml.py
  9. 126
      tools/buildgen/plugins/check_attrs.py

@ -17923,7 +17923,6 @@ target_include_directories(bad_streaming_id_bad_client_test
)
target_link_libraries(bad_streaming_id_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -17966,7 +17965,6 @@ target_include_directories(badreq_bad_client_test
)
target_link_libraries(badreq_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18009,7 +18007,6 @@ target_include_directories(connection_prefix_bad_client_test
)
target_link_libraries(connection_prefix_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18052,7 +18049,6 @@ target_include_directories(duplicate_header_bad_client_test
)
target_link_libraries(duplicate_header_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18095,7 +18091,6 @@ target_include_directories(head_of_line_blocking_bad_client_test
)
target_link_libraries(head_of_line_blocking_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18138,7 +18133,6 @@ target_include_directories(headers_bad_client_test
)
target_link_libraries(headers_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18181,7 +18175,6 @@ target_include_directories(initial_settings_frame_bad_client_test
)
target_link_libraries(initial_settings_frame_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18224,7 +18217,6 @@ target_include_directories(large_metadata_bad_client_test
)
target_link_libraries(large_metadata_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18267,7 +18259,6 @@ target_include_directories(out_of_bounds_bad_client_test
)
target_link_libraries(out_of_bounds_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18310,7 +18301,6 @@ target_include_directories(server_registered_method_bad_client_test
)
target_link_libraries(server_registered_method_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18353,7 +18343,6 @@ target_include_directories(simple_request_bad_client_test
)
target_link_libraries(simple_request_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18396,7 +18385,6 @@ target_include_directories(unknown_frame_bad_client_test
)
target_link_libraries(unknown_frame_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test
@ -18439,7 +18427,6 @@ target_include_directories(window_overflow_bad_client_test
)
target_link_libraries(window_overflow_bad_client_test
${_gRPC_SSL_LIBRARIES}
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
bad_client_test

File diff suppressed because it is too large Load Diff

@ -27,7 +27,7 @@ out['libs'] = [{
'name': 'benchmark',
'build': 'private',
'language': 'c++',
'secure': 'no',
'secure': False,
'defaults': 'benchmark',
'src': sorted(glob.glob('third_party/benchmark/src/*.cc')),
'headers': sorted(

@ -61,7 +61,7 @@ class Grpc(object):
'name': 'boringssl',
'build': 'private',
'language': 'c',
'secure': 'no',
'secure': False,
'src': sorted(
map_dir(f)
for f in files['ssl'] + files['crypto']
@ -79,7 +79,7 @@ class Grpc(object):
'name': 'boringssl_test_util',
'build': 'private',
'language': 'c++',
'secure': 'no',
'secure': False,
'boringssl': True,
'defaults': 'boringssl',
'src': [
@ -93,7 +93,7 @@ class Grpc(object):
'name': 'boringssl_%s' % test,
'build': 'test',
'run': False,
'secure': 'no',
'secure': False,
'language': 'c++',
'src': sorted(map_dir(f) for f in files[test]),
'vs_proj_dir': 'test/boringssl',

@ -53,7 +53,7 @@ try:
'defaults': 'ares',
'build': 'private',
'language': 'c',
'secure': 'no',
'secure': False,
'src': [
"third_party/cares/cares/ares__close_sockets.c",
"third_party/cares/cares/ares__get_hostent.c",

@ -48,4 +48,4 @@ $INTEROP --port=$TLS_PORT --max_send_message_size=8388608 --use_tls &
trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT
../../../tools/bazel run $SCHEME
../../../tools/bazel run $SCHEME

@ -42,7 +42,7 @@ try:
'defaults': 'zlib',
'build': 'private',
'language': 'c',
'secure': 'no',
'secure': False,
'src': sorted(cmvar('ZLIB_SRCS')),
'headers': sorted(cmvar('ZLIB_PUBLIC_HDRS') + cmvar('ZLIB_PRIVATE_HDRS')),
}]

@ -68,7 +68,7 @@ def main():
'cpu_cost': BAD_CLIENT_TESTS[t].cpu_cost,
'build': 'test',
'language': 'c++',
'secure': 'no',
'secure': False,
'src': ['test/core/bad_client/tests/%s.cc' % t],
'vs_proj_dir': 'test',
'exclude_iomgrs': ['uv'],

@ -0,0 +1,126 @@
# Copyright 2019 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.
"""Buildgen attribute validation plugin."""
def anything():
return lambda v: None
def one_of(values):
return lambda v: ('{0} is not in [{1}]'.format(v, values) if v not in values else None)
def subset_of(values):
return lambda v: ('{0} is not subset of [{1}]'.format(v, values)
if not all(e in values for e in v) else None)
VALID_ATTRIBUTE_KEYS_MAP = {
'filegroup': {
'deps': anything(),
'headers': anything(),
'plugin': anything(),
'public_headers': anything(),
'src': anything(),
'uses': anything(),
},
'lib': {
'baselib': anything(),
'boringssl': one_of((True,)),
'build_system': anything(),
'build': anything(),
'defaults': anything(),
'deps_linkage': one_of(('static',)),
'deps': anything(),
'dll': one_of((True, 'only')),
'filegroups': anything(),
'generate_plugin_registry': anything(),
'headers': anything(),
'language': one_of(('c', 'c++', 'csharp')),
'LDFLAGS': anything(),
'platforms': subset_of(('linux', 'mac', 'posix', 'windows')),
'public_headers': anything(),
'secure': one_of(('check', True, False)),
'src': anything(),
'vs_proj_dir': anything(),
'zlib': one_of((True,)),
},
'target': {
'args': anything(),
'benchmark': anything(),
'boringssl': one_of((True,)),
'build': anything(),
'ci_platforms': anything(),
'corpus_dirs': anything(),
'cpu_cost': anything(),
'defaults': anything(),
'deps': anything(),
'dict': anything(),
'exclude_configs': anything(),
'exclude_iomgrs': anything(),
'excluded_poll_engines': anything(),
'filegroups': anything(),
'flaky': one_of((True, False)),
'gtest': one_of((True, False)),
'headers': anything(),
'language': one_of(('c', 'c89', 'c++', 'csharp')),
'maxlen': anything(),
'platforms': subset_of(('linux', 'mac', 'posix', 'windows')),
'run': one_of((True, False)),
'secure': one_of(('check', True, False)),
'src': anything(),
'timeout_seconds': anything(),
'uses_polling': anything(),
'vs_proj_dir': anything(),
'zlib': one_of((True,)),
},
}
def check_attributes(entity, kind, errors):
attributes = VALID_ATTRIBUTE_KEYS_MAP[kind]
name = entity.get('name', anything())
for key, value in entity.items():
if key == 'name':
continue
validator = attributes.get(key)
if validator:
error = validator(value)
if error:
errors.append(
"{0}({1}) has an invalid value for '{2}': {3}".format(
name, kind, key, error))
else:
errors.append("{0}({1}) has an invalid attribute '{2}'".format(
name, kind, key))
def mako_plugin(dictionary):
"""The exported plugin code for check_attr.
This validates that filegroups, libs, and target can have only valid
attributes. This is mainly for preventing build.yaml from having
unnecessary and misleading attributes accidently.
"""
errors = []
for filegroup in dictionary.get('filegroups', {}):
check_attributes(filegroup, 'filegroup', errors)
for lib in dictionary.get('libs', {}):
check_attributes(lib, 'lib', errors)
for target in dictionary.get('targets', {}):
check_attributes(target, 'target', errors)
if errors:
raise Exception('\n'.join(errors))
Loading…
Cancel
Save