Browse Source

Use libfmt for building strings

default_compile_flags
vector-of-bool 5 years ago
parent
commit
83e7841bc9
4 changed files with 14 additions and 9 deletions
  1. +3
    -3
      src/dds/build.cpp
  2. +3
    -2
      src/dds/lm_parse.cpp
  3. +4
    -1
      src/dds/manifest.cpp
  4. +4
    -3
      src/dds/toolchain.cpp

+ 3
- 3
src/dds/build.cpp View File

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);

+ 3
- 2
src/dds/lm_parse.cpp View File



#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) {

+ 4
- 1
src/dds/manifest.cpp View File



#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;

+ 4
- 3
src/dds/toolchain.cpp View File



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));
} }
} }



Loading…
Cancel
Save