Skip to content
Snippets Groups Projects
Commit c1092587 authored by Zuzana Baranová's avatar Zuzana Baranová
Browse files

CC: Move construction of PairedFiles into Native.

parent eb78ef2e
No related branches found
No related tags found
No related merge requests found
......@@ -102,6 +102,38 @@ namespace divine::cc
return cc::link_bitcode< cc::Driver, false >( _files, _clang, _po.libSearchPath );
}
void Native::construct_paired_files()
{
using namespace brick::fs;
for ( auto srcFile : _po.files )
{
if ( srcFile.is< cc::File >() )
{
std::string ifn = srcFile.get< cc::File >().name;
std::string ofn = dropExtension( ifn );
ofn = splitFileName( ofn ).second;
if ( _po.outputFile != "" && _po.toObjectOnly )
ofn = _po.outputFile;
else
{
if ( !_po.toObjectOnly )
ofn += ".divcc.temp";
ofn += ".o";
}
if ( cc::is_object_type( ifn ) )
ofn = ifn;
_files.emplace_back( ifn, ofn );
}
else
{
assert( srcFile.is< cc::Lib >() );
_files.emplace_back( "lib", srcFile.get< cc::Lib >().name );
}
}
}
Native::~Native()
{
if ( !_po.toObjectOnly )
......
......@@ -38,6 +38,7 @@ namespace divine::cc
void init_ld_args();
void link();
virtual std::unique_ptr< llvm::Module > link_bitcode();
void construct_paired_files();
cc::ParsedOpts _po;
PairedFiles _files;
......
......@@ -50,10 +50,6 @@ int main( int argc, char **argv )
rt::NativeDiosCC nativeCC( { argv + 1, argv + argc } );
cc::CC1& clang = nativeCC._clang;
auto& po = nativeCC._po;
auto& pairedFiles = nativeCC._files;
using namespace brick::fs;
// count files, i.e. not libraries
auto num_files = std::count_if( po.files.begin(), po.files.end(),
......@@ -89,32 +85,7 @@ int main( int argc, char **argv )
return 0;
}
for ( auto srcFile : po.files )
{
if ( srcFile.is< cc::File >() )
{
std::string ifn = srcFile.get< cc::File >().name;
std::string ofn = dropExtension( ifn );
ofn = splitFileName( ofn ).second;
if ( po.outputFile != "" && po.toObjectOnly )
ofn = po.outputFile;
else
{
if ( !po.toObjectOnly )
ofn += ".divcc.temp";
ofn += ".o";
}
if ( cc::is_object_type( ifn ) )
ofn = ifn;
pairedFiles.emplace_back( ifn, ofn );
}
else
{
assert( srcFile.is< cc::Lib >() );
pairedFiles.emplace_back( "lib", srcFile.get< cc::Lib >().name );
}
}
nativeCC.construct_paired_files();
if ( po.toObjectOnly )
return nativeCC.compile_files();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment