283 ? boost::log::trivial::info
284 : boost::log::trivial::warning );
293 po::options_description
generic(
"Generic options" );
294 generic.add_options()(
"help,h",
"produce this help message" )(
295 "package-name,p", po::value<string>(),
"name of the package for which we create the configurables file" )(
296 "input-libraries,i", po::value<string>(),
"libraries to extract the component configurables from" )(
297 "input-cfg,c", po::value<string>(),
298 "path to the cfg file holding the description of the Configurable base "
299 "classes, the python module holding the Configurable definitions, etc..." )(
300 "output-dir,o", po::value<string>()->default_value(
"../genConfDir" ),
301 "output directory for genconf files." )(
"debug-level,d", po::value<int>()->default_value( 0 ),
"debug level" )(
302 "load-library,l", po::value<Strings_t>()->composing(),
"preloading library" )(
303 "user-module,m", po::value<string>(),
"user-defined module to be imported by the genConf-generated one" )(
304 "no-init",
"do not generate the (empty) __init__.py" )(
305 "type", po::value<string>()->default_value(
"conf,conf2" ),
"comma-separate types of configurables to generate" );
309 po::options_description
config(
"Configuration" );
310 config.add_options()(
"configurable-module", po::value<string>()->default_value(
"AthenaCommon" ),
311 "Name of the module holding the configurable classes" )(
312 "configurable-default-name", po::value<string>()->default_value(
"Configurable.DefaultName" ),
313 "Default name for the configurable instance" )(
"configurable-algorithm",
314 po::value<string>()->default_value(
"ConfigurableAlgorithm" ),
315 "Name of the configurable base class for Algorithm components" )(
316 "configurable-algtool", po::value<string>()->default_value(
"ConfigurableAlgTool" ),
317 "Name of the configurable base class for AlgTool components" )(
318 "configurable-auditor", po::value<string>()->default_value(
"ConfigurableAuditor" ),
319 "Name of the configurable base class for Auditor components" )(
320 "configurable-service", po::value<string>()->default_value(
"ConfigurableService" ),
321 "Name of the configurable base class for Service components" );
323 po::options_description cmdline_options;
324 cmdline_options.add(
generic ).add(
config );
326 po::options_description config_file_options;
327 config_file_options.add(
config );
329 po::options_description visible(
"Allowed options" );
330 visible.add(
generic ).add(
config );
332 po::variables_map vm;
335 po::store( po::command_line_parser(
argc,
argv ).
options( cmdline_options ).run(), vm );
340 if ( vm.contains(
"input-cfg" ) ) {
341 string cfgFileName = vm[
"input-cfg"].as<
string>();
342 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).
string();
344 po::store( parse_config_file( ifs, config_file_options ), vm );
348 }
catch ( po::error& err ) {
349 LOG_ERROR <<
"error detected while parsing command options: " << err.what();
354 if ( vm.contains(
"help" ) ) {
359 if ( vm.contains(
"package-name" ) ) {
360 pkgName = vm[
"package-name"].as<
string>();
367 if ( vm.contains(
"user-module" ) ) {
368 userModule = vm[
"user-module"].as<
string>();
369 LOG_INFO <<
"INFO: will import user module " << userModule;
372 if ( vm.contains(
"input-libraries" ) ) {
378 boost::split( libs, tmp, boost::is_any_of(
" " ), boost::token_compress_on );
380 LOG_ERROR <<
"input component library(ies) required";
385 if ( vm.contains(
"output-dir" ) ) {
out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) ); }
389 if ( vm.contains(
"load-library" ) ) {
390 for (
const auto& lLib : vm[
"load-library"].as<Strings_t>() ) {
394 if ( err != 1 )
LOG_WARNING <<
"failed to load: " << lLib;
399 if ( vm.contains(
"type" ) ) {
401 if (
type ==
"conf" ) {
402 confTypes.
insert( conf_t::CONF );
403 }
else if (
type ==
"conf2" ) {
404 confTypes.
insert( conf_t::CONF2 );
413 if ( !fs::exists(
out ) ) {
415 fs::create_directory(
out );
416 }
catch ( fs::filesystem_error& err ) {
417 LOG_ERROR <<
"error creating directory: " << err.what();
424 msg <<
":::::: libraries : [ ";
431 py.setConfigurableModule( vm[
"configurable-module"].as<string>() );
432 py.setConfigurableTypes( confTypes );
433 py.setConfigurableDefaultName( vm[
"configurable-default-name"].as<string>() );
434 py.setConfigurableAlgorithm( vm[
"configurable-algorithm"].as<string>() );
435 py.setConfigurableAlgTool( vm[
"configurable-algtool"].as<string>() );
436 py.setConfigurableAuditor( vm[
"configurable-auditor"].as<string>() );
437 py.setConfigurableService( vm[
"configurable-service"].as<string>() );
439 int sc = EXIT_FAILURE;
441 sc = py.genConfig( libs, userModule );
443 cout <<
"ERROR: Could not generate Configurable(s) !\n"
444 <<
"ERROR: Got exception: " << e.
what() <<
endl;
448 if ( EXIT_SUCCESS == sc && !vm.contains(
"no-init" ) ) {
451 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" <<
flush;
456 msg <<
":::::: libraries : [ ";
458 msg <<
"] :::::: [DONE]";