Return EXIT_FAILURE if one of the compilation units failed
This commit is contained in:
		
							parent
							
								
									a2b67298a4
								
							
						
					
					
						commit
						2458c7bb6c
					
				
							
								
								
									
										11
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.cpp
									
									
									
									
									
								
							| @ -38,6 +38,7 @@ int main(int argc, char* argv[]) { | |||||||
|         outputFileContent(outputFile, transpiledString); |         outputFileContent(outputFile, transpiledString); | ||||||
|         return transpiledString; |         return transpiledString; | ||||||
|     }; |     }; | ||||||
|  |     int8_t exit_code = EXIT_SUCCESS; | ||||||
|     if (!files.empty()) { |     if (!files.empty()) { | ||||||
|         vector<future<pair<string, optional<Yerbacon::Exception>>>> Units(files.size()); |         vector<future<pair<string, optional<Yerbacon::Exception>>>> Units(files.size()); | ||||||
|         const launch& Policy = not parallel ? launch::deferred : launch::async; |         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"; |         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(); |             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'; |                 if (printResult) cout << result.first << '\n'; | ||||||
|             } else { |             } else { | ||||||
|                 cout << "Compilation of " << result.first << " has failed with the following error:\n" << result.second.value().what() << '\n'; |                 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"; |     } else cout << "No valid file provided.\n"; | ||||||
|     return EXIT_SUCCESS; |     return exit_code; | ||||||
| } | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user