Skip to content

Commit

Permalink
minicargo - Fix infinite printing in build script error reporting if …
Browse files Browse the repository at this point in the history
…an over-long line is hit.
  • Loading branch information
thepowersgang committed Feb 23, 2019
1 parent a7868c9 commit a2f952b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tools/minicargo/build.cpp
Expand Up @@ -794,6 +794,10 @@ ::helpers::path Builder::build_build_script(const PackageManifest& manifest, boo
args.push_back("--crate-type"); args.push_back("bin");
args.push_back("-o"); args.push_back(outfile);
args.push_back("-L"); args.push_back(this->get_output_dir(true).str()); // NOTE: Forces `is_for_host` to true here.
if( true )
{
args.push_back("-g");
}
for(const auto& d : m_opts.lib_search_dirs)
{
args.push_back("-L");
Expand Down Expand Up @@ -893,22 +897,24 @@ ::helpers::path Builder::build_and_run_script(const PackageManifest& manifest, b
//auto _ = ScopedChdir { manifest.directory() };
if( !this->spawn_process(script_exe_abs.str().c_str(), {}, env, out_file, /*working_directory=*/manifest.directory()) )
{
auto failed_filename = out_file+"_failed.txt";
remove(failed_filename.str().c_str());
rename(out_file.str().c_str(), failed_filename.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() )
::std::ifstream ifs(failed_filename);
char linebuf[1024];
while( ifs.good() && !ifs.eof() )
{
ifs.getline(linebuf, sizeof(linebuf)-1);
if( strncmp(linebuf, "cargo:", 6) == 0 ) {
continue;
}
::std::cerr << linebuf << ::std::endl;
::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();
}
Expand Down

0 comments on commit a2f952b

Please sign in to comment.