276 ? boost::log::trivial::info
277 : boost::log::trivial::warning );
286 po::options_description
generic(
"Generic options" );
287 generic.add_options()(
"help,h",
"produce this help message" )(
288 "package-name,p", po::value<string>(),
"name of the package for which we create the configurables file" )(
289 "input-libraries,i", po::value<string>(),
"libraries to extract the component configurables from" )(
290 "input-cfg,c", po::value<string>(),
291 "path to the cfg file holding the description of the Configurable base "
292 "classes, the python module holding the Configurable definitions, etc..." )(
293 "output-dir,o", po::value<string>()->default_value(
"../genConfDir" ),
294 "output directory for genconf files." )(
"debug-level,d", po::value<int>()->default_value( 0 ),
"debug level" )(
295 "load-library,l", po::value<Strings_t>()->composing(),
"preloading library" )(
296 "user-module,m", po::value<string>(),
"user-defined module to be imported by the genConf-generated one" )(
297 "no-init",
"do not generate the (empty) __init__.py" );
301 po::options_description
config(
"Configuration" );
302 config.add_options()(
"configurable-module", po::value<string>()->default_value(
"AthenaCommon" ),
303 "Name of the module holding the configurable classes" )(
304 "configurable-default-name", po::value<string>()->default_value(
"Configurable.DefaultName" ),
305 "Default name for the configurable instance" )(
"configurable-algorithm",
306 po::value<string>()->default_value(
"ConfigurableAlgorithm" ),
307 "Name of the configurable base class for Algorithm components" )(
308 "configurable-algtool", po::value<string>()->default_value(
"ConfigurableAlgTool" ),
309 "Name of the configurable base class for AlgTool components" )(
310 "configurable-auditor", po::value<string>()->default_value(
"ConfigurableAuditor" ),
311 "Name of the configurable base class for Auditor components" )(
312 "configurable-service", po::value<string>()->default_value(
"ConfigurableService" ),
313 "Name of the configurable base class for Service components" );
315 po::options_description cmdline_options;
316 cmdline_options.add(
generic ).add(
config );
318 po::options_description config_file_options;
319 config_file_options.add(
config );
321 po::options_description visible(
"Allowed options" );
322 visible.add(
generic ).add(
config );
324 po::variables_map vm;
327 po::store( po::command_line_parser(
argc,
argv ).
options( cmdline_options ).run(), vm );
332 if ( vm.count(
"input-cfg" ) ) {
333 string cfgFileName = vm[
"input-cfg"].as<
string>();
334 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).
string();
336 po::store( parse_config_file( ifs, config_file_options ), vm );
340 }
catch ( po::error& err ) {
341 LOG_ERROR <<
"error detected while parsing command options: " << err.what();
346 if ( vm.count(
"help" ) ) {
351 if ( vm.count(
"package-name" ) ) {
352 pkgName = vm[
"package-name"].as<
string>();
359 if ( vm.count(
"user-module" ) ) {
360 userModule = vm[
"user-module"].as<
string>();
361 LOG_INFO <<
"INFO: will import user module " << userModule;
364 if ( vm.count(
"input-libraries" ) ) {
370 boost::split( libs, tmp, boost::is_any_of(
" " ), boost::token_compress_on );
372 LOG_ERROR <<
"input component library(ies) required";
377 if ( vm.count(
"output-dir" ) ) {
out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) ); }
381 if ( vm.count(
"load-library" ) ) {
382 for (
const auto& lLib : vm[
"load-library"].as<Strings_t>() ) {
386 if ( err != 1 )
LOG_WARNING <<
"failed to load: " << lLib;
390 if ( !fs::exists(
out ) ) {
392 fs::create_directory(
out );
393 }
catch ( fs::filesystem_error& err ) {
394 LOG_ERROR <<
"error creating directory: " << err.what();
401 msg <<
":::::: libraries : [ ";
408 py.setConfigurableModule( vm[
"configurable-module"].as<string>() );
409 py.setConfigurableDefaultName( vm[
"configurable-default-name"].as<string>() );
410 py.setConfigurableAlgorithm( vm[
"configurable-algorithm"].as<string>() );
411 py.setConfigurableAlgTool( vm[
"configurable-algtool"].as<string>() );
412 py.setConfigurableAuditor( vm[
"configurable-auditor"].as<string>() );
413 py.setConfigurableService( vm[
"configurable-service"].as<string>() );
415 int sc = EXIT_FAILURE;
417 sc = py.genConfig( libs, userModule );
419 cout <<
"ERROR: Could not generate Configurable(s) !\n"
420 <<
"ERROR: Got exception: " << e.
what() <<
endl;
424 if ( EXIT_SUCCESS == sc && !vm.count(
"no-init" ) ) {
427 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" <<
flush;
432 msg <<
":::::: libraries : [ ";
434 msg <<
"] :::::: [DONE]";