1 #include <msp/fs/dir.h>
2 #include <msp/fs/stat.h>
3 #include <msp/fs/utils.h>
7 #include "gnuarchiver.h"
8 #include "objectfile.h"
9 #include "sourcepackage.h"
10 #include "staticlibrary.h"
15 GnuArchiver::GnuArchiver(Builder &b, const Architecture &a):
18 set_command("ar", true);
19 input_suffixes.push_back(".o");
20 processing_unit = COMPONENT;
21 set_run_external(_run);
24 Target *GnuArchiver::create_target(const vector<Target *> &sources, const string &)
27 throw invalid_argument("GnuArchiver::create_target");
29 vector<ObjectFile *> objs;
30 objs.reserve(sources.size());
31 for(Target *s: sources)
32 objs.push_back(&dynamic_cast<ObjectFile &>(*s));
34 const Component &comp = *objs.front()->get_component();
35 StaticLibrary *lib = new StaticLibrary(builder, comp, objs);
40 ExternalTask::Arguments GnuArchiver::_run(const StaticLibrary &lib, FS::Path &work_dir)
42 const Tool &tool = *lib.get_tool();
45 argv.push_back(tool.get_executable()->get_path().str());
48 argv.push_back(relative(lib.get_path(), work_dir).str());
50 for(Target *d: lib.get_dependencies())
51 if(ObjectFile *obj = dynamic_cast<ObjectFile *>(d))
52 argv.push_back(relative(obj->get_path(), work_dir).str());