208 std::string userModule;
211 po::options_description
generic(
"Generic options");
212 generic.add_options()
214 "produce this help message")
217 "name of the package for which we create the configurables file")
218 (
"input-libraries,i",
220 "libraries to extract the component configurables from")
223 "path to the cfg file holding the description of the Configurable base "
224 "classes, the python module holding the Configurable definitions, etc...")
226 po::value<string>()->default_value(
"../genConf"),
227 "output directory for genconf files.")
229 po::value<int>()->default_value(0),
232 po::value< Strings_t >()->composing(),
233 "preloading library")
236 "user-defined module to be imported by the genConf-generated one")
238 "do not generate the (empty) __init__.py")
243 po::options_description config(
"Configuration");
245 (
"configurable-module",
246 po::value<string>()->default_value(
"AthenaCommon"),
247 "Name of the module holding the configurable classes")
248 (
"configurable-default-name",
249 po::value<string>()->default_value(
"Configurable.DefaultName"),
250 "Default name for the configurable instance")
251 (
"configurable-algorithm",
252 po::value<string>()->default_value(
"ConfigurableAlgorithm"),
253 "Name of the configurable base class for Algorithm components")
254 (
"configurable-algtool",
255 po::value<string>()->default_value(
"ConfigurableAlgTool"),
256 "Name of the configurable base class for AlgTool components")
257 (
"configurable-auditor",
258 po::value<string>()->default_value(
"ConfigurableAuditor"),
259 "Name of the configurable base class for Auditor components")
260 (
"configurable-service",
261 po::value<string>()->default_value(
"ConfigurableService"),
262 "Name of the configurable base class for Service components")
265 po::options_description cmdline_options;
266 cmdline_options.add(
generic).add(config);
268 po::options_description config_file_options;
269 config_file_options.add(config);
271 po::options_description visible(
"Allowed options");
272 visible.add(
generic).add(config);
274 po::variables_map vm;
277 po::store( po::command_line_parser(
argc,
argv).
278 options(cmdline_options).run(),
284 if( vm.count(
"input-cfg") ) {
285 string cfgFileName = vm[
"input-cfg"].as<
string>();
286 cfgFileName = fs::system_complete(
fs::path( cfgFileName ) ).string();
287 std::ifstream ifs( cfgFileName.c_str() );
288 po::store( parse_config_file( ifs, config_file_options ), vm );
293 catch ( po::error& err ) {
294 cout <<
"ERROR: error detected while parsing command options: "<< err.what() << endl;
299 if( vm.count(
"help")) {
300 cout << visible << endl;
304 if( vm.count(
"package-name") ) {
305 pkgName = vm[
"package-name"].as<
string>();
308 cout <<
"ERROR: 'package-name' required" << endl;
309 cout << visible << endl;
313 if( vm.count(
"user-module") ) {
314 userModule = vm[
"user-module"].as<
string>();
315 cout <<
"INFO: will import user module " << userModule << endl;
318 if( vm.count(
"input-libraries") ) {
324 string tmp = vm[
"input-libraries"].as<
string>();
326 boost::split( inputLibs, tmp,
327 boost::is_any_of(
" "),
328 boost::token_compress_on );
332 libs.reserve( inputLibs.size() );
333 for ( Strings_t::const_iterator iLib = inputLibs.begin();
334 iLib != inputLibs.end();
336 std::string lib =
fs::path(*iLib).stem().string();
337 if ( 0 == lib.find(
"lib") ) {
342 std::find( libs.begin(), libs.end(), lib ) == libs.end() ) {
343 libs.push_back( lib );
346 if ( libs.empty() ) {
347 cout <<
"ERROR: input component library(ies) required !\n"
348 <<
"ERROR: 'input-libraries' argument was ["
349 << vm[
"input-libraries"].as<
string>()
356 cout <<
"ERROR: input component library(ies) required" << endl;
357 cout << visible << endl;
361 if( vm.count(
"output-dir") ) {
362 out = fs::system_complete(
fs::path( vm[
"output-dir"].as<string>() ) );
365 if ( vm.count(
"debug-level") ) {
369 if ( vm.count(
"load-library") ) {
371 for (Strings_t::const_iterator lLib=lLib_list.begin();
372 lLib != lLib_list.end();
378 cout <<
"WARNING: failed to load: "<< *lLib << endl;
384 if ( !fs::exists( out ) ) {
386 fs::create_directory(out);
388 catch ( fs::filesystem_error &err ) {
389 cout <<
"ERROR: error creating directory: "<< err.what() << endl;
394 cout <<
":::::: libraries : [ ";
395 copy( libs.begin(), libs.end(), ostream_iterator<string>(cout,
" ") );
396 cout <<
"] ::::::" << endl;
400 py.setConfigurableDefaultName(vm[
"configurable-default-name"].as<string>());
401 py.setConfigurableAlgorithm (vm[
"configurable-algorithm"].as<string>());
402 py.setConfigurableAlgTool (vm[
"configurable-algtool"].as<string>());
403 py.setConfigurableAuditor (vm[
"configurable-auditor"].as<string>());
404 py.setConfigurableService (vm[
"configurable-service"].as<string>());
406 int sc = EXIT_FAILURE;
408 sc = py.genConfig( libs, userModule );
410 catch ( exception& e ) {
411 cout <<
"ERROR: Could not generate Configurable(s) !\n"
412 <<
"ERROR: Got exception: " << e.what() << endl;
416 if ( EXIT_SUCCESS == sc && ! vm.count(
"no-init")) {
418 fstream initPy( ( out /
fs::path(
"__init__.py" ) ).
string().c_str(),
419 std::ios_base::out|std::ios_base::trunc );
420 initPy <<
"## Hook for " << pkgName <<
" genConf module\n" << flush;
423 cout <<
":::::: libraries : [ ";
424 copy( libs.begin(), libs.end(), ostream_iterator<string>(cout,
" ") );
425 cout <<
"] :::::: [DONE]" << endl;
GAUDI_API long argc()
Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
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
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.