207 ? boost::log::trivial::info
208 : boost::log::trivial::warning );
217 po::options_description
generic(
"Generic options" );
218 generic.add_options()(
"help,h",
"produce this help message" )(
219 "package-name,p", po::value<string>(),
"name of the package for which we create the configurables file" )(
220 "input-libraries,i", po::value<string>(),
"libraries to extract the component configurables from" )(
221 "input-cfg,c", po::value<string>(),
"path to the cfg file holding the description of the Configurable base " 222 "classes, the python module holding the Configurable definitions, etc..." )(
223 "output-dir,o", po::value<string>()->default_value(
"../genConf" ),
224 "output directory for genconf files." )(
"debug-level,d", po::value<int>()->default_value( 0 ),
"debug level" )(
225 "load-library,l", po::value<Strings_t>()->composing(),
"preloading library" )(
226 "user-module,m", po::value<string>(),
"user-defined module to be imported by the genConf-generated one" )(
227 "no-init",
"do not generate the (empty) __init__.py" );
231 po::options_description
config(
"Configuration" );
232 config.add_options()(
"configurable-module", po::value<string>()->default_value(
"AthenaCommon" ),
233 "Name of the module holding the configurable classes" )(
234 "configurable-default-name", po::value<string>()->default_value(
"Configurable.DefaultName" ),
235 "Default name for the configurable instance" )(
"configurable-algorithm",
236 po::value<string>()->default_value(
"ConfigurableAlgorithm" ),
237 "Name of the configurable base class for Algorithm components" )(
238 "configurable-algtool", po::value<string>()->default_value(
"ConfigurableAlgTool" ),
239 "Name of the configurable base class for AlgTool components" )(
240 "configurable-auditor", po::value<string>()->default_value(
"ConfigurableAuditor" ),
241 "Name of the configurable base class for Auditor components" )(
242 "configurable-service", po::value<string>()->default_value(
"ConfigurableService" ),
243 "Name of the configurable base class for Service components" );
245 po::options_description cmdline_options;
246 cmdline_options.add(
generic ).add(
config );
248 po::options_description config_file_options;
249 config_file_options.add(
config );
251 po::options_description visible(
"Allowed options" );
252 visible.add(
generic ).add(
config );
254 po::variables_map vm;
257 po::store( po::command_line_parser(
argc,
argv ).
options( cmdline_options ).run(), vm );
262 if ( vm.count(
"input-cfg" ) ) {
263 string cfgFileName = vm[
"input-cfg"].as<
string>();
264 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).
string();
266 po::store( parse_config_file( ifs, config_file_options ), vm );
270 }
catch ( po::error& err ) {
271 LOG_ERROR <<
"error detected while parsing command options: " << err.what();
276 if ( vm.count(
"help" ) ) {
281 if ( vm.count(
"package-name" ) ) {
282 pkgName = vm[
"package-name"].as<
string>();
289 if ( vm.count(
"user-module" ) ) {
290 userModule = vm[
"user-module"].as<
string>();
291 LOG_INFO <<
"INFO: will import user module " << userModule;
294 if ( vm.count(
"input-libraries" ) ) {
300 string tmp = vm[
"input-libraries"].as<
string>();
302 boost::split( inputLibs, tmp, boost::is_any_of(
" " ), boost::token_compress_on );
307 for ( Strings_t::const_iterator iLib = inputLibs.
begin(); iLib != inputLibs.
end(); ++iLib ) {
309 if ( 0 == lib.
find(
"lib" ) ) {
317 if ( libs.
empty() ) {
318 LOG_ERROR <<
"input component library(ies) required !\n";
319 LOG_ERROR <<
"'input-libraries' argument was [" << vm[
"input-libraries"].as<
string>() <<
"]";
323 LOG_ERROR <<
"input component library(ies) required";
328 if ( vm.count(
"output-dir" ) ) {
329 out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) );
332 if ( vm.count(
"debug-level" ) ) {
336 if ( vm.count(
"load-library" ) ) {
338 for ( Strings_t::const_iterator lLib = lLib_list.
begin(); lLib != lLib_list.
end(); ++lLib ) {
348 if ( !fs::exists( out ) ) {
350 fs::create_directory( out );
351 }
catch ( fs::filesystem_error& err ) {
352 LOG_ERROR <<
"error creating directory: " << err.what();
359 msg <<
":::::: libraries : [ ";
367 py.setConfigurableDefaultName( vm[
"configurable-default-name"].as<string>() );
368 py.setConfigurableAlgorithm( vm[
"configurable-algorithm"].as<string>() );
369 py.setConfigurableAlgTool( vm[
"configurable-algtool"].as<string>() );
370 py.setConfigurableAuditor( vm[
"configurable-auditor"].as<string>() );
371 py.setConfigurableService( vm[
"configurable-service"].as<string>() );
373 int sc = EXIT_FAILURE;
375 sc = py.genConfig( libs, userModule );
377 cout <<
"ERROR: Could not generate Configurable(s) !\n" 378 <<
"ERROR: Got exception: " << e.
what() <<
endl;
382 if ( EXIT_SUCCESS == sc && !vm.count(
"no-init" ) ) {
384 fstream initPy( ( out /
fs::path(
"__init__.py" ) ).
string(), std::ios_base::out | std::ios_base::trunc );
385 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" <<
flush;
390 msg <<
":::::: libraries : [ ";
392 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
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
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)
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.