]> git.tdb.fi Git - builder.git/blobdiff - source/gnuarchiver.cpp
Redesign how tools are run
[builder.git] / source / gnuarchiver.cpp
index 742278de668653f17895abab2e6d003fc9698e16..2f5ba24d6068d7c3f9c5d695b502a87d955f3d5c 100644 (file)
@@ -19,21 +19,18 @@ GnuArchiver::GnuArchiver(Builder &b, const Architecture &a):
        set_command("ar", true);
        input_suffixes.push_back(".o");
        processing_unit = COMPONENT;
+       set_run(_run);
 }
 
-Target *GnuArchiver::create_target(const list<Target *> &sources, const string &)
+Target *GnuArchiver::create_target(const vector<Target *> &sources, const string &)
 {
        if(sources.empty())
                throw invalid_argument("GnuArchiver::create_target");
 
-       list<ObjectFile *> objs;
+       vector<ObjectFile *> objs;
+       objs.reserve(sources.size());
        for(Target *s: sources)
-       {
-               if(ObjectFile *obj = dynamic_cast<ObjectFile *>(s))
-                       objs.push_back(obj);
-               else
-                       throw invalid_argument("GnuArchiver::create_target");
-       }
+               objs.push_back(&dynamic_cast<ObjectFile &>(*s));
 
        const Component &comp = *objs.front()->get_component();
        StaticLibrary *lib = new StaticLibrary(builder, comp, objs);
@@ -41,13 +38,13 @@ Target *GnuArchiver::create_target(const list<Target *> &sources, const string &
        return lib;
 }
 
-Task *GnuArchiver::run(const Target &target) const
+Task *GnuArchiver::_run(const StaticLibrary &lib)
 {
-       const StaticLibrary &lib = dynamic_cast<const StaticLibrary &>(target);
+       const Tool &tool = *lib.get_tool();
        const Component &comp = *lib.get_component();
 
        vector<string> argv;
-       argv.push_back(executable->get_path().str());
+       argv.push_back(tool.get_executable()->get_path().str());
        argv.push_back("rc");
 
        FS::Path work_dir = comp.get_package().get_source_directory();