2 #include <msp/builder/builder.h>
3 #include <msp/builder/component.h>
4 #include <msp/builder/objectfile.h>
5 #include <msp/builder/sourcepackage.h>
6 #include <msp/builder/staticlibrary.h>
7 #include <msp/fs/path.h>
8 #include <msp/fs/utils.h>
9 #include "gnuarchiver.h"
14 GnuArchiver::GnuArchiver(Builder &b, const Architecture &a):
17 set_command("ar", true);
18 input_suffixes.push_back(".o");
19 processing_unit = COMPONENT;
20 set_run_external(_run);
23 Target *GnuArchiver::create_target(const vector<Target *> &sources, const string &)
26 throw invalid_argument("GnuArchiver::create_target");
28 vector<ObjectFile *> objs;
29 objs.reserve(sources.size());
30 for(Target *s: sources)
31 objs.push_back(&dynamic_cast<ObjectFile &>(*s));
33 const Component &comp = *objs.front()->get_component();
34 StaticLibrary *lib = new StaticLibrary(builder, comp, objs);
39 ExternalTask::Arguments GnuArchiver::_run(const StaticLibrary &lib, FS::Path &work_dir)
41 const Tool &tool = *lib.get_tool();
44 argv.push_back(tool.get_executable()->get_path().str());
47 argv.push_back(relative(lib.get_path(), work_dir).str());
49 for(Target *d: lib.get_dependencies())
50 if(ObjectFile *obj = dynamic_cast<ObjectFile *>(d))
51 argv.push_back(relative(obj->get_path(), work_dir).str());