diff options
author | John Hodge <tpg@mutabah.net> | 2019-02-23 12:33:15 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2019-02-23 12:33:15 +0800 |
commit | 80c2add7b04e6e202d9a4f3b3c25ec498e3b5893 (patch) | |
tree | bf853a8317362118a21116b8478a77635e639a87 | |
parent | f893005e2b0a207826d56782afcd456754adb643 (diff) | |
download | mrust-80c2add7b04e6e202d9a4f3b3c25ec498e3b5893.tar.gz |
minicargo - Improved error reporting for failed build scripts
-rw-r--r-- | tools/minicargo/build.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp index 35c64f3b..6d586893 100644 --- a/tools/minicargo/build.cpp +++ b/tools/minicargo/build.cpp @@ -30,6 +30,7 @@ extern int _putenv_s(const char*, const char*); # include <mutex> # include <condition_variable> #endif +#include <fstream> #include <climits> #include <cassert> #ifdef _WIN32 @@ -889,9 +890,24 @@ bool Builder::build_target(const PackageManifest& manifest, const PackageTarget& #endif if( !this->spawn_process(script_exe_abs.str().c_str(), {}, env, out_file) ) { - rename(out_file.str().c_str(), (out_file+"_failed").str().c_str()); + ::std::cerr << "Calling " << script_exe_abs << " failed" << ::std::endl; + { + ::std::ifstream ifs(out_file); + char linebuf[512]; + while( !ifs.getline(linebuf, sizeof(linebuf)-1).eof() ) + { + if( strncmp(linebuf, "cargo:", 6) == 0 ) { + continue; + } + ::std::cerr << linebuf << ::std::endl; + } + } + + auto failed_filename = out_file+"_failed.txt"; + remove(failed_filename.str().c_str()); + rename(out_file.str().c_str(), failed_filename.str().c_str()); // Build failed, return an invalid path - return ::helpers::path();; + return ::helpers::path(); } #if _WIN32 #else @@ -993,7 +1009,7 @@ bool Builder::spawn_process(const char* exe_name, const StringList& args, const GetExitCodeProcess(pi.hProcess, &status); if (status != 0) { - DEBUG("Compiler exited with non-zero exit status " << status); + DEBUG("Process exited with non-zero exit status " << status); return false; } #else |