int main( int argc, char* argv[] )
{
// Get inputs
- if( argc < 5 )
+ if( argc < 4 )
{
std::cerr
<< "Usage: " << argv[ 0 ]
- << " definitons_file library_name output_path number_of_sources"
+ << " definitons_file library_name output_prefix"
<< std::endl;
return( 1 );
} // fi
std::string definitions_filename = argv[ 1 ];
std::string library_name = argv[ 2 ];
- std::string output_path = argv[ 3 ];
- unsigned int number_of_sources = std::atoi( argv[ 4 ] );
+ std::string output_prefix = argv[ 3 ];
+ unsigned int number_of_sources = cpPlugins_CONFIG_NUMBER_OF_FILES;
// Read inputs
std::string definitions_buffer;
if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) )
{
- std::cout
+ std::cerr
<< argv[ 0 ]
<< ": Error reading definitions file \"" << definitions_filename
<< "\"" << std::endl;
} // rof
- // Prepare header file
- std::stringstream header;
- header
- << "// Automaticaly generated file. Please do not modify." << std::endl
- << "#ifndef __" << library_name << "__h__" << std::endl
- << "#define __" << library_name << "__h__" << std::endl << std::endl;
-
- auto hIt = commands.find( "header" );
- if( hIt != commands.end( ) )
- {
- for( auto vIt = hIt->second.begin( ); vIt != hIt->second.end( ); ++vIt )
- header << *vIt << std::endl;
- header << std::endl;
-
- } // fi
-
- if( tfiles.size( ) > 0 )
- {
- for( auto tIt = tfiles.begin( ); tIt != tfiles.end( ); ++tIt )
- {
- TStrings toks;
- cpPlugins_bash::Tokenize( toks, *tIt, ":|" );
- if( toks.size( ) == 3 )
- header
- << "#include <" << toks[ 0 ] << "." << toks[ 1 ] << ">" << std::endl;
-
- } // rof
- header << std::endl;
-
- } // fi
- header << "#endif // __" << library_name << "__h__" << std::endl;
-
- // Write header
- std::stringstream header_filename;
- header_filename << output_path << "/" << library_name << ".h";
- if( !( cpPlugins_bash::Write( header.str( ), header_filename.str( ) ) ) )
- {
- std::cerr << "Error writing header file." << std::endl;
- return( 1 );
-
- } // fi
-
// Write source code
unsigned int instances_per_file =
( unsigned int )(
source
<< "#include <" << library_name << "_Export.h>"
<< std::endl;
- source
- << "#include <" << output_path<< "/" << library_name << ".h>"
- << std::endl << std::endl;
+ auto hIt = commands.find( "header" );
+ if( hIt != commands.end( ) )
+ {
+ source << std::endl;
+ for( auto vIt = hIt->second.begin( ); vIt != hIt->second.end( ); ++vIt )
+ source << *vIt << std::endl;
+ source << std::endl;
+
+ } // fi
+
if( tfiles.size( ) > 0 )
{
for( auto tIt = tfiles.begin( ); tIt != tfiles.end( ); ++tIt )
TStrings toks;
cpPlugins_bash::Tokenize( toks, *tIt, ":|" );
if( toks.size( ) == 3 )
+ {
+ source << "#include <" << toks[ 0 ] << "." << toks[ 1 ] << ">" << std::endl;
source << "#include <" << toks[ 0 ] << "." << toks[ 2 ] << ">" << std::endl;
+ } // fi
+
} // rof
source << std::endl;
source << std::endl << "// eof" << std::endl;
std::stringstream source_file;
source_file
- << output_path << "/" << library_name << "_" << f_id << ".cxx";
+ << output_prefix << "_" << f_id << ".cxx";
if( !( cpPlugins_bash::Write( source.str( ), source_file.str( ) ) ) )
{
std::cerr << "Error writing source code." << std::endl;