]> git.tdb.fi Git - builder.git/blobdiff - source/gnuarchiver.cpp
Store a target representing the executable in each tool
[builder.git] / source / gnuarchiver.cpp
index 8eab751e7ad405faf49951bff4f763fd003303d6..13b2054ff5f26d2ea9006b3513d17e924b28faf9 100644 (file)
@@ -16,6 +16,8 @@ using namespace Msp;
 GnuArchiver::GnuArchiver(Builder &b):
        Tool(b, "AR")
 {
+       executable = builder.get_vfs().find_binary("ar");
+
        input_suffixes.push_back(".o");
 }
 
@@ -30,7 +32,7 @@ Target *GnuArchiver::create_target(const list<Target *> &sources, const string &
                if(ObjectFile *obj = dynamic_cast<ObjectFile *>(*i))
                        objs.push_back(obj);
                else
-                       throw invalid_argument("GnuLinker::create_target");
+                       throw invalid_argument("GnuArchiver::create_target");
        }
 
        const Component &comp = objs.front()->get_component();
@@ -42,18 +44,18 @@ Target *GnuArchiver::create_target(const list<Target *> &sources, const string &
 Task *GnuArchiver::run(const Target &target) const
 {
        const StaticLibrary &lib = dynamic_cast<const StaticLibrary &>(target);
-       const Component &comp = lib.get_component();
+       const Component &comp = *lib.get_component();
 
        vector<string> 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();
 
        argv.push_back(relative(lib.get_path(), work_dir).str());
 
-       const TargetList &deps = lib.get_depends();
-       for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+       const Target::Dependencies &deps = lib.get_depends();
+       for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i)
                if(ObjectFile *obj = dynamic_cast<ObjectFile *>(*i))
                        argv.push_back(relative(obj->get_path(), work_dir).str());