feat(libconfig): new version of libconfig

This commit is contained in:
2025-12-06 11:41:57 -05:00
parent 7242c765f3
commit b6f452e74c
18 changed files with 118 additions and 21 deletions

View File

@@ -0,0 +1,48 @@
#include "fourdst/config/config.h"
#include "gridfire/config/config.h"
#include <source_location>
#include <filesystem>
#include "CLI/CLI.hpp"
consteval std::string_view strip_namespaces(const std::string_view fullName) {
const size_t pos = fullName.rfind("::");
if (pos == std::string_view::npos) {
return fullName;
}
return fullName.substr(pos + 2);
}
template <typename T>
consteval std::string_view get_type_name() {
constexpr std::string_view name = std::source_location::current().function_name();
const auto pos = name.find("T = ");
if (pos == std::string_view::npos) return name;
const auto start = pos + 4;
const auto end = name.rfind(']');
return name.substr(start, end - start);
}
int main(int argc, char** argv) {
CLI::App app{"GridFire Sandbox Application."};
std::string outputPath = ".";
app.add_option("-p,--path", outputPath, "path to save generated config files (default: current directory)");
CLI11_PARSE(app, argc, argv);
const std::filesystem::path outPath(outputPath);
if (!std::filesystem::exists(outPath)) {
std::cerr << "Error: The specified path does not exist: " << outputPath << std::endl;
return 1;
}
fourdst::config::Config<gridfire::config::GridFireConfig> configConfig;
const std::string_view name = strip_namespaces(get_type_name<gridfire::config::GridFireConfig>());
const std::string defaultConfigFilePath = (outPath / (std::string(name) + ".toml")).string();
const std::string schemaFilePath = (outPath / (std::string(name) + ".schema.json")).string();
configConfig.save(defaultConfigFilePath);
configConfig.save_schema(schemaFilePath);
}

1
tools/config/meson.build Normal file
View File

@@ -0,0 +1 @@
executable('gf_generate_config_file', 'generate_config_files.cpp', dependencies: [gridfire_dep, cli11_dep], install: true)

3
tools/meson.build Normal file
View File

@@ -0,0 +1,3 @@
if get_option('build_tools')
subdir('config')
endif