]> git.tdb.fi Git - builder.git/blobdiff - source/externalaction.cpp
Use package directory as work dir for ExternalActions and make filename arguments...
[builder.git] / source / externalaction.cpp
index 0ae68ff05f30bd297b314de7a77ac3e471192cb0..54c9acc1274fed39f2b01c79aafeabdaa8d6d4bd 100644 (file)
@@ -1,6 +1,13 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
 #include <sys/wait.h>
 #include <iostream>
-#include <msp/iter.h>
+#include <msp/path/utils.h>
 #include "builder.h"
 #include "externalaction.h"
 
@@ -14,7 +21,7 @@ int ExternalAction::check()
                signal_done.emit();
                return 0;
        }
-       
+
        if(!pid)
                return exit_code;
 
@@ -48,7 +55,7 @@ void ExternalAction::launch()
                }
                cout<<'\n';
        }
-       
+
        if(builder.get_dry_run())
                pid=-1;
        else
@@ -57,10 +64,16 @@ void ExternalAction::launch()
                if(pid==0)
                {
                        char *argv_[argv.size()+1];
-                       for(CountingIterator<string, StringList::iterator> i=argv.begin(); i!=argv.end(); ++i)
-                               argv_[i.count()]=strdup(i->c_str());
-                       argv_[argv.size()]=0;
+
+                       unsigned j=0;
+                       for(StringList::iterator i=argv.begin(); i!=argv.end(); ++i)
+                               argv_[j++]=strdup(i->c_str());
+                       argv_[j]=0;
+
+                       if(!work_dir.empty())
+                               chdir(work_dir);
                        execvp(argv_[0], argv_);
+                       cout<<"Couldn't execute "<<argv.front()<<'\n';
                        exit(1);
                }
                else if(pid<0)