Skip to content
Snippets Groups Projects
Commit f5f62a29 authored by Markus Frank's avatar Markus Frank
Browse files

Fix plugin runner to properly accept arguments

parent 08c718c5
No related branches found
No related tags found
No related merge requests found
...@@ -28,28 +28,19 @@ namespace { ...@@ -28,28 +28,19 @@ namespace {
//______________________________________________________________________________ //______________________________________________________________________________
int main(int argc,char** argv) { int main(int argc,char** argv) {
char plugin_runner[64] = "plugin_runner";
string plugin;
Args arguments; Args arguments;
vector<const char*> options;
options.push_back(plugin_runner);
for(int i=1; i<argc;++i) { for(int i=1; i<argc;++i) {
if ( argv[i][0]=='-' ) { if ( argv[i][0]=='-' ) {
if ( arguments.handle(i,argc,argv) ) if ( arguments.handle(i,argc,argv) )
continue; continue;
else if ( strncmp(argv[i],"-plugin",2)==0 )
plugin = argv[++i];
else
options.push_back(argv[i]);
} }
else { else {
usage(); usage();
} }
} }
if ( plugin.empty() ) if ( arguments.plugins.empty() )
usage(); usage();
options.push_back(0);
LCDD& lcdd = dd4hep_instance(); LCDD& lcdd = dd4hep_instance();
// Load compact files if required by plugin // Load compact files if required by plugin
if ( !arguments.geo_files.empty() ) { if ( !arguments.geo_files.empty() ) {
...@@ -61,7 +52,11 @@ int main(int argc,char** argv) { ...@@ -61,7 +52,11 @@ int main(int argc,char** argv) {
// Create volume manager and populate it required // Create volume manager and populate it required
if ( arguments.volmgr ) run_plugin(lcdd,"DD4hepVolumeManager",0,0); if ( arguments.volmgr ) run_plugin(lcdd,"DD4hepVolumeManager",0,0);
// Execute plugin // Execute plugin
run_plugin(lcdd,plugin.c_str(),(int)(options.size()-1),(char**)&options[0]); for(size_t i=0; i<arguments.plugins.size(); ++i) {
std::vector<const char*>& plug = arguments.plugins[i];
int num_arg = int(plug.size())-2;
run_plugin(lcdd,plug[0], num_arg,(char**)&plug[1]);
}
if ( arguments.destroy ) delete &lcdd; if ( arguments.destroy ) delete &lcdd;
return 0; return 0;
} }
...@@ -147,10 +147,11 @@ namespace { ...@@ -147,10 +147,11 @@ namespace {
// Need to interprete plugin args here locally..... // Need to interprete plugin args here locally.....
plugins.push_back(std::vector<const char*>()); plugins.push_back(std::vector<const char*>());
plugins.back().push_back(argv[++i]); plugins.back().push_back(argv[++i]);
for(; i<argc; ++i) { for( ++i; i < argc; ++i ) {
if ( argv[i][0]=='-' ) { --i; break; } if ( argv[i][0]=='-' ) { --i; break; }
plugins.back().push_back(argv[i]); plugins.back().push_back(argv[i]);
} }
plugins.back().push_back(0);
} }
else else
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment