36 assert len(sys.argv) > 1
37 version_path = sys.argv[1]
39 with open(version_path,
'r')
as version_file:
40 for line
in version_file:
41 match = re.match(
r'[ \t]*define\(\[(.*)\],[ \t]*\[(.*)\]\)[ \t]*', line)
43 output.append(match.expand(
r'set(\1 \2)'))
44 out_path = os.path.join(
"%s" % (sys.argv[2]
if len(sys.argv) > 2
else "."),
"version.cmake")
48 with open(out_path,
"r")
as out_file:
49 prev_content = out_file.read()
54 content =
"\n".join(output) +
"\n"
55 if prev_content != content:
56 print(
"Writing %s" % out_path)
57 with open(out_path,
"w")
as out_file:
58 out_file.write(content)
60 print(
"Content of %s hasn't changed" % out_path)
62 if __name__ ==
"__main__":