Skip to content

Commit 56a88c4

Browse files
authored
Merge pull request #35 from build-cpp/toml-checker
Proper error messages for invalid keys/conditions
2 parents f02ccc2 + 6809e8d commit 56a88c4

File tree

5 files changed

+419
-283
lines changed

5 files changed

+419
-283
lines changed

cmake.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ link-libraries = [
3535
"ghc_filesystem",
3636
"mpark_variant",
3737
"ordered_map",
38-
"nlohmann_json"
38+
"nlohmann_json",
3939
]
4040
cmake-after = """
4141
generate_resources(${CMKR_TARGET})

src/build.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include "project_parser.hpp"
55

66
#include "fs.hpp"
7-
#include <sstream>
87
#include <cstddef>
9-
#include <stdexcept>
108
#include <cstdlib>
9+
#include <sstream>
10+
#include <stdexcept>
1111
#include <system_error>
1212

1313
namespace cmkr {

src/cmake_generator.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ int generate_project(const char *str) {
119119
const auto tomlbuf = format(cmake_toml, dir_name.c_str(), dir_name.c_str(), str, installed.c_str(), target.c_str(), dest.c_str());
120120

121121
if (strcmp(str, "interface")) {
122-
std::ofstream ofs("src/main.cpp");
122+
std::ofstream ofs("src/main.cpp", std::ios::binary);
123123
if (ofs.is_open()) {
124124
ofs << mainbuf;
125125
}
126126
ofs.flush();
127127
ofs.close();
128128
}
129129

130-
std::ofstream ofs2("cmake.toml");
130+
std::ofstream ofs2("cmake.toml", std::ios::binary);
131131
if (ofs2.is_open()) {
132132
ofs2 << tomlbuf;
133133
}
@@ -607,7 +607,7 @@ int generate_cmake(const char *path, const parser::Project *parent_project) {
607607
j["description"] = project.project_description;
608608
}
609609

610-
std::ofstream ofs("vcpkg.json");
610+
std::ofstream ofs("vcpkg.json", std::ios::binary);
611611
if (!ofs) {
612612
throw std::runtime_error("Failed to create a vcpkg.json manifest file!");
613613
}
@@ -900,7 +900,7 @@ int generate_cmake(const char *path, const parser::Project *parent_project) {
900900
if (!fs::exists(list_path))
901901
return true;
902902

903-
std::ifstream ifs(list_path, std::ios_base::binary);
903+
std::ifstream ifs(list_path, std::ios::binary);
904904
if (!ifs.is_open()) {
905905
throw std::runtime_error("Failed to read " + list_path.string());
906906
}
@@ -910,7 +910,7 @@ int generate_cmake(const char *path, const parser::Project *parent_project) {
910910
}();
911911

912912
if (should_regenerate) {
913-
std::ofstream ofs(list_path, std::ios_base::binary);
913+
std::ofstream ofs(list_path, std::ios::binary);
914914
if (ofs.is_open()) {
915915
ofs << ss.str();
916916
} else {

0 commit comments

Comments
 (0)