diff options
| author | Leitwolf11 | 2026-11-01 22:16:14 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-01 22:16:14 +0300 |
| commit | da3c9d0880dbd4a74e0e43f092d10f5ae42c5043 (patch) | |
| tree | 4676a526585dbb0e2f6d8c9c18978ed01092c2e2 /tools/VersionMain.cpp | |
| parent | 241b5567d09d59e82bff18287c32ada480deb8c0 (diff) | |
| download | catch3-da3c9d0880dbd4a74e0e43f092d10f5ae42c5043.tar.gz | |
Move the tools from Python to C++17 and Bazel
The scripts in use become programs run with `bazelisk run //tools:<tool>`,
and arguments follow `--`:
amalgamate the single-file distribution; --check only compares it
check licenses, convenience headers, header guards, file names,
versions and whether the distribution is up to date
third-party compares third_party/ with its archives, or writes it
version prints the version, or moves every place that states it
release-notes prints a section of the release notes
repo-info reports the checkout and the tools on PATH; --json writes
it through yyjson, with the fields of Tala's repo-info
amalgamate writes what the Python script wrote, byte for byte, except for
the time of generation. That line is gone so that the output is
deterministic and --check can compare it.
MODULE.bazel now pins the archives of third_party/ by version and sha256,
so Bazel fetches and checks them instead of a tool of ours, and Renovate
reads the versions there.
Scripts nobody used are gone: fixWhitespace, updateDocumentSnippets,
buildAndTest, and updateDocumentToC, which rewrote unrelated documents.
CheckConvenienceHeaders leaves CTest, since //tools:check runs it in CI.
The Python of tests/TestScripts stays: those are tests, not tools.
Diffstat (limited to 'tools/VersionMain.cpp')
| -rw-r--r-- | tools/VersionMain.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tools/VersionMain.cpp b/tools/VersionMain.cpp new file mode 100644 index 00000000..a7fb123a --- /dev/null +++ b/tools/VersionMain.cpp @@ -0,0 +1,69 @@ +// Copyright (c) 2026 Progmasoft. +// SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-2.0 + +// bazelisk run //tools:version prints the current version +// bazelisk run //tools:version -- --next moves to the next version +// bazelisk run //tools:version -- 0.3.1.0 moves to that version +// +// Moving writes every place that states the version, and the amalgamation. + +#include <iostream> +#include <string> +#include <string_view> + +#include "tools/Amalgamation.hpp" +#include "tools/Repository.hpp" +#include "tools/Versions.hpp" + +int +main(int argc, char **argv) +{ + using namespace Progmasoft::Catch3::Tools; + + if (argc > 2) + { + std::cerr + << "usage: bazelisk run //tools:version [-- --next|<version>]\n"; + return 2; + } + const auto root = RepositoryRoot(); + if (!root) + { + std::cerr << "run this tool with bazelisk run\n"; + return 2; + } + Problems problems; + const auto current = CurrentVersion(*root, problems); + if (!current) + { + return Finish(problems); + } + if (argc == 1) + { + std::cout << *current << '\n'; + return 0; + } + const std::string_view argument{ argv[1] }; + const auto parsed = ParseVersion( + argument == "--next" ? *current : std::string{ argument }); + if (!parsed) + { + std::cerr << "not a version of three or four numbers: " << argument + << '\n'; + return 2; + } + const auto version + = FormatVersion(argument == "--next" ? NextVersion(*parsed) : *parsed); + SetVersion(*root, version, problems); + if (problems.empty()) + { + WriteAmalgamation(*root, + GenerateAmalgamation(*root, problems), + problems); + } + if (problems.empty()) + { + std::cout << *current << " -> " << version << '\n'; + } + return Finish(problems); +} |