summaryrefslogtreecommitdiffhomepage
path: root/src/NeBuildKit
diff options
context:
space:
mode:
Diffstat (limited to 'src/NeBuildKit')
-rw-r--r--src/NeBuildKit/JSONManifestBuilder.cpp10
-rw-r--r--src/NeBuildKit/TOMLManifestBuilder.cpp32
2 files changed, 24 insertions, 18 deletions
diff --git a/src/NeBuildKit/JSONManifestBuilder.cpp b/src/NeBuildKit/JSONManifestBuilder.cpp
index 0cc9fd3..b3db08f 100644
--- a/src/NeBuildKit/JSONManifestBuilder.cpp
+++ b/src/NeBuildKit/JSONManifestBuilder.cpp
@@ -28,8 +28,7 @@ bool JSONManifestBuilder::BuildTarget(BuildConfig& config) {
path = config.path_;
if (!FS::exists(path)) {
- NeBuild::Logger::info() << "error: file '" << path << "' does not exist"
- << std::endl;
+ NeBuild::Logger::info() << "error: file '" << path << "' does not exist" << std::endl;
return false;
}
}
@@ -38,8 +37,8 @@ bool JSONManifestBuilder::BuildTarget(BuildConfig& config) {
std::ifstream json(path);
if (!json.good()) {
- NeBuild::Logger::info() << "error: file '" << path
- << "' is not a valid nlohmann::json" << std::endl;
+ NeBuild::Logger::info() << "error: file '" << path << "' is not a valid nlohmann::json"
+ << std::endl;
return false;
}
@@ -52,7 +51,8 @@ bool JSONManifestBuilder::BuildTarget(BuildConfig& config) {
if (auto res = description.get<std::string>(); !res.empty())
NeBuild::Logger::info() << "description: " << res << std::endl;
- } catch (...) {}
+ } catch (...) {
+ }
std::string compiler = json_obj["compiler_path"].get<std::string>();
diff --git a/src/NeBuildKit/TOMLManifestBuilder.cpp b/src/NeBuildKit/TOMLManifestBuilder.cpp
index cce9384..d7cb585 100644
--- a/src/NeBuildKit/TOMLManifestBuilder.cpp
+++ b/src/NeBuildKit/TOMLManifestBuilder.cpp
@@ -28,30 +28,36 @@ bool TOMLManifestBuilder::BuildTarget(BuildConfig& config) {
path = config.path_;
if (!FS::exists(path)) {
- NeBuild::Logger::info() << "error: file '" << path << "' does not exist"
- << std::endl;
+ NeBuild::Logger::info() << "error: file '" << path << "' does not exist" << std::endl;
return false;
}
}
-
+
try {
auto toml_file = toml::parse_file(path);
try {
- auto* description = toml_file["description"].as_string();
-
+ auto* description = toml_file["description"].as_string();
+
+ if (!description) throw std::runtime_error({});
+
NeBuild::Logger::info() << "package path: " << path << std::endl;
-
- if (description) NeBuild::Logger::info() << "description: " << description->get() << std::endl;
+
+ if (description)
+ NeBuild::Logger::info() << "description: " << description->get() << std::endl;
} catch (...) {
- // ...
}
-
- std::string compiler = toml_file["compiler_path"].as_string()->get();
- std::string command = compiler + " ";
+ auto* compiler_path_ptr = toml_file["compiler_path"].as_string();
+ if (!compiler_path_ptr) return false;
+
+ std::string compiler = compiler_path_ptr->get();
+ std::string command = compiler + " ";
- auto header_search_path = toml_file["compiler_headers_path"].as_array();
+ auto* header_search_path_ptr = toml_file["compiler_headers_path"].as_array();
+ if (!header_search_path_ptr) return false;
+
+ auto header_search_path = header_search_path_ptr;
if (header_search_path) {
for (auto& headers : *header_search_path) {
@@ -126,5 +132,5 @@ bool TOMLManifestBuilder::BuildTarget(BuildConfig& config) {
const std::string_view TOMLManifestBuilder::BuildSystem() {
return "NeBuild (toml++::toml)";
}
-
+
} // namespace NeBuild