diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-12-22 10:49:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 10:49:21 +0100 |
commit | 276f390480a4ecb90909e9ebd7ef581dea3d480a (patch) | |
tree | 2a5cb418a5485dbd0677212fb45394387846ecff /templates/tools/run_tests/generated/sources_and_headers.json.template | |
parent | d7c923d40bc609d442130e57bf1177fcc3bbcf80 (diff) | |
parent | 5c79a3199c1b47d1a2d3ff4dc5636c9c90ca2a7f (diff) |
Merge pull request #9176 from jtattermusch/runtests_refactor
Clean up tools/run_tests directory
Diffstat (limited to 'templates/tools/run_tests/generated/sources_and_headers.json.template')
-rw-r--r-- | templates/tools/run_tests/generated/sources_and_headers.json.template | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/templates/tools/run_tests/generated/sources_and_headers.json.template b/templates/tools/run_tests/generated/sources_and_headers.json.template new file mode 100644 index 0000000000..1c5c9747d6 --- /dev/null +++ b/templates/tools/run_tests/generated/sources_and_headers.json.template @@ -0,0 +1,72 @@ +%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, + "is_filegroup": False, + "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, [])] + + [{"name": tgt.name, + "type": typ, + "is_filegroup": True, + "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([], [], filegroups)], + sort_keys=True, indent=2)} |