Skip to content

Commit

Permalink
Meson: Also update version number in meson.build during release
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecrowe committed Oct 1, 2022
1 parent 982d1c2 commit d0b0cb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion meson.build
Expand Up @@ -8,7 +8,7 @@
project(
'catch2',
'cpp',
version : '3.1.0',
version : '3.1.0', # CML version placeholder, don't delete
license: 'BSL-1.0',
meson_version: '>=0.49.0'
)
Expand Down
12 changes: 12 additions & 0 deletions tools/scripts/releaseCommon.py
Expand Up @@ -15,6 +15,7 @@
definePath = os.path.join(rootPath, 'catch_version_macros.hpp')
readmePath = os.path.join( catchPath, "README.md" )
cmakePath = os.path.join(catchPath, 'CMakeLists.txt')
mesonPath = os.path.join(catchPath, 'meson.build')

class Version:
def __init__(self):
Expand Down Expand Up @@ -89,6 +90,16 @@ def updateCmakeFile(version):
file.write(replacementRegex.sub(replacement, line))


def updateMesonFile(version):
with open(mesonPath, 'rb') as file:
lines = file.readlines()
replacementRegex = re.compile(b'''version\s*:\s*'(\\d+.\\d+.\\d+)', # CML version placeholder, don't delete''')
replacement = '''version : '{0}', # CML version placeholder, don't delete'''.format(version.getVersionString()).encode('ascii')
with open(mesonPath, 'wb') as file:
for line in lines:
file.write(replacementRegex.sub(replacement, line))


def updateVersionDefine(version):
# First member of the tuple is the compiled regex object, the second is replacement if it matches
replacementRegexes = [(re.compile(b'#define CATCH_VERSION_MAJOR \\d+'),'#define CATCH_VERSION_MAJOR {}'.format(version.majorVersion).encode('ascii')),
Expand Down Expand Up @@ -132,4 +143,5 @@ def performUpdates(version):
generateAmalgamatedFiles.generate_cpp()

updateCmakeFile(version)
updateMesonFile(version)
updateDocumentationVersionPlaceholders(version)

0 comments on commit d0b0cb1

Please sign in to comment.