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>(),
"path to the cfg file holding the description of the Configurable base " 280 "classes, the python module holding the Configurable definitions, etc..." )(
281 "output-dir,o", po::value<string>()->default_value(
"../genConf" ),
282 "output directory for genconf files." )(
"debug-level,d", po::value<int>()->default_value( 0 ),
"debug level" )(
283 "load-library,l", po::value<Strings_t>()->composing(),
"preloading library" )(
284 "user-module,m", po::value<string>(),
"user-defined module to be imported by the genConf-generated one" )(
285 "no-init",
"do not generate the (empty) __init__.py" );
289 po::options_description
config(
"Configuration" );
290 config.add_options()(
"configurable-module", po::value<string>()->default_value(
"AthenaCommon" ),
291 "Name of the module holding the configurable classes" )(
292 "configurable-default-name", po::value<string>()->default_value(
"Configurable.DefaultName" ),
293 "Default name for the configurable instance" )(
"configurable-algorithm",
294 po::value<string>()->default_value(
"ConfigurableAlgorithm" ),
295 "Name of the configurable base class for Algorithm components" )(
296 "configurable-algtool", po::value<string>()->default_value(
"ConfigurableAlgTool" ),
297 "Name of the configurable base class for AlgTool components" )(
298 "configurable-auditor", po::value<string>()->default_value(
"ConfigurableAuditor" ),
299 "Name of the configurable base class for Auditor components" )(
300 "configurable-service", po::value<string>()->default_value(
"ConfigurableService" ),
301 "Name of the configurable base class for Service components" );
303 po::options_description cmdline_options;
304 cmdline_options.add(
generic ).add(
config );
306 po::options_description config_file_options;
307 config_file_options.add(
config );
309 po::options_description visible(
"Allowed options" );
310 visible.add(
generic ).add(
config );
312 po::variables_map vm;
315 po::store( po::command_line_parser(
argc,
argv ).
options( cmdline_options ).run(), vm );
320 if ( vm.count(
"input-cfg" ) ) {
321 string cfgFileName = vm[
"input-cfg"].as<
string>();
322 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).
string();
324 po::store( parse_config_file( ifs, config_file_options ), vm );
328 }
catch ( po::error& err ) {
329 LOG_ERROR <<
"error detected while parsing command options: " << err.what();
334 if ( vm.count(
"help" ) ) {
339 if ( vm.count(
"package-name" ) ) {
340 pkgName = vm[
"package-name"].as<
string>();
347 if ( vm.count(
"user-module" ) ) {
348 userModule = vm[
"user-module"].as<
string>();
349 LOG_INFO <<
"INFO: will import user module " << userModule;
352 if ( vm.count(
"input-libraries" ) ) {
360 boost::split( inputLibs, tmp, boost::is_any_of(
" " ), boost::token_compress_on );
365 for (
const auto& iLib : inputLibs ) {
367 if ( lib.
compare( 0, 3,
"lib" ) == 0 ) {
375 if ( libs.
empty() ) {
376 LOG_ERROR <<
"input component library(ies) required !\n";
377 LOG_ERROR <<
"'input-libraries' argument was [" << vm[
"input-libraries"].as<
string>() <<
"]";
381 LOG_ERROR <<
"input component library(ies) required";
386 if ( vm.count(
"output-dir" ) ) {
387 out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) );
390 if ( vm.count(
"debug-level" ) ) {
394 if ( vm.count(
"load-library" ) ) {
395 for (
const auto& lLib : vm[
"load-library"].as<Strings_t>() ) {
399 if ( err != 1 )
LOG_WARNING <<
"failed to load: " << lLib;
403 if ( !fs::exists( out ) ) {
405 fs::create_directory( out );
406 }
catch ( fs::filesystem_error& err ) {
407 LOG_ERROR <<
"error creating directory: " << err.what();
414 msg <<
":::::: libraries : [ ";
422 py.setConfigurableDefaultName( vm[
"configurable-default-name"].as<string>() );
423 py.setConfigurableAlgorithm( vm[
"configurable-algorithm"].as<string>() );
424 py.setConfigurableAlgTool( vm[
"configurable-algtool"].as<string>() );
425 py.setConfigurableAuditor( vm[
"configurable-auditor"].as<string>() );
426 py.setConfigurableService( vm[
"configurable-service"].as<string>() );
428 int sc = EXIT_FAILURE;
430 sc = py.genConfig( libs, userModule );
432 cout <<
"ERROR: Could not generate Configurable(s) !\n" 433 <<
"ERROR: Got exception: " << e.
what() <<
endl;
437 if ( EXIT_SUCCESS == sc && !vm.count(
"no-init" ) ) {
439 std::fstream initPy( ( out /
fs::path(
"__init__.py" ) ).
string(), std::ios_base::out | std::ios_base::trunc );
440 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" <<
flush;
445 msg <<
":::::: libraries : [ ";
447 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.