24 TEST = (os.environ.get(
'TEST',
'false') ==
'true')
27 'settings',
'proto_deps',
'filegroups',
'libs',
'targets',
'vspackages'
30 'name',
'gtest',
'cpu_cost',
'flaky',
'build',
'run',
'language',
31 'public_headers',
'headers',
'src',
'deps'
36 return dumper.represent_mapping(
'tag:yaml.org,2002:map',
40 yaml.add_representer(collections.OrderedDict, repr_ordered_dict)
44 outdict = collections.OrderedDict()
45 for key
in sorted(indict.keys()):
47 outdict[key] = indict[key]
48 for key
in special_keys:
50 outdict[key] = indict[key]
51 for key
in sorted(indict.keys()):
52 if key
in special_keys:
56 outdict[key] = indict[key]
61 for name
in [
'public_headers',
'headers',
'src']:
62 if name
not in indict:
65 protos = list(x
for x
in inlist
if os.path.splitext(x)[1] ==
'.proto')
66 others =
set(x
for x
in inlist
if x
not in protos)
67 indict[name] = protos + sorted(others)
72 """Takes dictionary which represents yaml file and returns the cleaned-up yaml string"""
74 for grp
in [
'filegroups',
'libs',
'targets']:
78 key=
lambda x: (x.get(
'language',
'_'), x[
'name']))
79 output = yaml.dump(js, indent=2, width=80, default_flow_style=
False)
82 for line
in output.splitlines():
83 lines.append(line.rstrip() +
'\n')
84 output =
''.join(lines)
88 if __name__ ==
'__main__':
89 for filename
in sys.argv[1:]:
90 with open(filename)
as f:
91 js = yaml.load(f, Loader=yaml.FullLoader)
94 with open(filename)
as f:
95 if not f.read() == output:
97 'Looks like build-cleaner.py has not been run for file "%s"?'
100 with open(filename,
'w')
as f: