267 ? boost::log::trivial::info
268 : boost::log::trivial::warning );
277 po::options_description
generic(
"Generic options" );
278 generic.add_options()(
"help,h",
"produce this help message" )(
279 "package-name,p", po::value<string>(),
"name of the package for which we create the configurables file" )(
280 "input-libraries,i", po::value<string>(),
"libraries to extract the component configurables from" )(
281 "input-cfg,c", po::value<string>(),
282 "path to the cfg file holding the description of the Configurable base "
283 "classes, the python module holding the Configurable definitions, etc..." )(
284 "output-dir,o", po::value<string>()->default_value(
"../genConfDir" ),
285 "output directory for genconf files." )(
"debug-level,d", po::value<int>()->default_value( 0 ),
"debug level" )(
286 "load-library,l", po::value<Strings_t>()->composing(),
"preloading library" )(
287 "user-module,m", po::value<string>(),
"user-defined module to be imported by the genConf-generated one" )(
288 "no-init",
"do not generate the (empty) __init__.py" );
292 po::options_description
config(
"Configuration" );
293 config.add_options()(
"configurable-module", po::value<string>()->default_value(
"AthenaCommon" ),
294 "Name of the module holding the configurable classes" )(
295 "configurable-default-name", po::value<string>()->default_value(
"Configurable.DefaultName" ),
296 "Default name for the configurable instance" )(
"configurable-algorithm",
297 po::value<string>()->default_value(
"ConfigurableAlgorithm" ),
298 "Name of the configurable base class for Algorithm components" )(
299 "configurable-algtool", po::value<string>()->default_value(
"ConfigurableAlgTool" ),
300 "Name of the configurable base class for AlgTool components" )(
301 "configurable-auditor", po::value<string>()->default_value(
"ConfigurableAuditor" ),
302 "Name of the configurable base class for Auditor components" )(
303 "configurable-service", po::value<string>()->default_value(
"ConfigurableService" ),
304 "Name of the configurable base class for Service components" );
306 po::options_description cmdline_options;
307 cmdline_options.add(
generic ).add(
config );
309 po::options_description config_file_options;
310 config_file_options.add(
config );
312 po::options_description visible(
"Allowed options" );
313 visible.add(
generic ).add(
config );
315 po::variables_map vm;
318 po::store( po::command_line_parser(
argc,
argv ).
options( cmdline_options ).run(), vm );
323 if ( vm.count(
"input-cfg" ) ) {
324 string cfgFileName = vm[
"input-cfg"].as<
string>();
325 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).
string();
327 po::store( parse_config_file( ifs, config_file_options ), vm );
331 }
catch ( po::error& err ) {
332 LOG_ERROR <<
"error detected while parsing command options: " << err.what();
337 if ( vm.count(
"help" ) ) {
342 if ( vm.count(
"package-name" ) ) {
343 pkgName = vm[
"package-name"].as<
string>();
350 if ( vm.count(
"user-module" ) ) {
351 userModule = vm[
"user-module"].as<
string>();
352 LOG_INFO <<
"INFO: will import user module " << userModule;
355 if ( vm.count(
"input-libraries" ) ) {
361 boost::split( libs, tmp, boost::is_any_of(
" " ), boost::token_compress_on );
363 LOG_ERROR <<
"input component library(ies) required";
368 if ( vm.count(
"output-dir" ) ) {
out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) ); }
372 if ( vm.count(
"load-library" ) ) {
373 for (
const auto& lLib : vm[
"load-library"].as<Strings_t>() ) {
377 if ( err != 1 )
LOG_WARNING <<
"failed to load: " << lLib;
381 if ( !fs::exists(
out ) ) {
383 fs::create_directory(
out );
384 }
catch ( fs::filesystem_error& err ) {
385 LOG_ERROR <<
"error creating directory: " << err.what();
392 msg <<
":::::: libraries : [ ";
399 py.setConfigurableModule( vm[
"configurable-module"].as<string>() );
400 py.setConfigurableDefaultName( vm[
"configurable-default-name"].as<string>() );
401 py.setConfigurableAlgorithm( vm[
"configurable-algorithm"].as<string>() );
402 py.setConfigurableAlgTool( vm[
"configurable-algtool"].as<string>() );
403 py.setConfigurableAuditor( vm[
"configurable-auditor"].as<string>() );
404 py.setConfigurableService( vm[
"configurable-service"].as<string>() );
406 int sc = EXIT_FAILURE;
408 sc = py.genConfig( libs, userModule );
410 cout <<
"ERROR: Could not generate Configurable(s) !\n"
411 <<
"ERROR: Got exception: " << e.
what() <<
endl;
415 if ( EXIT_SUCCESS == sc && !vm.count(
"no-init" ) ) {
418 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" <<
flush;
423 msg <<
":::::: libraries : [ ";
425 msg <<
"] :::::: [DONE]";