feat(config): import CMake configure presets
This commit is contained in:
1 parent
7772697a48
commit
083af6af79
10 files changed
+387
-1
No files matched your search
@@ -46,6 +46,7 @@ add_library(VoidBuild_Core STATIC
|
||||
src/Execution/Scheduler.cpp
|
||||
src/Config/BuildTree.cpp
|
||||
src/Config/Frontend.cpp
|
||||
src/Config/Presets.cpp
|
||||
src/Config/Scaffold.cpp
|
||||
src/Daemon/Daemon.cpp
|
||||
src/Editor/CompDb.cpp
|
||||
|
||||
@@ -292,6 +292,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
|
||||
- **Wave 99 (Windows Path & Case-Sensitivity Validation)**: graph lowering for Windows targets rejects case-insensitive output collisions (`Tool` vs `tool` → `Tool.exe`/`tool.exe`) and reserved device names (`CON`, `NUL`, `COM1`, …), with explicit diagnostics. The Wine regression test now also proves PE case-insensitive file semantics (`fopen("CASE_A.TXT")` finds `case_a.txt`) and asserts both validation errors.
|
||||
|
||||
- **Wave 100 (CMakePresets Import)**: `Config::load_cmake_presets` parses `CMakePresets.json`-style configure presets (resolving `inherits` as a string or array with cycle detection), expands `${sourceDir}`, merges `cacheVariables`, and maps `CMAKE_BUILD_TYPE`/`CMAKE_CXX_COMPILER` onto VBS profile/compiler. The `vbs presets` CLI lists the mapping or prints the equivalent `vbs build` command for one preset; covered by `FullV1Tests.cmake_presets_import_maps_inherits_and_cache` and a CLI contract.
|
||||
|
||||
## Remaining future scope
|
||||
|
||||
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
|
||||
|
||||
@@ -103,4 +103,5 @@ Base HEAD: `fe0d1a6`
|
||||
| Wave 97 (ZIP & DEB generators) | `--archive-format zip|deb`: stored ZIP and Debian ar package with metadata; tested structurally and validated with real `dpkg-deb` | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; install test passes, full CTest 8/8) | `include/Void/Build/Install/Installer.hpp`, `src/Install/Installer.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs |
|
||||
| Wave 98 (Signed installer archives) | `--signing-key` writes `.sha256`/`.sig`/`.pub` for the installer archive and fails closed without a backend | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; install test passes, full CTest 8/8) | `include/Void/Build/Install/Installer.hpp`, `src/Install/Installer.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs |
|
||||
| Wave 99 (Windows path semantics) | Case-insensitive output collision + reserved device name validation for Windows targets; Wine case-insensitivity assertion | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Windows regression test passes, full CTest 8/8) | `src/Graph/Graph.cpp`, `tests/FullV1Tests.cpp`, docs |
|
||||
| Wave 100 (CMakePresets import) | `Config::load_cmake_presets` (inherits, `${sourceDir}`, cache merge, profile/compiler mapping) + `vbs presets` CLI | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; presets test passes, full CTest 8/8) | `include/Void/Build/Config/Presets.hpp`, `src/Config/Presets.cpp`, `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}.cpp/cmake`, docs |
|
||||
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
|
||||
@@ -1412,6 +1412,12 @@ dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc -p wine64 -c build/pinned/bin/vbs_v1
|
||||
target fails with `reserved Windows device name`.
|
||||
- Regression test: **passed** (14.12 s); full CTest: **8 / 8 passed** in 277.56 s.
|
||||
|
||||
## CMakePresets Import (GCC 16.2, pin `0002e74`)
|
||||
|
||||
- `FullV1Tests.cmake_presets_import_maps_inherits_and_cache` **passed**: a child preset inheriting an array parent gets the merged `${sourceDir}` binary dir, `Release` → `release` profile, `clang++` → `clang`, and the suggested command contains `--profile 'release' --compiler 'clang' --build-dir '...'`; a bare preset defaults to `debug`/`gcc` with no build dir.
|
||||
- CLI contract: `vbs presets --help` passes.
|
||||
- Full CTest: **8 / 8 passed** in 276.96 s.
|
||||
|
||||
## Limits and Unrun Checks
|
||||
|
||||
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
|
||||
|
||||
@@ -78,7 +78,7 @@ Concrete work this implies:
|
||||
1. Documentation drift: status tables must match verified reality (this plan updates them).
|
||||
2. Wine-first Windows target support (§2).
|
||||
3. Packaging parity: ZIP (stored), DEB, RPM, metadata, signing (`--archive-format` extensions).
|
||||
4. IDE ecosystem: File API shim, presets import, external plugins.
|
||||
4. IDE ecosystem: File API shim, presets import (**done**: `vbs presets`), external plugins.
|
||||
5. Migration tooling (`vbs migrate`) and migrating VoidLibrary onto VBS.
|
||||
6. Test-runner parity.
|
||||
7. Benchmarks against CMake/Meson/build2 on documented fixtures (including 10k-target scaling).
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Functional/Error.hpp>
|
||||
#include <Void/Functional/Result.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Void::Build::Config {
|
||||
|
||||
// One imported CMake configure preset projected onto VBS concepts.
|
||||
struct ImportedPreset {
|
||||
std::string name;
|
||||
std::string generator; // Recorded for diagnostics; VBS has no generator.
|
||||
std::optional<std::string> build_dir; // binaryDir with ${sourceDir} expanded.
|
||||
std::string build_type; // Raw CMAKE_BUILD_TYPE (may be empty).
|
||||
std::string profile{"debug"}; // Mapped VBS profile: debug or release.
|
||||
std::string compiler{"gcc"}; // Mapped VBS compiler family: gcc or clang.
|
||||
std::map<std::string, std::string, std::less<>> cache_variables;
|
||||
};
|
||||
|
||||
// Parses `CMakePresets.json`-style configure presets, resolving `inherits`
|
||||
// (string or array) and projecting build type/compiler onto VBS defaults.
|
||||
// The project root is used to expand `${sourceDir}`.
|
||||
[[nodiscard]] Void::Result::Result<std::vector<ImportedPreset>, Void::Result::Error>
|
||||
load_cmake_presets(const std::filesystem::path &presets_file,
|
||||
const std::filesystem::path &project_root);
|
||||
|
||||
// Shell-safe single-quoted argument for the suggested `vbs` command line.
|
||||
[[nodiscard]] std::string suggested_build_command(const ImportedPreset &preset);
|
||||
|
||||
} // namespace Void::Build::Config
|
||||
@@ -0,0 +1,235 @@
|
||||
#include <Void/Build/Config/Presets.hpp>
|
||||
|
||||
#include <Void/Data/StrictJson.hpp>
|
||||
#include <Void/System/Path.hpp>
|
||||
#include <Void/System/Types.hpp>
|
||||
#include <Void/Text/Str.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
|
||||
namespace Void::Build::Config {
|
||||
namespace {
|
||||
|
||||
using JsonValue = Void::Json::Strict::Value;
|
||||
using JsonObject = JsonValue::Object;
|
||||
|
||||
Void::Result::Error make_error(std::string message) {
|
||||
return Void::System::make_system_error(Void::System::SystemErrorCode::invalid_argument,
|
||||
std::move(message));
|
||||
}
|
||||
|
||||
std::string lower(std::string_view text) { return Void::Str::to_lower_ascii(text); }
|
||||
|
||||
std::string map_profile(std::string_view build_type) {
|
||||
const std::string type = lower(build_type);
|
||||
if (type == "debug") {
|
||||
return "debug";
|
||||
}
|
||||
if (type == "release" || type == "relwithdebinfo" || type == "minsizerel") {
|
||||
return "release";
|
||||
}
|
||||
return "debug";
|
||||
}
|
||||
|
||||
std::string map_compiler(std::string_view compiler_path) {
|
||||
const std::string path = lower(compiler_path);
|
||||
if (path.find("clang") != std::string::npos) {
|
||||
return "clang";
|
||||
}
|
||||
return "gcc";
|
||||
}
|
||||
|
||||
std::string expand_source_dir(std::string value, const std::filesystem::path &project_root) {
|
||||
const std::string token{"${sourceDir}"};
|
||||
std::size_t pos = 0;
|
||||
while ((pos = value.find(token, pos)) != std::string::npos) {
|
||||
value.replace(pos, token.size(), project_root.string());
|
||||
pos += project_root.string().size();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Void::Result::Result<std::vector<ImportedPreset>, Void::Result::Error>
|
||||
load_cmake_presets(const std::filesystem::path &presets_file,
|
||||
const std::filesystem::path &project_root) {
|
||||
auto text = Void::FileSystem::read_file(presets_file);
|
||||
if (!text) {
|
||||
return std::unexpected{text.error()};
|
||||
}
|
||||
auto parsed = Void::Json::Strict::parse(*text);
|
||||
if (!parsed) {
|
||||
return std::unexpected{
|
||||
make_error(std::format("CMakePresets '{}' is not valid JSON", presets_file.string()))};
|
||||
}
|
||||
const auto *root = std::get_if<JsonObject>(&parsed->value);
|
||||
if (!root) {
|
||||
return std::unexpected{make_error("CMakePresets root must be a JSON object")};
|
||||
}
|
||||
const auto list_it = root->find("configurePresets");
|
||||
if (list_it == root->end()) {
|
||||
return std::vector<ImportedPreset>{};
|
||||
}
|
||||
const auto *presets = std::get_if<JsonValue::Array>(&list_it->second.value);
|
||||
if (!presets) {
|
||||
return std::unexpected{make_error("configurePresets must be a JSON array")};
|
||||
}
|
||||
|
||||
std::map<std::string, JsonObject, std::less<>> raw_by_name;
|
||||
std::vector<std::string> order;
|
||||
for (const auto &entry : *presets) {
|
||||
const auto *object = std::get_if<JsonObject>(&entry.value);
|
||||
if (!object) {
|
||||
continue;
|
||||
}
|
||||
const auto name_it = object->find("name");
|
||||
if (name_it == object->end()) {
|
||||
continue;
|
||||
}
|
||||
const auto *name = std::get_if<std::string>(&name_it->second.value);
|
||||
if (!name) {
|
||||
continue;
|
||||
}
|
||||
if (!raw_by_name.contains(*name)) {
|
||||
order.push_back(*name);
|
||||
}
|
||||
raw_by_name[*name] = *object;
|
||||
}
|
||||
|
||||
// Flattens `inherits` (string or array) depth-first with cycle detection.
|
||||
std::map<std::string, JsonObject, std::less<>> merged;
|
||||
std::function<Void::Result::Result<JsonObject, Void::Result::Error>(const std::string &,
|
||||
std::set<std::string>)>
|
||||
flatten = [&](const std::string &name, std::set<std::string> stack)
|
||||
-> Void::Result::Result<JsonObject, Void::Result::Error> {
|
||||
if (const auto it = merged.find(name); it != merged.end()) {
|
||||
return it->second;
|
||||
}
|
||||
const auto raw_it = raw_by_name.find(name);
|
||||
if (raw_it == raw_by_name.end()) {
|
||||
return std::unexpected{make_error(
|
||||
std::format("CMakePresets preset '{}' is inherited but not defined", name))};
|
||||
}
|
||||
if (!stack.insert(name).second) {
|
||||
return std::unexpected{
|
||||
make_error(std::format("CMakePresets inherits cycle at '{}'", name))};
|
||||
}
|
||||
JsonObject result;
|
||||
const auto inherits_it = raw_it->second.find("inherits");
|
||||
std::vector<std::string> parents;
|
||||
if (inherits_it != raw_it->second.end()) {
|
||||
if (const auto *single = std::get_if<std::string>(&inherits_it->second.value)) {
|
||||
parents.push_back(*single);
|
||||
} else if (const auto *many =
|
||||
std::get_if<JsonValue::Array>(&inherits_it->second.value)) {
|
||||
for (const auto &parent : *many) {
|
||||
if (const auto *text = std::get_if<std::string>(&parent.value)) {
|
||||
parents.push_back(*text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto &parent : parents) {
|
||||
auto parent_merged = flatten(parent, stack);
|
||||
if (!parent_merged) {
|
||||
return std::unexpected{parent_merged.error()};
|
||||
}
|
||||
for (const auto &[key, value] : *parent_merged) {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
for (const auto &[key, value] : raw_it->second) {
|
||||
if (key == "cacheVariables") {
|
||||
auto &target = result[key];
|
||||
if (target.value.index() == 0) {
|
||||
target = JsonValue{JsonObject{}};
|
||||
}
|
||||
auto *target_object = std::get_if<JsonObject>(&target.value);
|
||||
const auto *source_object = std::get_if<JsonObject>(&value.value);
|
||||
if (target_object != nullptr && source_object != nullptr) {
|
||||
for (const auto &[cache_key, cache_value] : *source_object) {
|
||||
(*target_object)[cache_key] = cache_value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
merged[name] = result;
|
||||
return result;
|
||||
};
|
||||
|
||||
std::vector<ImportedPreset> imported;
|
||||
for (const auto &name : order) {
|
||||
auto flat = flatten(name, {});
|
||||
if (!flat) {
|
||||
return std::unexpected{flat.error()};
|
||||
}
|
||||
ImportedPreset preset;
|
||||
preset.name = name;
|
||||
const auto read_string = [&](std::string_view key) -> std::string {
|
||||
const auto it = flat->find(std::string{key});
|
||||
if (it == flat->end()) {
|
||||
return {};
|
||||
}
|
||||
const auto *value = std::get_if<std::string>(&it->second.value);
|
||||
return value ? *value : std::string{};
|
||||
};
|
||||
preset.generator = read_string("generator");
|
||||
if (auto binary_dir = read_string("binaryDir"); !binary_dir.empty()) {
|
||||
preset.build_dir = expand_source_dir(binary_dir, project_root);
|
||||
}
|
||||
if (const auto cache_it = flat->find("cacheVariables"); cache_it != flat->end()) {
|
||||
if (const auto *cache = std::get_if<JsonObject>(&cache_it->second.value)) {
|
||||
for (const auto &[key, value] : *cache) {
|
||||
std::string text;
|
||||
if (const auto *as_text = std::get_if<std::string>(&value.value)) {
|
||||
text = *as_text;
|
||||
} else if (const auto *as_bool = std::get_if<bool>(&value.value)) {
|
||||
text = *as_bool ? "ON" : "OFF";
|
||||
}
|
||||
preset.cache_variables[key] = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (const auto bt = preset.cache_variables.find("CMAKE_BUILD_TYPE");
|
||||
bt != preset.cache_variables.end()) {
|
||||
preset.build_type = bt->second;
|
||||
}
|
||||
preset.profile = map_profile(preset.build_type);
|
||||
if (const auto cxx = preset.cache_variables.find("CMAKE_CXX_COMPILER");
|
||||
cxx != preset.cache_variables.end()) {
|
||||
preset.compiler = map_compiler(cxx->second);
|
||||
}
|
||||
imported.push_back(std::move(preset));
|
||||
}
|
||||
return imported;
|
||||
}
|
||||
|
||||
std::string suggested_build_command(const ImportedPreset &preset) {
|
||||
const auto quote = [](const std::string &value) {
|
||||
std::string out{"'"};
|
||||
for (const char c : value) {
|
||||
if (c == '\'') {
|
||||
out += "'\\''";
|
||||
} else {
|
||||
out.push_back(c);
|
||||
}
|
||||
}
|
||||
out.push_back('\'');
|
||||
return out;
|
||||
};
|
||||
std::string command = "vbs build";
|
||||
if (preset.build_dir) {
|
||||
command += " --build-dir " + quote(*preset.build_dir);
|
||||
}
|
||||
command += " --profile " + quote(preset.profile);
|
||||
command += " --compiler " + quote(preset.compiler);
|
||||
return command;
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Config
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <Void/Build/Bridge/CMakeBridge.hpp>
|
||||
#include <Void/Build/Config/BuildTree.hpp>
|
||||
#include <Void/Build/Config/Frontend.hpp>
|
||||
#include <Void/Build/Config/Presets.hpp>
|
||||
#include <Void/Build/Config/Scaffold.hpp>
|
||||
#include <Void/Build/Daemon/Daemon.hpp>
|
||||
#include <Void/Build/Editor/CompDb.hpp>
|
||||
@@ -1331,6 +1332,40 @@ int execute_compdb_entries_command(const CompdbEntriesCmdOptions &opts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct PresetsCmdOptions {
|
||||
std::string file_arg{"CMakePresets.json"};
|
||||
std::string project_arg;
|
||||
std::optional<std::string> name_arg;
|
||||
};
|
||||
|
||||
int execute_presets_command(const PresetsCmdOptions &opts) {
|
||||
auto presets = Config::load_cmake_presets(opts.file_arg, opts.project_arg);
|
||||
if (!presets) {
|
||||
std::cerr << "vbs presets: " << presets.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
if (opts.name_arg) {
|
||||
const auto match =
|
||||
std::ranges::find_if(*presets, [&](const Config::ImportedPreset &preset) {
|
||||
return preset.name == *opts.name_arg;
|
||||
});
|
||||
if (match == presets->end()) {
|
||||
std::cerr << "vbs presets: unknown preset '" << *opts.name_arg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
std::cout << Config::suggested_build_command(*match) << '\n';
|
||||
return 0;
|
||||
}
|
||||
for (const auto &preset : *presets) {
|
||||
std::cout << "preset=" << preset.name << " profile=" << preset.profile
|
||||
<< " compiler=" << preset.compiler
|
||||
<< " build_dir=" << (preset.build_dir ? *preset.build_dir : std::string{"-"})
|
||||
<< " build_type=" << (preset.build_type.empty() ? "-" : preset.build_type)
|
||||
<< '\n';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct VerifyCmdOptions {
|
||||
std::optional<std::string> name_arg;
|
||||
std::optional<std::string> version_arg;
|
||||
@@ -2728,6 +2763,7 @@ int main(int argc, char **argv) {
|
||||
TokensCmdOptions tokens_opts;
|
||||
LockCmdOptions lock_opts;
|
||||
VerifyCmdOptions verify_opts;
|
||||
PresetsCmdOptions presets_opts;
|
||||
CompdbEntriesCmdOptions compdb_entries_opts;
|
||||
publish_opts.project_arg = cwd;
|
||||
BridgeCmdOptions bridge_opts;
|
||||
@@ -2934,6 +2970,16 @@ int main(int argc, char **argv) {
|
||||
verify_opts.trusted_key_files);
|
||||
add_log_flags(verify_cmd, false); // `-v` is `--version` on verify.
|
||||
|
||||
auto &presets_cmd = root.subcommand(
|
||||
"presets", "Import CMake configure presets (CMakePresets.json) as VBS equivalents");
|
||||
presets_cmd
|
||||
.option_default("--file", "-f", "CMakePresets.json path", presets_opts.file_arg,
|
||||
"CMakePresets.json")
|
||||
.option_default("--project", "-C", "Project root for ${sourceDir}",
|
||||
presets_opts.project_arg, cwd)
|
||||
.option("--name", "-n", "Print the VBS command for one preset", presets_opts.name_arg);
|
||||
add_log_flags(presets_cmd);
|
||||
|
||||
auto &lock_cmd = root.subcommand("lock", "Inspect the project's vbs.lock");
|
||||
auto &lock_show_cmd = lock_cmd.subcommand("show", "Print lockfile contexts and entries");
|
||||
lock_show_cmd.option_default("--project", "-C", "Project directory", lock_opts.project_arg,
|
||||
@@ -3404,6 +3450,9 @@ int main(int argc, char **argv) {
|
||||
if (cmd == "verify") {
|
||||
return execute_verify_command(verify_opts);
|
||||
}
|
||||
if (cmd == "presets") {
|
||||
return execute_presets_command(presets_opts);
|
||||
}
|
||||
if (cmd == "compdb-entries") {
|
||||
return execute_compdb_entries_command(compdb_entries_opts);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ check_process(0 "Usage: vbs releases yank " "" releases yank --help)
|
||||
check_process(2 "" "--registry, --name, and --version are required" releases yank)
|
||||
check_process(0 "Usage: vbs tokens list " "" tokens list --help)
|
||||
check_process(0 "Usage: vbs lock show " "" lock show --help)
|
||||
check_process(0 "Usage: vbs presets " "" presets --help)
|
||||
check_process(0 "Usage: vbs verify " "" verify --help)
|
||||
check_process(0 "Usage: vbs compdb-entries " "" compdb-entries --help)
|
||||
check_process(1 "" "no compilation database is published" compdb-entries --project
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <Void/Build.hpp>
|
||||
#include <Void/Build/BootstrapConfig.hpp>
|
||||
#include <Void/Build/Bridge/CMakeBridge.hpp>
|
||||
#include <Void/Build/Config/Presets.hpp>
|
||||
#include <Void/Build/Editor/CompDb.hpp>
|
||||
#include <Void/Build/Execution/Scheduler.hpp>
|
||||
#include <Void/Build/Graph/Graph.hpp>
|
||||
@@ -1061,6 +1062,61 @@ void build(Void::Build::Project &p) {
|
||||
}
|
||||
}
|
||||
|
||||
// === IDE/migration ecosystem: CMakePresets import ===
|
||||
VOID_TEST(FullV1Tests, cmake_presets_import_maps_inherits_and_cache) {
|
||||
Void::FileSystem::TempDir tmp{"vbs_presets_"};
|
||||
const auto presets_file = tmp / "CMakePresets.json";
|
||||
write_file(presets_file, R"json({
|
||||
"version": 3,
|
||||
"configurePresets": [
|
||||
{"name": "base", "hidden": true, "binaryDir": "${sourceDir}/out/base",
|
||||
"cacheVariables": {"CMAKE_BUILD_TYPE": "Debug"}},
|
||||
{"name": "release-clang", "inherits": ["base"],
|
||||
"cacheVariables": {"CMAKE_BUILD_TYPE": "Release", "CMAKE_CXX_COMPILER": "/usr/bin/clang++"},
|
||||
"generator": "Ninja"},
|
||||
{"name": "plain", "generator": "Unix Makefiles"}
|
||||
]
|
||||
})json");
|
||||
|
||||
auto presets = Config::load_cmake_presets(presets_file, tmp.path());
|
||||
Void::Testing::require(presets.has_value());
|
||||
Void::Testing::expect_eq(presets->size(), std::size_t{3});
|
||||
|
||||
const auto find = [&](std::string_view name) -> const Config::ImportedPreset * {
|
||||
for (const auto &preset : *presets) {
|
||||
if (preset.name == name) {
|
||||
return &preset;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
const auto *base = find("base");
|
||||
Void::Testing::require(base != nullptr);
|
||||
Void::Testing::expect_eq(base->profile, std::string{"debug"});
|
||||
Void::Testing::expect(base->build_dir.has_value());
|
||||
if (base->build_dir) {
|
||||
Void::Testing::expect(base->build_dir->ends_with("out/base"));
|
||||
Void::Testing::expect(base->build_dir->starts_with(tmp.path().string()));
|
||||
}
|
||||
|
||||
const auto *release = find("release-clang");
|
||||
Void::Testing::require(release != nullptr);
|
||||
Void::Testing::expect_eq(release->profile, std::string{"release"});
|
||||
Void::Testing::expect_eq(release->compiler, std::string{"clang"});
|
||||
Void::Testing::expect_eq(release->generator, std::string{"Ninja"});
|
||||
Void::Testing::expect(release->cache_variables.contains("CMAKE_BUILD_TYPE"));
|
||||
const auto command = Config::suggested_build_command(*release);
|
||||
Void::Testing::expect(command.find("--profile 'release'") != std::string::npos);
|
||||
Void::Testing::expect(command.find("--compiler 'clang'") != std::string::npos);
|
||||
Void::Testing::expect(command.find("--build-dir '") != std::string::npos);
|
||||
|
||||
const auto *plain = find("plain");
|
||||
Void::Testing::require(plain != nullptr);
|
||||
Void::Testing::expect_eq(plain->profile, std::string{"debug"});
|
||||
Void::Testing::expect_eq(plain->compiler, std::string{"gcc"});
|
||||
Void::Testing::expect(!plain->build_dir.has_value());
|
||||
}
|
||||
|
||||
// === Track C (Wine-first): cross-compile to Windows with MinGW-w64 and run tests under Wine ===
|
||||
VOID_TEST(FullV1Tests, track_c_windows_target_cross_build_and_wine_test) {
|
||||
const auto vbs_bin = locate_vbs_binary();
|
||||
|
||||
Reference in new issue
Block a user