Bladeren bron

Use libfmt for building strings

default_compile_flags
vector-of-bool 5 jaren geleden
bovenliggende
commit
83e7841bc9
4 gewijzigde bestanden met toevoegingen van 14 en 9 verwijderingen
  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 Bestand weergeven

@@ -163,7 +163,7 @@ void copy_headers(const fs::path& source, const fs::path& dest, const source_lis
void generate_export(const build_params& params,
fs::path archive_file,
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());
fs::remove_all(export_root);
fs::create_directories(export_root);
@@ -296,8 +296,8 @@ void dds::build(const build_params& params, const library_manifest& man) {
archive_spec arc;
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());
auto ar_cmd = params.toolchain.create_archive_command(arc);

+ 3
- 2
src/dds/lm_parse.cpp Bestand weergeven

@@ -2,6 +2,8 @@

#include <dds/util.hpp>

#include <spdlog/fmt/fmt.h>

#include <cctype>
#include <fstream>

@@ -44,8 +46,7 @@ void parse_line(std::vector<lm_pair>& pairs, const std::string_view whole_line)

while (true) {
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 == end) {

+ 4
- 1
src/dds/manifest.cpp Bestand weergeven

@@ -2,6 +2,8 @@

#include <dds/lm_parse.hpp>

#include <spdlog/fmt/fmt.h>

using namespace dds;

library_manifest library_manifest::load_from_file(const fs::path& fpath) {
@@ -13,7 +15,8 @@ library_manifest library_manifest::load_from_file(const fs::path& fpath) {
} else if (pair.key() == "Private-Defines") {
ret.private_defines.emplace_back(pair.value());
} 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;

+ 4
- 3
src/dds/toolchain.cpp Bestand weergeven

@@ -38,7 +38,8 @@ toolchain toolchain::load_from_file(fs::path p) {

auto require_key = [](auto k, auto& opt) {
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));
}
};

@@ -50,7 +51,7 @@ toolchain toolchain::load_from_file(fs::path p) {
auto try_single = [&](auto k, auto& opt) {
if (key == k) {
if (opt.has_value()) {
throw invalid_toolchain("Duplicate key: " + key);
throw invalid_toolchain(fmt::format("Duplicated key '{}'", key));
}
opt = value;
return true;
@@ -74,7 +75,7 @@ toolchain toolchain::load_from_file(fs::path p) {
// clang-format on

if (!found_single) {
throw invalid_toolchain("Unknown toolchain file key: " + key);
throw invalid_toolchain(fmt::format("Unknown toolchain file key '{}'", key));
}
}


Laden…
Annuleren
Opslaan