]> git.tdb.fi Git - builder.git/commitdiff
Use package directory as work dir for ExternalActions and make filename arguments...
authorMikko Rasa <tdb@tdb.fi>
Tue, 20 May 2008 12:02:55 +0000 (12:02 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 20 May 2008 12:02:55 +0000 (12:02 +0000)
Do not use static libraries when linking dynamic ones

source/archive.cpp
source/compile.cpp
source/executable.cpp
source/externalaction.cpp
source/externalaction.h
source/link.cpp
source/sourcepackage.h

index a018dc9235c4421351003565cb4e6a2c1c438af9..63d1635bee578e37f0bf6c75c786ebcf6294e168 100644 (file)
@@ -21,21 +21,23 @@ Archive::Archive(Builder &b, const StaticLibrary &lib):
 {
        const Component &comp=lib.get_component();
 
+       work_dir=comp.get_package().get_source();
+
        std::string tool="AR";
        argv.push_back(builder.get_current_arch().get_tool(tool));
        argv.push_back("rc");
 
-       argv.push_back(lib.get_name());
+       argv.push_back(relative(lib.get_name(), work_dir).str());
        const TargetList &deps=lib.get_depends();
        for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
                if(dynamic_cast<ObjectFile *>(*i))
-                       argv.push_back((*i)->get_name());
+                       argv.push_back(relative((*i)->get_name(), work_dir).str());
 
        Path lpath=lib.get_name();
        if(!builder.get_dry_run())
                mkpath(lpath.subpath(0, lpath.size()-1), 0755);
 
-       announce(comp.get_package().get_name(), tool, relative(lpath, comp.get_package().get_source()).str());
+       announce(comp.get_package().get_name(), tool, relative(lpath, work_dir).str());
 
        launch();
 }
index 53802639dae7786675aff8e9ff994582bed2334b..efa20efea3a6af31b9003a99396ac66be018f992 100644 (file)
@@ -21,6 +21,8 @@ Compile::Compile(Builder &b, const ObjectFile &obj):
 {
        const Component &comp=obj.get_component();
 
+       work_dir=comp.get_package().get_source();
+
        const TargetList &deps=obj.get_depends();
        Path spath=deps.front()->get_name();
 
@@ -44,13 +46,13 @@ Compile::Compile(Builder &b, const ObjectFile &obj):
 
        Path opath=obj.get_name();
        argv.push_back("-o");
-       argv.push_back(opath.str());
-       argv.push_back(spath.str());
+       argv.push_back(relative(opath, work_dir).str());
+       argv.push_back(relative(spath, work_dir).str());
 
        if(!builder.get_dry_run())
                mkpath(opath.subpath(0, opath.size()-1), 0755);
 
-       announce(comp.get_package().get_name(), tool, relative(opath, comp.get_package().get_source()).str());
+       announce(comp.get_package().get_name(), tool, relative(opath, work_dir).str());
 
        launch();
 }
index ea2f4e0204684cb94ea25799fcd57e50a8029040..488dd2966a27279e1d85ac8100f1be51977fdafd 100644 (file)
@@ -14,6 +14,7 @@ Distributed under the LGPL
 #include "link.h"
 #include "objectfile.h"
 #include "package.h"
+#include "sharedlibrary.h"
 #include "staticlibrary.h"
 
 using namespace std;
@@ -34,6 +35,8 @@ Finds and adds any required libraries to the dependencies.
 void Executable::find_depends()
 {
        LibMode libmode=comp.get_package().get_library_mode();
+       if(dynamic_cast<SharedLibrary *>(this))
+               libmode=DYNAMIC;
 
        list<const Component *> queue;
        list<Target *> dep_libs;
index bde453f8c18b7321d0835ad54ce3913f93e0dfce..54c9acc1274fed39f2b01c79aafeabdaa8d6d4bd 100644 (file)
@@ -7,6 +7,7 @@ Distributed under the LGPL
 
 #include <sys/wait.h>
 #include <iostream>
+#include <msp/path/utils.h>
 #include "builder.h"
 #include "externalaction.h"
 
@@ -69,6 +70,8 @@ void ExternalAction::launch()
                                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);
index c9c3bf53b08cd2320f7440d28023385019924f2e..232e0847c1770dd0c3dec2d586758e7cc080c6b7 100644 (file)
@@ -22,6 +22,7 @@ public:
        int check();
 protected:
        StringList argv;
+       Msp::Path  work_dir;
        int        pid;
        int        exit_code;
        
index 7d37ac4f619685ccaf4ffea257953480cad805a5..910387e2299b7c55b1d224b6a1b75853673a40ab 100644 (file)
@@ -25,6 +25,8 @@ Link::Link(Builder &b, const Executable &exe):
 {
        const Component &comp=exe.get_component();
 
+       work_dir=comp.get_package().get_source();
+
        //XXX Determine whether to use g++ or gcc
        string tool="LXX";
        argv.push_back(builder.get_current_arch().get_tool(tool));
@@ -41,7 +43,7 @@ Link::Link(Builder &b, const Executable &exe):
                argv.push_back("-L"+*i);
 
        argv.push_back("-o");
-       argv.push_back(exe.get_name());
+       argv.push_back(relative(exe.get_name(), work_dir).str());
        const TargetList &deps=exe.get_depends();
        for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
        {
@@ -50,11 +52,11 @@ Link::Link(Builder &b, const Executable &exe):
                        tgt=tgt->get_depends().front();
 
                if(dynamic_cast<ObjectFile *>(tgt))
-                       argv.push_back((*i)->get_name());
+                       argv.push_back(relative((*i)->get_name(), work_dir).str());
                else if(SharedLibrary *shlib=dynamic_cast<SharedLibrary *>(tgt))
                        argv.push_back("-l"+shlib->get_libname());
                else if(dynamic_cast<StaticLibrary *>(tgt))
-                       argv.push_back((*i)->get_name());
+                       argv.push_back(relative((*i)->get_name(), work_dir).str());
                else if(SystemLibrary *syslib=dynamic_cast<SystemLibrary *>(tgt))
                        argv.push_back("-l"+syslib->get_libname());
        }
@@ -63,7 +65,7 @@ Link::Link(Builder &b, const Executable &exe):
        if(!builder.get_dry_run())
                mkpath(epath.subpath(0, epath.size()-1), 0755);
 
-       announce(comp.get_package().get_name(), tool, relative(epath, comp.get_package().get_source()).str());
+       announce(comp.get_package().get_name(), tool, relative(epath, work_dir).str());
 
        launch();
 }
index 3b6ef11d845bb36262f776817fa9a44859c19bf7..bcdd74cbbfb30aae55b60e0ec9971720efc529b5 100644 (file)
@@ -51,7 +51,6 @@ public:
        };
 
        SourcePackage(Builder &, const std::string &, const Msp::Path &);
-       void                set_path(const Msp::Path &);
        const std::string   &get_name() const           { return name; }
        const std::string   &get_version() const        { return version; }
        const std::string   &get_description() const    { return description; }