• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1%YAML 1.2
2--- |
3  <%!
4  import json
5  import os
6
7  def proto_headers(src):
8    out = []
9    for f in src:
10      name, ext = os.path.splitext(f)
11      if ext == '.proto':
12        out.extend(fmt % name for fmt in ['%s.grpc.pb.h', '%s.pb.h', '%s_mock.grpc.pb.h'])
13    return out
14
15  def all_targets(targets, libs, filegroups):
16    for tgt in targets:
17      yield ('target', tgt)
18    for tgt in libs:
19      yield ('lib', tgt)
20    for tgt in filegroups:
21      yield ('filegroup', tgt)
22
23  def no_protos_filter(src):
24  	return os.path.splitext(src)[1] != '.proto'
25
26  def no_third_party_filter(src):
27  	return not src.startswith('third_party/')
28
29  def filter_srcs(srcs, filters):
30  	out = []
31  	for s in srcs:
32  		filter_passes = (f(s) for f in filters)
33  		if all(filter_passes):
34  			out.append(s)
35  	return out
36  %>
37
38  ${json.dumps([{"name": tgt.name,
39                 "type": typ,
40                 "is_filegroup": False,
41                 "language": tgt.language,
42                 "third_party": tgt.boringssl or tgt.zlib,
43                 "src": sorted(
44                     filter_srcs(tgt.own_src, (no_protos_filter, no_third_party_filter)) +
45                     filter_srcs(tgt.own_public_headers, (no_protos_filter, no_third_party_filter)) +
46                     filter_srcs(tgt.own_headers, (no_third_party_filter,))),
47                 "headers": sorted(
48                     tgt.own_public_headers +
49                     tgt.own_headers +
50                     proto_headers(tgt.own_src)),
51                 "deps": sorted(tgt.get('deps', []) +
52                                tgt.get('uses', []) +
53                                tgt.get('filegroups', []))}
54                for typ, tgt in all_targets(targets, libs, [])] +
55                [{"name": tgt.name,
56                 "type": typ,
57                 "is_filegroup": True,
58                 "language": tgt.language,
59                 "third_party": tgt.boringssl or tgt.zlib,
60                 "src": sorted(
61                     filter_srcs(tgt.own_src, (no_protos_filter, no_third_party_filter)) +
62                     filter_srcs(tgt.own_public_headers, (no_protos_filter, no_third_party_filter)) +
63                     filter_srcs(tgt.own_headers, (no_third_party_filter,))),
64                 "headers": sorted(
65                     tgt.own_public_headers +
66                     tgt.own_headers +
67                     proto_headers(tgt.own_src)),
68                 "deps": sorted(tgt.get('deps', []) +
69                                tgt.get('uses', []) +
70                                tgt.get('filegroups', []))}
71                for typ, tgt in all_targets([], [], filegroups)],
72               sort_keys=True, indent=2)}
73