Return EXIT_FAILURE if one of the compilation units failed

This commit is contained in:
Username404-59 2021-10-08 17:27:05 +02:00
parent a2b67298a4
commit 2458c7bb6c
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 7 additions and 4 deletions

View File

@ -38,6 +38,7 @@ int main(int argc, char* argv[]) {
outputFileContent(outputFile, transpiledString);
return transpiledString;
};
int8_t exit_code = EXIT_SUCCESS;
if (!files.empty()) {
vector<future<pair<string, optional<Yerbacon::Exception>>>> Units(files.size());
const launch& Policy = not parallel ? launch::deferred : launch::async;
@ -66,14 +67,16 @@ int main(int argc, char* argv[]) {
});
});
if (printResult) cout << "~~~~[Yerbacon compilation result]~~~~\n\n";
for_each(Units.begin(), Units.end(), [&printResult](future<pair<string, optional<Yerbacon::Exception>>>& currentFuture) {
exit_code = none_of(Units.rbegin(), Units.rend(), [&printResult](future<pair<string, optional<Yerbacon::Exception>>>& currentFuture) -> bool {
const auto&& result = currentFuture.get();
if (not result.second.has_value()) {
const bool is_exception = result.second.has_value();
if (not is_exception) {
if (printResult) cout << result.first << '\n';
} else {
cout << "Compilation of " << result.first << " has failed with the following error:\n" << result.second.value().what() << '\n';
}
});
return is_exception;
}) ? EXIT_SUCCESS : EXIT_FAILURE;
} else cout << "No valid file provided.\n";
return EXIT_SUCCESS;
return exit_code;
}