diff options
| author | Leitwolf11 | 2026-09-24 22:07:03 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-09-24 22:07:03 +0300 |
| commit | 9ad804cedf4cc4a85ef89fe097f97a3b44654360 (patch) | |
| tree | f088e919776b22d19387377bdbec727daa2429c0 /buildsupport/catch2_config.lua | |
| parent | 02f8b5593a15cdec8558256e6f40a0c7fb5862d6 (diff) | |
| download | catch3-0.1.0.tar.gz | |
Add Progmasoft Catch3 property testing and build support0.1.0
Introduce deterministic property execution, built-in generators, shrinking, replayable seeds, and a separate Progmasoft-owned header API while preserving Catch2 compatibility targets and the C++14 engine baseline.
Add Bazel, Meson, Xmake, and Premake integration and tests alongside the existing CMake build. Replace Linux-only workflow coverage with Windows and macOS jobs and document the Catch2/Catch3 distinction.
Diffstat (limited to 'buildsupport/catch2_config.lua')
| -rw-r--r-- | buildsupport/catch2_config.lua | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/buildsupport/catch2_config.lua b/buildsupport/catch2_config.lua new file mode 100644 index 00000000..5067d247 --- /dev/null +++ b/buildsupport/catch2_config.lua @@ -0,0 +1,57 @@ +-- Copyright (c) 2026 Progmasoft. +-- SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1 + +-- Materialize Catch2's checked-in CMake template for non-CMake build tools. +-- Keeping the template as the source of truth avoids maintaining a second +-- copy of upstream configuration declarations under a different license. +local M = {} + +local function read_file(file_path) + local file = assert(io.open(file_path, "rb"), "cannot read " .. file_path) + local contents = file:read("*a") + file:close() + return contents +end + +local function write_file(file_path, contents) + local file = assert(io.open(file_path, "wb"), "cannot write " .. file_path) + file:write(contents) + file:close() +end + +--- Generates the default Catch2 user configuration header under output_root. +--- The generated path is output_root/catch2/catch_user_config.hpp. +function M.generate(output_root, repository_root) + local template_path = repository_root .. "/src/catch2/catch_user_config.hpp.in" + local template = read_file(template_path) + + -- Neither Xmake nor Premake interprets CMake's #cmakedefine directives. + -- All feature toggles stay at Catch2's defaults; the two value settings + -- match Catch2's own CMake defaults and the root Bazel configuration. + local configured = template:gsub( + "#cmakedefine%s+([%w_]+)%s*([^\r\n]*)", + function(name) + if name == "CATCH_CONFIG_DEFAULT_REPORTER" then + return '#define CATCH_CONFIG_DEFAULT_REPORTER "console"' + elseif name == "CATCH_CONFIG_CONSOLE_WIDTH" then + return "#define CATCH_CONFIG_CONSOLE_WIDTH 80" + end + return "/* #undef " .. name .. " */" + end + ) + + configured = configured:gsub('"@CATCH_CONFIG_DEFAULT_REPORTER@"', '"console"') + configured = configured:gsub("@CATCH_CONFIG_CONSOLE_WIDTH@", "80") + configured = configured:gsub("@CATCH_CONFIG_FALLBACK_STRINGIFIER@", "") + + local output_dir = output_root .. "/catch2" + os.mkdir(output_dir) + write_file(output_dir .. "/catch_user_config.hpp", configured) +end + +-- Xmake imports call the module's main entry point; Premake can use generate. +function main(output_root, repository_root) + return M.generate(output_root, repository_root) +end + +return M |