274 ? boost::log::trivial::info
275 : boost::log::trivial::warning );
284 po::options_description
generic(
"Generic options" );
285 generic.add_options()(
"help,h",
"produce this help message" )(
286 "package-name,p", po::value<string>(),
"name of the package for which we create the configurables file" )(
287 "input-libraries,i", po::value<string>(),
"libraries to extract the component configurables from" )(
288 "input-cfg,c", po::value<string>(),
289 "path to the cfg file holding the description of the Configurable base " 290 "classes, the python module holding the Configurable definitions, etc..." )(
291 "output-dir,o", po::value<string>()->default_value(
"../genConf" ),
292 "output directory for genconf files." )(
"debug-level,d", po::value<int>()->default_value( 0 ),
"debug level" )(
293 "load-library,l", po::value<Strings_t>()->composing(),
"preloading library" )(
294 "user-module,m", po::value<string>(),
"user-defined module to be imported by the genConf-generated one" )(
295 "no-init",
"do not generate the (empty) __init__.py" );
299 po::options_description
config(
"Configuration" );
300 config.add_options()(
"configurable-module", po::value<string>()->default_value(
"AthenaCommon" ),
301 "Name of the module holding the configurable classes" )(
302 "configurable-default-name", po::value<string>()->default_value(
"Configurable.DefaultName" ),
303 "Default name for the configurable instance" )(
"configurable-algorithm",
304 po::value<string>()->default_value(
"ConfigurableAlgorithm" ),
305 "Name of the configurable base class for Algorithm components" )(
306 "configurable-algtool", po::value<string>()->default_value(
"ConfigurableAlgTool" ),
307 "Name of the configurable base class for AlgTool components" )(
308 "configurable-auditor", po::value<string>()->default_value(
"ConfigurableAuditor" ),
309 "Name of the configurable base class for Auditor components" )(
310 "configurable-service", po::value<string>()->default_value(
"ConfigurableService" ),
311 "Name of the configurable base class for Service components" );
313 po::options_description cmdline_options;
314 cmdline_options.add(
generic ).add(
config );
316 po::options_description config_file_options;
317 config_file_options.add(
config );
319 po::options_description visible(
"Allowed options" );
320 visible.add(
generic ).add(
config );
322 po::variables_map vm;
325 po::store( po::command_line_parser(
argc,
argv ).
options( cmdline_options ).run(), vm );
330 if ( vm.count(
"input-cfg" ) ) {
331 string cfgFileName = vm[
"input-cfg"].as<
string>();
332 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).
string();
334 po::store( parse_config_file( ifs, config_file_options ), vm );
338 }
catch ( po::error& err ) {
339 LOG_ERROR <<
"error detected while parsing command options: " << err.what();
344 if ( vm.count(
"help" ) ) {
349 if ( vm.count(
"package-name" ) ) {
350 pkgName = vm[
"package-name"].as<
string>();
357 if ( vm.count(
"user-module" ) ) {
358 userModule = vm[
"user-module"].as<
string>();
359 LOG_INFO <<
"INFO: will import user module " << userModule;
362 if ( vm.count(
"input-libraries" ) ) {
370 boost::split( inputLibs, tmp, boost::is_any_of(
" " ), boost::token_compress_on );
375 for (
const auto& iLib : inputLibs ) {
377 if ( lib.
compare( 0, 3,
"lib" ) == 0 ) {
383 if ( libs.
empty() ) {
384 LOG_ERROR <<
"input component library(ies) required !\n";
385 LOG_ERROR <<
"'input-libraries' argument was [" << vm[
"input-libraries"].as<
string>() <<
"]";
389 LOG_ERROR <<
"input component library(ies) required";
394 if ( vm.count(
"output-dir" ) ) { out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) ); }
398 if ( vm.count(
"load-library" ) ) {
399 for (
const auto& lLib : vm[
"load-library"].as<Strings_t>() ) {
403 if ( err != 1 )
LOG_WARNING <<
"failed to load: " << lLib;
407 if ( !fs::exists( out ) ) {
409 fs::create_directory( out );
410 }
catch ( fs::filesystem_error& err ) {
411 LOG_ERROR <<
"error creating directory: " << err.what();
418 msg <<
":::::: libraries : [ ";
426 py.setConfigurableDefaultName( vm[
"configurable-default-name"].as<string>() );
427 py.setConfigurableAlgorithm( vm[
"configurable-algorithm"].as<string>() );
428 py.setConfigurableAlgTool( vm[
"configurable-algtool"].as<string>() );
429 py.setConfigurableAuditor( vm[
"configurable-auditor"].as<string>() );
430 py.setConfigurableService( vm[
"configurable-service"].as<string>() );
432 int sc = EXIT_FAILURE;
434 sc = py.genConfig( libs, userModule );
436 cout <<
"ERROR: Could not generate Configurable(s) !\n" 437 <<
"ERROR: Got exception: " << e.
what() <<
endl;
441 if ( EXIT_SUCCESS == sc && !vm.count(
"no-init" ) ) {
443 std::fstream initPy( ( out /
fs::path(
"__init__.py" ) ).
string(), std::ios_base::out | std::ios_base::trunc );
444 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" <<
flush;
449 msg <<
":::::: libraries : [ ";
451 msg <<
"] :::::: [DONE]";
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
void * ImageHandle
Definition of an image handle.
void setConfigurableModule(const std::string &moduleName)
customize the Module name where configurable base classes are defined
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
void init_logging(boost::log::trivial::severity_level level)
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.