void generate_export(const build_params& params, | void generate_export(const build_params& params, | ||||
fs::path archive_file, | fs::path archive_file, | ||||
const source_list& sources) { | const source_list& sources) { | ||||
const auto export_root = params.out_root / (params.export_name + ".export-root"); | |||||
const auto export_root = params.out_root / fmt::format("{}.export-root", params.export_name); | |||||
spdlog::info("Generating library export: {}", export_root.string()); | spdlog::info("Generating library export: {}", export_root.string()); | ||||
fs::remove_all(export_root); | fs::remove_all(export_root); | ||||
fs::create_directories(export_root); | fs::create_directories(export_root); | ||||
archive_spec arc; | archive_spec arc; | ||||
arc.input_files = compile_sources(sources, params, man); | arc.input_files = compile_sources(sources, params, man); | ||||
arc.out_path | |||||
= params.out_root / ("lib" + params.export_name + params.toolchain.archive_suffix()); | |||||
arc.out_path = params.out_root | |||||
/ (fmt::format("lib{}{}", params.export_name, params.toolchain.archive_suffix())); | |||||
spdlog::info("Create archive {}", arc.out_path.string()); | spdlog::info("Create archive {}", arc.out_path.string()); | ||||
auto ar_cmd = params.toolchain.create_archive_command(arc); | auto ar_cmd = params.toolchain.create_archive_command(arc); |
#include <dds/util.hpp> | #include <dds/util.hpp> | ||||
#include <spdlog/fmt/fmt.h> | |||||
#include <cctype> | #include <cctype> | ||||
#include <fstream> | #include <fstream> | ||||
while (true) { | while (true) { | ||||
if (iter == end) { | if (iter == end) { | ||||
throw std::runtime_error("Invalid line in config file: '"s + std::string(whole_line) | |||||
+ "'"); | |||||
throw std::runtime_error(fmt::format("Invalid line in config file: '{}'", whole_line)); | |||||
} | } | ||||
if (*iter == ':') { | if (*iter == ':') { | ||||
if (++iter == end) { | if (++iter == end) { |
#include <dds/lm_parse.hpp> | #include <dds/lm_parse.hpp> | ||||
#include <spdlog/fmt/fmt.h> | |||||
using namespace dds; | using namespace dds; | ||||
library_manifest library_manifest::load_from_file(const fs::path& fpath) { | library_manifest library_manifest::load_from_file(const fs::path& fpath) { | ||||
} else if (pair.key() == "Private-Defines") { | } else if (pair.key() == "Private-Defines") { | ||||
ret.private_defines.emplace_back(pair.value()); | ret.private_defines.emplace_back(pair.value()); | ||||
} else { | } else { | ||||
throw std::runtime_error("Unknown key in " + fpath.string() + ": " + pair.key()); | |||||
throw std::runtime_error( | |||||
fmt::format("Unknown key in file '{}': {}", fpath.string(), pair.key())); | |||||
} | } | ||||
} | } | ||||
return ret; | return ret; |
auto require_key = [](auto k, auto& opt) { | auto require_key = [](auto k, auto& opt) { | ||||
if (!opt.has_value()) { | if (!opt.has_value()) { | ||||
throw invalid_toolchain("Toolchain file is missing a required key: " + string(k)); | |||||
throw invalid_toolchain( | |||||
fmt::format("Toolchain file is missing a required key '{}'", k)); | |||||
} | } | ||||
}; | }; | ||||
auto try_single = [&](auto k, auto& opt) { | auto try_single = [&](auto k, auto& opt) { | ||||
if (key == k) { | if (key == k) { | ||||
if (opt.has_value()) { | if (opt.has_value()) { | ||||
throw invalid_toolchain("Duplicate key: " + key); | |||||
throw invalid_toolchain(fmt::format("Duplicated key '{}'", key)); | |||||
} | } | ||||
opt = value; | opt = value; | ||||
return true; | return true; | ||||
// clang-format on | // clang-format on | ||||
if (!found_single) { | if (!found_single) { | ||||
throw invalid_toolchain("Unknown toolchain file key: " + key); | |||||
throw invalid_toolchain(fmt::format("Unknown toolchain file key '{}'", key)); | |||||
} | } | ||||
} | } | ||||