241 ? boost::log::trivial::info
242 : boost::log::trivial::warning);
248 std::string userModule;
251 po::options_description
generic(
"Generic options");
252 generic.add_options()
254 "produce this help message")
257 "name of the package for which we create the configurables file")
258 (
"input-libraries,i",
260 "libraries to extract the component configurables from")
263 "path to the cfg file holding the description of the Configurable base "
264 "classes, the python module holding the Configurable definitions, etc...")
266 po::value<string>()->default_value(
"../genConf"),
267 "output directory for genconf files.")
269 po::value<int>()->default_value(0),
272 po::value< Strings_t >()->composing(),
273 "preloading library")
276 "user-defined module to be imported by the genConf-generated one")
278 "do not generate the (empty) __init__.py")
283 po::options_description config(
"Configuration");
285 (
"configurable-module",
286 po::value<string>()->default_value(
"AthenaCommon"),
287 "Name of the module holding the configurable classes")
288 (
"configurable-default-name",
289 po::value<string>()->default_value(
"Configurable.DefaultName"),
290 "Default name for the configurable instance")
291 (
"configurable-algorithm",
292 po::value<string>()->default_value(
"ConfigurableAlgorithm"),
293 "Name of the configurable base class for Algorithm components")
294 (
"configurable-algtool",
295 po::value<string>()->default_value(
"ConfigurableAlgTool"),
296 "Name of the configurable base class for AlgTool components")
297 (
"configurable-auditor",
298 po::value<string>()->default_value(
"ConfigurableAuditor"),
299 "Name of the configurable base class for Auditor components")
300 (
"configurable-service",
301 po::value<string>()->default_value(
"ConfigurableService"),
302 "Name of the configurable base class for Service components")
305 po::options_description cmdline_options;
306 cmdline_options.add(
generic).add(config);
308 po::options_description config_file_options;
309 config_file_options.add(config);
311 po::options_description visible(
"Allowed options");
312 visible.add(
generic).add(config);
314 po::variables_map vm;
317 po::store( po::command_line_parser(
argc,
argv).
318 options(cmdline_options).run(),
324 if( vm.count(
"input-cfg") ) {
325 string cfgFileName = vm[
"input-cfg"].as<
string>();
326 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).string();
327 std::ifstream ifs( cfgFileName );
328 po::store( parse_config_file( ifs, config_file_options ), vm );
333 catch ( po::error& err ) {
335 <<
"error detected while parsing command options: "
341 if( vm.count(
"help")) {
342 cout << visible << endl;
346 if( vm.count(
"package-name") ) {
347 pkgName = vm[
"package-name"].as<
string>();
351 cout << visible << endl;
355 if( vm.count(
"user-module") ) {
356 userModule = vm[
"user-module"].as<
string>();
357 LOG_INFO <<
"INFO: will import user module " << userModule;
360 if( vm.count(
"input-libraries") ) {
366 string tmp = vm[
"input-libraries"].as<
string>();
368 boost::split( inputLibs, tmp,
369 boost::is_any_of(
" "),
370 boost::token_compress_on );
374 libs.reserve( inputLibs.size() );
375 for ( Strings_t::const_iterator iLib = inputLibs.begin();
376 iLib != inputLibs.end();
378 std::string lib =
fs::path(*iLib).stem().string();
379 if ( 0 == lib.find(
"lib") ) {
384 std::find( libs.begin(), libs.end(), lib ) == libs.end() ) {
385 libs.push_back( lib );
388 if ( libs.empty() ) {
389 LOG_ERROR <<
"input component library(ies) required !\n";
390 LOG_ERROR <<
"'input-libraries' argument was ["
391 << vm[
"input-libraries"].as<
string>()
397 LOG_ERROR <<
"input component library(ies) required";
398 cout << visible << endl;
402 if( vm.count(
"output-dir") ) {
403 out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) );
406 if ( vm.count(
"debug-level") ) {
410 if ( vm.count(
"load-library") ) {
412 for (Strings_t::const_iterator lLib=lLib_list.begin();
413 lLib != lLib_list.end();
425 if ( !fs::exists( out ) ) {
427 fs::create_directory(out);
429 catch ( fs::filesystem_error &err ) {
430 LOG_ERROR <<
"error creating directory: "<< err.what();
436 std::ostringstream
msg;
437 msg <<
":::::: libraries : [ ";
438 copy( libs.begin(), libs.end(), ostream_iterator<string>(
msg,
" ") );
445 py.setConfigurableDefaultName(vm[
"configurable-default-name"].as<string>());
446 py.setConfigurableAlgorithm (vm[
"configurable-algorithm"].as<string>());
447 py.setConfigurableAlgTool (vm[
"configurable-algtool"].as<string>());
448 py.setConfigurableAuditor (vm[
"configurable-auditor"].as<string>());
449 py.setConfigurableService (vm[
"configurable-service"].as<string>());
451 int sc = EXIT_FAILURE;
453 sc = py.genConfig( libs, userModule );
455 catch ( exception& e ) {
456 cout <<
"ERROR: Could not generate Configurable(s) !\n"
457 <<
"ERROR: Got exception: " << e.what() << endl;
461 if ( EXIT_SUCCESS == sc && ! vm.count(
"no-init")) {
463 fstream initPy( ( out /
fs::path(
"__init__.py" ) ).
string(),
464 std::ios_base::out|std::ios_base::trunc );
465 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" << flush;
469 std::ostringstream
msg;
470 msg <<
":::::: libraries : [ ";
471 copy( libs.begin(), libs.end(), ostream_iterator<string>(
msg,
" ") );
472 msg <<
"] :::::: [DONE]";
std::vector< std::string > Strings_t
void * ImageHandle
Definition of an image handle.
GAUDI_API long argc()
Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
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.