+++ /dev/null
-#include <msp/fs/dir.h>
-#include <msp/fs/stat.h>
-#include <msp/fs/utils.h>
-#include <stdexcept>
-#include "builder.h"
-#include "component.h"
-#include "externaltask.h"
-#include "gnuarchiver.h"
-#include "objectfile.h"
-#include "sourcepackage.h"
-#include "staticlibrary.h"
-
-using namespace std;
-using namespace Msp;
-
-GnuArchiver::GnuArchiver(Builder &b, const Architecture &a):
- Tool(b, &a, "AR")
-{
- set_command("ar", true);
- input_suffixes.push_back(".o");
- processing_unit = COMPONENT;
- set_run(_run);
-}
-
-Target *GnuArchiver::create_target(const vector<Target *> &sources, const string &)
-{
- if(sources.empty())
- throw invalid_argument("GnuArchiver::create_target");
-
- vector<ObjectFile *> objs;
- objs.reserve(sources.size());
- for(Target *s: sources)
- objs.push_back(&dynamic_cast<ObjectFile &>(*s));
-
- const Component &comp = *objs.front()->get_component();
- StaticLibrary *lib = new StaticLibrary(builder, comp, objs);
- lib->set_tool(*this);
- return lib;
-}
-
-Task *GnuArchiver::_run(const StaticLibrary &lib)
-{
- const Tool &tool = *lib.get_tool();
- const Component &comp = *lib.get_component();
-
- vector<string> argv;
- argv.push_back(tool.get_executable()->get_path().str());
- argv.push_back("rc");
-
- FS::Path work_dir = comp.get_package().get_source_directory();
-
- argv.push_back(relative(lib.get_path(), work_dir).str());
-
- for(Target *d: lib.get_dependencies())
- if(ObjectFile *obj = dynamic_cast<ObjectFile *>(d))
- argv.push_back(relative(obj->get_path(), work_dir).str());
-
- return new ExternalTask(argv, work_dir);
-}