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
@@ -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