245 ? boost::log::trivial::info
246 : boost::log::trivial::warning);
252 std::string userModule;
255 po::options_description
generic(
"Generic options");
256 generic.add_options()
258 "produce this help message")
261 "name of the package for which we create the configurables file")
262 (
"input-libraries,i",
264 "libraries to extract the component configurables from")
267 "path to the cfg file holding the description of the Configurable base "
268 "classes, the python module holding the Configurable definitions, etc...")
270 po::value<string>()->default_value(
"../genConf"),
271 "output directory for genconf files.")
273 po::value<int>()->default_value(0),
276 po::value< Strings_t >()->composing(),
277 "preloading library")
280 "user-defined module to be imported by the genConf-generated one")
282 "do not generate the (empty) __init__.py")
287 po::options_description
config(
"Configuration");
289 (
"configurable-module",
290 po::value<string>()->default_value(
"AthenaCommon"),
291 "Name of the module holding the configurable classes")
292 (
"configurable-default-name",
293 po::value<string>()->default_value(
"Configurable.DefaultName"),
294 "Default name for the configurable instance")
295 (
"configurable-algorithm",
296 po::value<string>()->default_value(
"ConfigurableAlgorithm"),
297 "Name of the configurable base class for Algorithm components")
298 (
"configurable-algtool",
299 po::value<string>()->default_value(
"ConfigurableAlgTool"),
300 "Name of the configurable base class for AlgTool components")
301 (
"configurable-auditor",
302 po::value<string>()->default_value(
"ConfigurableAuditor"),
303 "Name of the configurable base class for Auditor components")
304 (
"configurable-service",
305 po::value<string>()->default_value(
"ConfigurableService"),
306 "Name of the configurable base class for Service components")
309 po::options_description cmdline_options;
310 cmdline_options.add(
generic).add(
config);
312 po::options_description config_file_options;
313 config_file_options.add(
config);
315 po::options_description visible(
"Allowed options");
316 visible.add(
generic).add(
config);
318 po::variables_map vm;
321 po::store( po::command_line_parser(
argc,
argv).
322 options(cmdline_options).run(),
328 if( vm.count(
"input-cfg") ) {
329 string cfgFileName = vm[
"input-cfg"].as<
string>();
330 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).string();
331 std::ifstream ifs( cfgFileName );
332 po::store( parse_config_file( ifs, config_file_options ), vm );
337 catch ( po::error& err ) {
339 <<
"error detected while parsing command options: "
345 if( vm.count(
"help")) {
346 cout << visible << endl;
350 if( vm.count(
"package-name") ) {
351 pkgName = vm[
"package-name"].as<
string>();
355 cout << visible << endl;
359 if( vm.count(
"user-module") ) {
360 userModule = vm[
"user-module"].as<
string>();
361 LOG_INFO <<
"INFO: will import user module " << userModule;
364 if( vm.count(
"input-libraries") ) {
370 string tmp = vm[
"input-libraries"].as<
string>();
372 boost::split( inputLibs, tmp,
373 boost::is_any_of(
" "),
374 boost::token_compress_on );
378 libs.reserve( inputLibs.size() );
379 for ( Strings_t::const_iterator iLib = inputLibs.begin();
380 iLib != inputLibs.end();
382 std::string lib =
fs::path(*iLib).stem().string();
383 if ( 0 == lib.find(
"lib") ) {
388 std::find( libs.begin(), libs.end(), lib ) == libs.end() ) {
389 libs.push_back( lib );
392 if ( libs.empty() ) {
393 LOG_ERROR <<
"input component library(ies) required !\n";
394 LOG_ERROR <<
"'input-libraries' argument was ["
395 << vm[
"input-libraries"].as<
string>()
401 LOG_ERROR <<
"input component library(ies) required";
402 cout << visible << endl;
406 if( vm.count(
"output-dir") ) {
407 out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) );
410 if ( vm.count(
"debug-level") ) {
414 if ( vm.count(
"load-library") ) {
416 for (Strings_t::const_iterator lLib=lLib_list.begin();
417 lLib != lLib_list.end();
429 if ( !fs::exists( out ) ) {
431 fs::create_directory(out);
433 catch ( fs::filesystem_error &err ) {
434 LOG_ERROR <<
"error creating directory: "<< err.what();
440 std::ostringstream
msg;
441 msg <<
":::::: libraries : [ ";
442 copy( libs.begin(), libs.end(), ostream_iterator<string>(
msg,
" ") );
449 py.setConfigurableDefaultName(vm[
"configurable-default-name"].as<string>());
450 py.setConfigurableAlgorithm (vm[
"configurable-algorithm"].as<string>());
451 py.setConfigurableAlgTool (vm[
"configurable-algtool"].as<string>());
452 py.setConfigurableAuditor (vm[
"configurable-auditor"].as<string>());
453 py.setConfigurableService (vm[
"configurable-service"].as<string>());
455 int sc = EXIT_FAILURE;
457 sc = py.genConfig( libs, userModule );
459 catch ( exception& e ) {
460 cout <<
"ERROR: Could not generate Configurable(s) !\n"
461 <<
"ERROR: Got exception: " << e.what() << endl;
465 if ( EXIT_SUCCESS == sc && ! vm.count(
"no-init")) {
467 fstream initPy( ( out /
fs::path(
"__init__.py" ) ).
string(),
468 std::ios_base::out|std::ios_base::trunc );
469 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" << flush;
473 std::ostringstream
msg;
474 msg <<
":::::: libraries : [ ";
475 copy( libs.begin(), libs.end(), ostream_iterator<string>(
msg,
" ") );
476 msg <<
"] :::::: [DONE]";
std::vector< std::string > Strings_t
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.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
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.