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);
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();