verify_duplicate_sources.py
Go to the documentation of this file.
1 # Copyright 2020 gRPC authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Buildgen duplicate source validation plugin."""
15 
16 
17 def mako_plugin(dictionary):
18  """The exported plugin code for verify_duplicate_sources.
19 
20  This validates that a certain set of libraries don't contain
21  duplicate source files which may cause One Definition Rule (ODR)
22  violation.
23  """
24  errors = []
25  target_groups = (
26  ('gpr', 'grpc', 'grpc++'),
27  ('gpr', 'grpc_unsecure', 'grpc++_unsecure'),
28  )
29  lib_map = {lib['name']: lib for lib in dictionary.get('libs')}
30  for target_group in target_groups:
31  src_map = {}
32  for target in target_group:
33  for src in lib_map[target]['src']:
34  if src.endswith('.cc'):
35  if src in src_map:
36  errors.append(
37  'Source {0} is used in both {1} and {2}'.format(
38  src, src_map[src], target))
39  else:
40  src_map[src] = target
41  if errors:
42  raise Exception('\n'.join(errors))
http2_test_server.format
format
Definition: http2_test_server.py:118
verify_duplicate_sources.mako_plugin
def mako_plugin(dictionary)
Definition: verify_duplicate_sources.py:17


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:50