266 ? boost::log::trivial::info
267 : boost::log::trivial::warning );
276 po::options_description
generic(
"Generic options" );
277 generic.add_options()(
"help,h",
"produce this help message" )(
278 "package-name,p", po::value<string>(),
"name of the package for which we create the configurables file" )(
279 "input-libraries,i", po::value<string>(),
"libraries to extract the component configurables from" )(
280 "input-cfg,c", po::value<string>(),
281 "path to the cfg file holding the description of the Configurable base "
282 "classes, the python module holding the Configurable definitions, etc..." )(
283 "output-dir,o", po::value<string>()->default_value(
"../genConfDir" ),
284 "output directory for genconf files." )(
"debug-level,d", po::value<int>()->default_value( 0 ),
"debug level" )(
285 "load-library,l", po::value<Strings_t>()->composing(),
"preloading library" )(
286 "user-module,m", po::value<string>(),
"user-defined module to be imported by the genConf-generated one" )(
287 "no-init",
"do not generate the (empty) __init__.py" );
291 po::options_description
config(
"Configuration" );
292 config.add_options()(
"configurable-module", po::value<string>()->default_value(
"AthenaCommon" ),
293 "Name of the module holding the configurable classes" )(
294 "configurable-default-name", po::value<string>()->default_value(
"Configurable.DefaultName" ),
295 "Default name for the configurable instance" )(
"configurable-algorithm",
296 po::value<string>()->default_value(
"ConfigurableAlgorithm" ),
297 "Name of the configurable base class for Algorithm components" )(
298 "configurable-algtool", po::value<string>()->default_value(
"ConfigurableAlgTool" ),
299 "Name of the configurable base class for AlgTool components" )(
300 "configurable-auditor", po::value<string>()->default_value(
"ConfigurableAuditor" ),
301 "Name of the configurable base class for Auditor components" )(
302 "configurable-service", po::value<string>()->default_value(
"ConfigurableService" ),
303 "Name of the configurable base class for Service components" );
305 po::options_description cmdline_options;
306 cmdline_options.add(
generic ).add(
config );
308 po::options_description config_file_options;
309 config_file_options.add(
config );
311 po::options_description visible(
"Allowed options" );
312 visible.add(
generic ).add(
config );
314 po::variables_map vm;
317 po::store( po::command_line_parser(
argc,
argv ).
options( cmdline_options ).run(), vm );
322 if ( vm.count(
"input-cfg" ) ) {
323 string cfgFileName = vm[
"input-cfg"].as<
string>();
324 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).
string();
326 po::store( parse_config_file( ifs, config_file_options ), vm );
330 }
catch ( po::error& err ) {
331 LOG_ERROR <<
"error detected while parsing command options: " << err.what();
336 if ( vm.count(
"help" ) ) {
341 if ( vm.count(
"package-name" ) ) {
342 pkgName = vm[
"package-name"].as<
string>();
349 if ( vm.count(
"user-module" ) ) {
350 userModule = vm[
"user-module"].as<
string>();
351 LOG_INFO <<
"INFO: will import user module " << userModule;
354 if ( vm.count(
"input-libraries" ) ) {
360 boost::split( libs, tmp, boost::is_any_of(
" " ), boost::token_compress_on );
362 LOG_ERROR <<
"input component library(ies) required";
367 if ( vm.count(
"output-dir" ) ) {
out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) ); }
371 if ( vm.count(
"load-library" ) ) {
372 for (
const auto& lLib : vm[
"load-library"].as<Strings_t>() ) {
376 if ( err != 1 )
LOG_WARNING <<
"failed to load: " << lLib;
380 if ( !fs::exists(
out ) ) {
382 fs::create_directory(
out );
383 }
catch ( fs::filesystem_error& err ) {
384 LOG_ERROR <<
"error creating directory: " << err.what();
391 msg <<
":::::: libraries : [ ";
398 py.setConfigurableModule( vm[
"configurable-module"].as<string>() );
399 py.setConfigurableDefaultName( vm[
"configurable-default-name"].as<string>() );
400 py.setConfigurableAlgorithm( vm[
"configurable-algorithm"].as<string>() );
401 py.setConfigurableAlgTool( vm[
"configurable-algtool"].as<string>() );
402 py.setConfigurableAuditor( vm[
"configurable-auditor"].as<string>() );
403 py.setConfigurableService( vm[
"configurable-service"].as<string>() );
405 int sc = EXIT_FAILURE;
407 sc = py.genConfig( libs, userModule );
409 cout <<
"ERROR: Could not generate Configurable(s) !\n"
410 <<
"ERROR: Got exception: " << e.
what() <<
endl;
414 if ( EXIT_SUCCESS == sc && !vm.count(
"no-init" ) ) {
417 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" <<
flush;
422 msg <<
":::::: libraries : [ ";
424 msg <<
"] :::::: [DONE]";