265 ? boost::log::trivial::info
266 : boost::log::trivial::warning );
275 po::options_description
generic(
"Generic options" );
276 generic.add_options()(
"help,h",
"produce this help message" )(
277 "package-name,p", po::value<string>(),
"name of the package for which we create the configurables file" )(
278 "input-libraries,i", po::value<string>(),
"libraries to extract the component configurables from" )(
279 "input-cfg,c", po::value<string>(),
280 "path to the cfg file holding the description of the Configurable base " 281 "classes, the python module holding the Configurable definitions, etc..." )(
282 "output-dir,o", po::value<string>()->default_value(
"../genConf" ),
283 "output directory for genconf files." )(
"debug-level,d", po::value<int>()->default_value( 0 ),
"debug level" )(
284 "load-library,l", po::value<Strings_t>()->composing(),
"preloading library" )(
285 "user-module,m", po::value<string>(),
"user-defined module to be imported by the genConf-generated one" )(
286 "no-init",
"do not generate the (empty) __init__.py" );
290 po::options_description
config(
"Configuration" );
291 config.add_options()(
"configurable-module", po::value<string>()->default_value(
"AthenaCommon" ),
292 "Name of the module holding the configurable classes" )(
293 "configurable-default-name", po::value<string>()->default_value(
"Configurable.DefaultName" ),
294 "Default name for the configurable instance" )(
"configurable-algorithm",
295 po::value<string>()->default_value(
"ConfigurableAlgorithm" ),
296 "Name of the configurable base class for Algorithm components" )(
297 "configurable-algtool", po::value<string>()->default_value(
"ConfigurableAlgTool" ),
298 "Name of the configurable base class for AlgTool components" )(
299 "configurable-auditor", po::value<string>()->default_value(
"ConfigurableAuditor" ),
300 "Name of the configurable base class for Auditor components" )(
301 "configurable-service", po::value<string>()->default_value(
"ConfigurableService" ),
302 "Name of the configurable base class for Service components" );
304 po::options_description cmdline_options;
305 cmdline_options.add(
generic ).add(
config );
307 po::options_description config_file_options;
308 config_file_options.add(
config );
310 po::options_description visible(
"Allowed options" );
311 visible.add(
generic ).add(
config );
313 po::variables_map vm;
316 po::store( po::command_line_parser(
argc,
argv ).
options( cmdline_options ).run(), vm );
321 if ( vm.count(
"input-cfg" ) ) {
322 string cfgFileName = vm[
"input-cfg"].as<
string>();
323 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).
string();
325 po::store( parse_config_file( ifs, config_file_options ), vm );
329 }
catch ( po::error& err ) {
330 LOG_ERROR <<
"error detected while parsing command options: " << err.what();
335 if ( vm.count(
"help" ) ) {
340 if ( vm.count(
"package-name" ) ) {
341 pkgName = vm[
"package-name"].as<
string>();
348 if ( vm.count(
"user-module" ) ) {
349 userModule = vm[
"user-module"].as<
string>();
350 LOG_INFO <<
"INFO: will import user module " << userModule;
353 if ( vm.count(
"input-libraries" ) ) {
361 boost::split( inputLibs, tmp, boost::is_any_of(
" " ), boost::token_compress_on );
366 for (
const auto& iLib : inputLibs ) {
368 if ( lib.
compare( 0, 3,
"lib" ) == 0 ) {
374 if ( libs.
empty() ) {
375 LOG_ERROR <<
"input component library(ies) required !\n";
376 LOG_ERROR <<
"'input-libraries' argument was [" << vm[
"input-libraries"].as<
string>() <<
"]";
380 LOG_ERROR <<
"input component library(ies) required";
385 if ( vm.count(
"output-dir" ) ) { out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) ); }
389 if ( vm.count(
"load-library" ) ) {
390 for (
const auto& lLib : vm[
"load-library"].as<Strings_t>() ) {
394 if ( err != 1 )
LOG_WARNING <<
"failed to load: " << lLib;
398 if ( !fs::exists( out ) ) {
400 fs::create_directory( out );
401 }
catch ( fs::filesystem_error& err ) {
402 LOG_ERROR <<
"error creating directory: " << err.what();
409 msg <<
":::::: libraries : [ ";
417 py.setConfigurableDefaultName( vm[
"configurable-default-name"].as<string>() );
418 py.setConfigurableAlgorithm( vm[
"configurable-algorithm"].as<string>() );
419 py.setConfigurableAlgTool( vm[
"configurable-algtool"].as<string>() );
420 py.setConfigurableAuditor( vm[
"configurable-auditor"].as<string>() );
421 py.setConfigurableService( vm[
"configurable-service"].as<string>() );
423 int sc = EXIT_FAILURE;
425 sc = py.genConfig( libs, userModule );
427 cout <<
"ERROR: Could not generate Configurable(s) !\n" 428 <<
"ERROR: Got exception: " << e.
what() <<
endl;
432 if ( EXIT_SUCCESS == sc && !vm.count(
"no-init" ) ) {
434 std::fstream initPy( ( out /
fs::path(
"__init__.py" ) ).
string(), std::ios_base::out | std::ios_base::trunc );
435 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" <<
flush;
440 msg <<
":::::: libraries : [ ";
442 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.