From 82342a6b6ff950ff6f9fee669e35f61fd702832c Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sat, 14 Jan 2023 15:51:57 +0100 Subject: [PATCH 1/4] Rename [settings] to [variables] --- src/project_parser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/project_parser.cpp b/src/project_parser.cpp index fdcaf18..ceb7a99 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -320,8 +320,12 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p } if (checker.contains("settings")) { + throw std::runtime_error(format_key_error("[settings] has been renamed to [variables]", "", toml.at("settings"))); + } + + if (checker.contains("variables")) { using set_map = tsl::ordered_map; - const auto &sets = toml::find(toml, "settings"); + const auto &sets = toml::find(toml, "variables"); for (const auto &itr : sets) { Setting s; s.name = itr.first; From 12ee23a44c9c6dede14c5c4e16ec840b8697c683 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sat, 14 Jan 2023 15:52:19 +0100 Subject: [PATCH 2/4] Improve error messages --- src/project_parser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/project_parser.cpp b/src/project_parser.cpp index ceb7a99..81731aa 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -219,7 +219,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p cmake.required("version", cmake_version); if (cmake.contains("bin-dir")) { - throw std::runtime_error("bin-dir has been renamed to build-dir"); + throw std::runtime_error(format_key_error("bin-dir has been renamed to build-dir", "bin-dir", cmake.find("bin-dir"))); } cmake.optional("build-dir", build_dir); @@ -473,7 +473,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p } if (checker.contains("bin")) { - throw std::runtime_error("[[bin]] has been renamed to [[target]]"); + throw std::runtime_error(format_key_error("[[bin]] has been renamed to [target.]", "", toml.at("bin"))); } auto parse_target = [&](const std::string &name, TomlChecker &t, bool isTemplate) { @@ -711,7 +711,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p package.features.emplace_back(feature); } } else { - throw std::runtime_error("Invalid vcpkg package '" + package_str + "'"); + throw std::runtime_error(format_key_error("Invalid package name '" + package_str + "'", "packages", p)); } vcpkg.packages.emplace_back(std::move(package)); } From 2c6fc569af56e9c0072dc64587ffe7afec0a514d Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sat, 14 Jan 2023 16:11:00 +0100 Subject: [PATCH 3/4] Preserve backwards compatibility --- include/project_parser.hpp | 4 +-- src/cmake_generator.cpp | 7 ++--- src/project_parser.cpp | 64 +++++++++++++++++++++++--------------- 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/include/project_parser.hpp b/include/project_parser.hpp index d504e98..1887029 100644 --- a/include/project_parser.hpp +++ b/include/project_parser.hpp @@ -14,7 +14,7 @@ using Condition = tsl::ordered_map; using ConditionVector = Condition>; -struct Setting { +struct Variable { std::string name; std::string comment; mpark::variant val; @@ -185,7 +185,7 @@ struct Project { Condition cmake_after; ConditionVector include_before; ConditionVector include_after; - std::vector settings; + std::vector variables; std::vector