X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgnuarchiver.cpp;h=170007028a5201f26bf64160402a2bab3f8bebd7;hb=HEAD;hp=13b2054ff5f26d2ea9006b3513d17e924b28faf9;hpb=3e8f3a5e852e9dd5b78ec3d89c722ef1bae6bef5;p=builder.git diff --git a/source/gnuarchiver.cpp b/source/gnuarchiver.cpp deleted file mode 100644 index 13b2054..0000000 --- a/source/gnuarchiver.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include -#include -#include -#include "builder.h" -#include "component.h" -#include "externaltask.h" -#include "gnuarchiver.h" -#include "objectfile.h" -#include "sourcepackage.h" -#include "staticlibrary.h" - -using namespace std; -using namespace Msp; - -GnuArchiver::GnuArchiver(Builder &b): - Tool(b, "AR") -{ - executable = builder.get_vfs().find_binary("ar"); - - input_suffixes.push_back(".o"); -} - -Target *GnuArchiver::create_target(const list &sources, const string &) const -{ - if(sources.empty()) - throw invalid_argument("GnuArchiver::create_target"); - - list objs; - for(list::const_iterator i=sources.begin(); i!=sources.end(); ++i) - { - if(ObjectFile *obj = dynamic_cast(*i)) - objs.push_back(obj); - else - throw invalid_argument("GnuArchiver::create_target"); - } - - const Component &comp = objs.front()->get_component(); - StaticLibrary *lib = new StaticLibrary(builder, comp, objs); - lib->set_tool(*this); - return lib; -} - -Task *GnuArchiver::run(const Target &target) const -{ - const StaticLibrary &lib = dynamic_cast(target); - const Component &comp = *lib.get_component(); - - vector argv; - argv.push_back(executable->get_path().str()); - argv.push_back("rc"); - - FS::Path work_dir = comp.get_package().get_source(); - - argv.push_back(relative(lib.get_path(), work_dir).str()); - - const Target::Dependencies &deps = lib.get_depends(); - for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i) - if(ObjectFile *obj = dynamic_cast(*i)) - argv.push_back(relative(obj->get_path(), work_dir).str()); - - if(!builder.get_dry_run()) - { - FS::mkpath(FS::dirname(lib.get_path()), 0755); - if(FS::exists(lib.get_path())) - FS::unlink(lib.get_path()); - } - - return new ExternalTask(argv, work_dir); -}