aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/tools/run_tests/sources_and_headers.json.template
blob: 07559828dc49a5ff9086f4b44ba13fdf559dc7d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
%YAML 1.2
--- |
  <%!
  import json
  import os

  def proto_headers(src):
    out = []
    for f in src:
      name, ext = os.path.splitext(f)
      if ext == '.proto':
        out.extend(fmt % name for fmt in ['%s.grpc.pb.h', '%s.pb.h'])
    return out

  def all_targets(targets, libs, filegroups):
    for tgt in targets:
      yield ('target', tgt)
    for tgt in libs:
      yield ('lib', tgt)
    for tgt in filegroups:
      yield ('filegroup', tgt)

  def no_protos_filter(src):
  	return os.path.splitext(src)[1] != '.proto'

  def no_third_party_filter(src):
  	return not src.startswith('third_party/')

  def filter_srcs(srcs, filters):
  	out = []
  	for s in srcs:
  		filter_passes = (f(s) for f in filters)
  		if all(filter_passes):
  			out.append(s)
  	return out
  %>

  ${json.dumps([{"name": tgt.name,
                 "type": typ,
                 "language": tgt.language,
                 "third_party": tgt.boringssl or tgt.zlib,
                 "src": sorted(
                     filter_srcs(tgt.own_src, (no_protos_filter, no_third_party_filter)) +
                     filter_srcs(tgt.own_public_headers, (no_protos_filter, no_third_party_filter)) +
                     filter_srcs(tgt.own_headers, (no_third_party_filter,))),
                 "headers": sorted(
                     tgt.own_public_headers +
                     tgt.own_headers +
                     proto_headers(tgt.own_src)),
                 "deps": sorted(tgt.get('deps', []) +
                                tgt.get('uses', []) +
                                tgt.get('filegroups', []))}
                for typ, tgt in all_targets(targets, libs, filegroups)],
               sort_keys=True, indent=2)}