Skip to content

Commit 961d365

Browse files
committed
Merge #176: Make make-tag.py compatible with CMake
658a84a Make `make-tag.py` compatible with CMake (Hennadii Stepanov) 278f73a Fix "SyntaxWarning: invalid escape sequence" (Hennadii Stepanov) Pull request description: Fixes #175. ACKs for top commit: achow101: ACK 658a84a laanwj: Code review ACK 658a84a Tree-SHA512: 1a39e9fbf19b6785091a3e16ad98e61c981b124a6b12234065756785fd6f946fef30d6ba61289a4bb0183a49f56296384d857d5d18d34f9be05e2925a991c4d9
2 parents d49cea0 + 658a84a commit 961d365

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

make-tag.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def parse_tag(tag):
3838
- v1.2rc3
3939
- v1.2.3rc4
4040
'''
41-
m = re.match("^v([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:rc([0-9])+)?$", tag)
41+
m = re.match(r"^v([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:rc([0-9])+)?$", tag)
4242

4343
if m is None:
4444
print(f"Invalid tag {tag}", file=sys.stderr)
@@ -62,16 +62,25 @@ def parse_tag(tag):
6262

6363
return VersionSpec(int(major), int(minor), int(build), int(rc))
6464

65-
def check_configure_ac(spec):
65+
def check_buildsystem(spec):
6666
'''
67-
Parse configure.ac and return
67+
Parse configure.ac or CMakeLists.txt and return
6868
(major, minor, build, rc)
6969
'''
7070
info = {}
7171
filename = 'configure.ac'
72+
if os.path.exists(filename):
73+
pattern = r"define\(_CLIENT_VERSION_([A-Z_]+), ([0-9a-z]+)\)"
74+
else:
75+
filename = 'CMakeLists.txt'
76+
if not os.path.exists(filename):
77+
print("No buildsystem (configure.ac or CMakeLists.txt) found", file=sys.stderr)
78+
sys.exit(1)
79+
pattern = r'set\(CLIENT_VERSION_([A-Z_]+)\s+"?([0-9a-z]+)"?\)'
80+
7281
with open(filename) as f:
7382
for line in f:
74-
m = re.match("define\(_CLIENT_VERSION_([A-Z_]+), ([0-9a-z]+)\)", line)
83+
m = re.match(pattern, line)
7584
if m:
7685
info[m.group(1)] = m.group(2)
7786
# check if IS_RELEASE is set
@@ -110,7 +119,7 @@ def main():
110119
sys.exit(1)
111120

112121
# Check version components against configure.ac in git tree
113-
check_configure_ac(spec)
122+
check_buildsystem(spec)
114123

115124
# Generate base message
116125
if not spec.build:

0 commit comments

Comments
 (0)