X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgnuarchiver.cpp;h=742278de668653f17895abab2e6d003fc9698e16;hb=bc6d4c540e7132c829dd558ca9d8acfbde7d71e1;hp=3f56a2ea4e246e701bd4b18ade03104c4d797f3b;hpb=0b16c3de0f9dc01bd8a9708008f9435fe0252df1;p=builder.git diff --git a/source/gnuarchiver.cpp b/source/gnuarchiver.cpp index 3f56a2e..742278d 100644 --- a/source/gnuarchiver.cpp +++ b/source/gnuarchiver.cpp @@ -13,27 +13,29 @@ using namespace std; using namespace Msp; -GnuArchiver::GnuArchiver(Builder &b): - Tool(b, "AR") +GnuArchiver::GnuArchiver(Builder &b, const Architecture &a): + Tool(b, a, "AR") { + set_command("ar", true); input_suffixes.push_back(".o"); + processing_unit = COMPONENT; } -Target *GnuArchiver::create_target(const list &sources, const string &) const +Target *GnuArchiver::create_target(const list &sources, const string &) { if(sources.empty()) throw invalid_argument("GnuArchiver::create_target"); list objs; - for(list::const_iterator i=sources.begin(); i!=sources.end(); ++i) + for(Target *s: sources) { - if(ObjectFile *obj = dynamic_cast(*i)) + if(ObjectFile *obj = dynamic_cast(s)) objs.push_back(obj); else - throw invalid_argument("GnuLinker::create_target"); + throw invalid_argument("GnuArchiver::create_target"); } - const Component &comp = objs.front()->get_component(); + const Component &comp = *objs.front()->get_component(); StaticLibrary *lib = new StaticLibrary(builder, comp, objs); lib->set_tool(*this); return lib; @@ -42,27 +44,19 @@ Target *GnuArchiver::create_target(const list &sources, const string & Task *GnuArchiver::run(const Target &target) const { const StaticLibrary &lib = dynamic_cast(target); - const Component &comp = lib.get_component(); + const Component &comp = *lib.get_component(); vector argv; - argv.push_back("ar"); + argv.push_back(executable->get_path().str()); argv.push_back("rc"); - FS::Path work_dir = comp.get_package().get_source(); + FS::Path work_dir = comp.get_package().get_source_directory(); 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)) + for(Target *d: lib.get_dependencies()) + if(ObjectFile *obj = dynamic_cast(d)) 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); }