From 4c11e2a041d2064f44b7eb3dbf1976c35fc8881c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 20 May 2008 12:02:55 +0000 Subject: [PATCH] Use package directory as work dir for ExternalActions and make filename arguments relative to it Do not use static libraries when linking dynamic ones --- source/archive.cpp | 8 +++++--- source/compile.cpp | 8 +++++--- source/executable.cpp | 3 +++ source/externalaction.cpp | 3 +++ source/externalaction.h | 1 + source/link.cpp | 10 ++++++---- source/sourcepackage.h | 1 - 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/source/archive.cpp b/source/archive.cpp index a018dc9..63d1635 100644 --- a/source/archive.cpp +++ b/source/archive.cpp @@ -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(*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(); } diff --git a/source/compile.cpp b/source/compile.cpp index 5380263..efa20ef 100644 --- a/source/compile.cpp +++ b/source/compile.cpp @@ -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(); } diff --git a/source/executable.cpp b/source/executable.cpp index ea2f4e0..488dd29 100644 --- a/source/executable.cpp +++ b/source/executable.cpp @@ -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(this)) + libmode=DYNAMIC; list queue; list dep_libs; diff --git a/source/externalaction.cpp b/source/externalaction.cpp index bde453f..54c9acc 100644 --- a/source/externalaction.cpp +++ b/source/externalaction.cpp @@ -7,6 +7,7 @@ Distributed under the LGPL #include #include +#include #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 "<get_depends().front(); if(dynamic_cast(tgt)) - argv.push_back((*i)->get_name()); + argv.push_back(relative((*i)->get_name(), work_dir).str()); else if(SharedLibrary *shlib=dynamic_cast(tgt)) argv.push_back("-l"+shlib->get_libname()); else if(dynamic_cast(tgt)) - argv.push_back((*i)->get_name()); + argv.push_back(relative((*i)->get_name(), work_dir).str()); else if(SystemLibrary *syslib=dynamic_cast(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(); } diff --git a/source/sourcepackage.h b/source/sourcepackage.h index 3b6ef11..bcdd74c 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -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; } -- 2.43.0