Some minor fixes related to newlines and formatting

toml-checker
Duncan Ogilvie 3 years ago
parent 09c9c28934
commit 77f4bf7da0

@ -35,7 +35,7 @@ link-libraries = [
"ghc_filesystem", "ghc_filesystem",
"mpark_variant", "mpark_variant",
"ordered_map", "ordered_map",
"nlohmann_json" "nlohmann_json",
] ]
cmake-after = """ cmake-after = """
generate_resources(${CMKR_TARGET}) generate_resources(${CMKR_TARGET})

@ -119,7 +119,7 @@ int generate_project(const char *str) {
const auto tomlbuf = format(cmake_toml, dir_name.c_str(), dir_name.c_str(), str, installed.c_str(), target.c_str(), dest.c_str()); const auto tomlbuf = format(cmake_toml, dir_name.c_str(), dir_name.c_str(), str, installed.c_str(), target.c_str(), dest.c_str());
if (strcmp(str, "interface")) { if (strcmp(str, "interface")) {
std::ofstream ofs("src/main.cpp"); std::ofstream ofs("src/main.cpp", std::ios::binary);
if (ofs.is_open()) { if (ofs.is_open()) {
ofs << mainbuf; ofs << mainbuf;
} }
@ -127,7 +127,7 @@ int generate_project(const char *str) {
ofs.close(); ofs.close();
} }
std::ofstream ofs2("cmake.toml"); std::ofstream ofs2("cmake.toml", std::ios::binary);
if (ofs2.is_open()) { if (ofs2.is_open()) {
ofs2 << tomlbuf; ofs2 << tomlbuf;
} }
@ -607,7 +607,7 @@ int generate_cmake(const char *path, const parser::Project *parent_project) {
j["description"] = project.project_description; j["description"] = project.project_description;
} }
std::ofstream ofs("vcpkg.json"); std::ofstream ofs("vcpkg.json", std::ios::binary);
if (!ofs) { if (!ofs) {
throw std::runtime_error("Failed to create a vcpkg.json manifest file!"); throw std::runtime_error("Failed to create a vcpkg.json manifest file!");
} }
@ -900,7 +900,7 @@ int generate_cmake(const char *path, const parser::Project *parent_project) {
if (!fs::exists(list_path)) if (!fs::exists(list_path))
return true; return true;
std::ifstream ifs(list_path, std::ios_base::binary); std::ifstream ifs(list_path, std::ios::binary);
if (!ifs.is_open()) { if (!ifs.is_open()) {
throw std::runtime_error("Failed to read " + list_path.string()); throw std::runtime_error("Failed to read " + list_path.string());
} }
@ -910,7 +910,7 @@ int generate_cmake(const char *path, const parser::Project *parent_project) {
}(); }();
if (should_regenerate) { if (should_regenerate) {
std::ofstream ofs(list_path, std::ios_base::binary); std::ofstream ofs(list_path, std::ios::binary);
if (ofs.is_open()) { if (ofs.is_open()) {
ofs << ss.str(); ofs << ss.str();
} else { } else {

@ -182,7 +182,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
for (const auto &itr : sets) { for (const auto &itr : sets) {
Setting s; Setting s;
s.name = itr.first; s.name = itr.first;
const auto& value = itr.second; const auto &value = itr.second;
if (value.is_boolean()) { if (value.is_boolean()) {
s.val = value.as_boolean(); s.val = value.as_boolean();
} else if (value.is_string()) { } else if (value.is_string()) {
@ -213,7 +213,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
for (const auto &itr : opts) { for (const auto &itr : opts) {
Option o; Option o;
o.name = itr.first; o.name = itr.first;
const auto& value = itr.second; const auto &value = itr.second;
if (value.is_boolean()) { if (value.is_boolean()) {
o.val = value.as_boolean(); o.val = value.as_boolean();
} else { } else {
@ -232,7 +232,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
for (const auto &itr : pkgs) { for (const auto &itr : pkgs) {
Package p; Package p;
p.name = itr.first; p.name = itr.first;
const auto& value = itr.second; const auto &value = itr.second;
if (itr.second.is_string()) { if (itr.second.is_string()) {
p.version = itr.second.as_string(); p.version = itr.second.as_string();
} else { } else {
@ -283,7 +283,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
const auto &ts = toml::find(toml, "target").as_table(); const auto &ts = toml::find(toml, "target").as_table();
for (const auto &itr : ts) { for (const auto &itr : ts) {
const auto& value = itr.second; const auto &value = itr.second;
Target target; Target target;
target.name = itr.first; target.name = itr.first;

Loading…
Cancel
Save