From c635f218c0aefc801d9748841930365e54fe3089 Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Sun, 29 Jan 2023 18:03:16 +0200 Subject: [PATCH] v3.3.0 --- CMakeLists.txt | 2 +- README.md | 6 ++-- docs/pages/main_page.dox | 6 ++-- meson.build | 2 +- toml++.vcxproj | 1 + toml++.vcxproj.filters | 3 ++ tools/version.py | 68 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 tools/version.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c91ef4..1179d37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.14) project( tomlplusplus - VERSION 3.2.0 + VERSION 3.3.0 DESCRIPTION "Header-only TOML config file parser and serializer for C++17" HOMEPAGE_URL "https://marzer.github.io/tomlplusplus/" LANGUAGES CXX diff --git a/README.md b/README.md index 8d7afac..117af5f 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ You'll find some more code examples in the `examples` directory, and plenty more ### Conan -Add `tomlplusplus/3.2.0` to your conanfile. +Add `tomlplusplus/3.3.0` to your conanfile. ### DDS @@ -121,7 +121,7 @@ Add `tomlpp` to your `package.json5`, e.g.: ```plaintext depends: [ - 'tomlpp^3.2.0', + 'tomlpp^3.3.0', ] ``` @@ -166,7 +166,7 @@ include(FetchContent) FetchContent_Declare( tomlplusplus GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git - GIT_TAG v3.2.0 + GIT_TAG v3.3.0 ) FetchContent_MakeAvailable(tomlplusplus) ``` diff --git a/docs/pages/main_page.dox b/docs/pages/main_page.dox index a48e9b7..c090957 100644 --- a/docs/pages/main_page.dox +++ b/docs/pages/main_page.dox @@ -453,7 +453,7 @@ and [emoji sundae] Regular. The API is the same for both. \subsection mainpage-adding-lib-conan Conan -Add `tomlplusplus/3.2.0` to your conanfile. +Add `tomlplusplus/3.3.0` to your conanfile. @@ -461,7 +461,7 @@ Add `tomlplusplus/3.2.0` to your conanfile. Add `tomlpp` to your `package.json5`, e.g.: \json depends: [ - 'tomlpp^3.2.0', + 'tomlpp^3.3.0', ] \endjson @@ -507,7 +507,7 @@ include(FetchContent) FetchContent_Declare( tomlplusplus GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git - GIT_TAG v3.2.0 + GIT_TAG v3.3.0 ) FetchContent_MakeAvailable(tomlplusplus) \endcmake diff --git a/meson.build b/meson.build index 0edded1..79749df 100644 --- a/meson.build +++ b/meson.build @@ -7,7 +7,7 @@ project( 'tomlplusplus', 'cpp', license: 'MIT', - version: '3.2.0', + version: '3.3.0', meson_version: '>=0.61.0', default_options: [ # https://mesonbuild.com/Builtin-options.html diff --git a/toml++.vcxproj b/toml++.vcxproj index a4cbe2b..c9baaf0 100644 --- a/toml++.vcxproj +++ b/toml++.vcxproj @@ -127,6 +127,7 @@ + diff --git a/toml++.vcxproj.filters b/toml++.vcxproj.filters index e421807..97bb192 100644 --- a/toml++.vcxproj.filters +++ b/toml++.vcxproj.filters @@ -248,6 +248,9 @@ .github + + tools + diff --git a/tools/version.py b/tools/version.py new file mode 100644 index 0000000..018e521 --- /dev/null +++ b/tools/version.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# This file is a part of toml++ and is subject to the the terms of the MIT license. +# Copyright (c) Mark Gillard +# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. +# SPDX-License-Identifier: MIT + +import sys +import re +from argparse import ArgumentParser +from pathlib import Path + + + +def read_text_file(path): + print(rf'Reading {path}') + with open(path, r'r', encoding=r'utf-8') as f: + return f.read() + + + +def write_text_file(path, text): + print(rf'Writing {path}') + with open(path, r'w', encoding=r'utf-8', newline='\n') as f: + f.write(text) + + + +if __name__ == '__main__': + + args = ArgumentParser(r'version.py', description=r'Sets the project version in all the necessary places.') + args.add_argument(r'version', type=str) + args = args.parse_args() + + version = re.fullmatch(r'\s*([0-9]+)\s*[.,;]\s*([0-9]+)\s*[.,;]\s*([0-9]+)\s*', args.version) + if not version: + print(rf"Couldn't parse version triplet from '{args.version}'", file=sys.stderr) + sys.exit(1) + version = (int(version[1]), int(version[2]), int(version[3])) + version_str = rf'{version[0]}.{version[1]}.{version[2]}' + print(rf'version: {version_str}') + + root = Path(__file__).parent.parent.resolve() + + path = root / r'meson.build' + text = read_text_file(path) + text = re.sub(r'''(\s|^)version\s*:\s*['"].*?['"]''', rf"\1version: '{version_str}'", text, count=1) + write_text_file(path, text) + + path = root / r'CMakeLists.txt' + text = read_text_file(path) + text = re.sub(r'''(\s|^)VERSION\s+[0-9](?:[.][0-9]){2}''', rf"\1VERSION {version_str}", text, count=1, flags=re.I) + write_text_file(path, text) + + path = root / r'include/toml++/impl/version.h' + text = read_text_file(path) + text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_MAJOR)\s+[0-9]+''', rf"\1 {version[0]}", text) + text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_MINOR)\s+[0-9]+''', rf"\1 {version[1]}", text) + text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_PATCH)\s+[0-9]+''', rf"\1 {version[2]}", text) + write_text_file(path, text) + + noop_sub = r'#$%^nbsp^%$#' + for file in (r'README.md', r'docs/pages/main_page.dox'): + path = root / file + text = read_text_file(path) + text = re.sub(r'''(toml(?:plusplus|\+\+|pp)\s*[/:^]\s*)[0-9](?:[.][0-9]){2}''', rf"\1{noop_sub}{version_str}", text, flags=re.I) + text = re.sub(r'''(GIT_TAG\s+)(?:v\s*)?[0-9](?:[.][0-9]){2}''', rf"\1v{version_str}", text, flags=re.I) + text = text.replace(noop_sub, '') + write_text_file(path, text)