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