From 77f4bf7da0ddda3daacb54ab3424dfbde75c9738 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Wed, 22 Dec 2021 13:30:59 +0100 Subject: [PATCH] Some minor fixes related to newlines and formatting --- cmake.toml | 2 +- src/cmake_generator.cpp | 10 +++++----- src/project_parser.cpp | 8 ++++---- tests/vcpkg/vcpkg.json | 22 +++++++++++----------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cmake.toml b/cmake.toml index be3e694..f7520fa 100644 --- a/cmake.toml +++ b/cmake.toml @@ -35,7 +35,7 @@ link-libraries = [ "ghc_filesystem", "mpark_variant", "ordered_map", - "nlohmann_json" + "nlohmann_json", ] cmake-after = """ generate_resources(${CMKR_TARGET}) diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index c6975ee..d9c9cc2 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -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()); if (strcmp(str, "interface")) { - std::ofstream ofs("src/main.cpp"); + std::ofstream ofs("src/main.cpp", std::ios::binary); if (ofs.is_open()) { ofs << mainbuf; } @@ -127,7 +127,7 @@ int generate_project(const char *str) { ofs.close(); } - std::ofstream ofs2("cmake.toml"); + std::ofstream ofs2("cmake.toml", std::ios::binary); if (ofs2.is_open()) { ofs2 << tomlbuf; } @@ -607,7 +607,7 @@ int generate_cmake(const char *path, const parser::Project *parent_project) { j["description"] = project.project_description; } - std::ofstream ofs("vcpkg.json"); + std::ofstream ofs("vcpkg.json", std::ios::binary); if (!ofs) { 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)) return true; - std::ifstream ifs(list_path, std::ios_base::binary); + std::ifstream ifs(list_path, std::ios::binary); if (!ifs.is_open()) { 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) { - std::ofstream ofs(list_path, std::ios_base::binary); + std::ofstream ofs(list_path, std::ios::binary); if (ofs.is_open()) { ofs << ss.str(); } else { diff --git a/src/project_parser.cpp b/src/project_parser.cpp index cb24558..2941010 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -182,7 +182,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) { for (const auto &itr : sets) { Setting s; s.name = itr.first; - const auto& value = itr.second; + const auto &value = itr.second; if (value.is_boolean()) { s.val = value.as_boolean(); } 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) { Option o; o.name = itr.first; - const auto& value = itr.second; + const auto &value = itr.second; if (value.is_boolean()) { o.val = value.as_boolean(); } else { @@ -232,7 +232,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) { for (const auto &itr : pkgs) { Package p; p.name = itr.first; - const auto& value = itr.second; + const auto &value = itr.second; if (itr.second.is_string()) { p.version = itr.second.as_string(); } 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(); for (const auto &itr : ts) { - const auto& value = itr.second; + const auto &value = itr.second; Target target; target.name = itr.first; diff --git a/tests/vcpkg/vcpkg.json b/tests/vcpkg/vcpkg.json index ec00969..8c0008a 100644 --- a/tests/vcpkg/vcpkg.json +++ b/tests/vcpkg/vcpkg.json @@ -1,11 +1,11 @@ -{ - "$cmkr": "This file is automatically generated from cmake.toml - DO NOT EDIT", - "$cmkr-url": "https://github.com/build-cpp/cmkr", - "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", - "dependencies": [ - "fmt" - ], - "description": "Dependencies from vcpkg", - "name": "vcpkg", - "version-string": "" -} +{ + "$cmkr": "This file is automatically generated from cmake.toml - DO NOT EDIT", + "$cmkr-url": "https://github.com/build-cpp/cmkr", + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", + "dependencies": [ + "fmt" + ], + "description": "Dependencies from vcpkg", + "name": "vcpkg", + "version-string": "" +}