]> git.tdb.fi Git - builder.git/blobdiff - source/gnuarchiver.cpp
Refactor transitive dependencies to work on all targets
[builder.git] / source / gnuarchiver.cpp
diff --git a/source/gnuarchiver.cpp b/source/gnuarchiver.cpp
deleted file mode 100644 (file)
index 742278d..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#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;
-}
-
-Target *GnuArchiver::create_target(const list<Target *> &sources, const string &)
-{
-       if(sources.empty())
-               throw invalid_argument("GnuArchiver::create_target");
-
-       list<ObjectFile *> objs;
-       for(Target *s: sources)
-       {
-               if(ObjectFile *obj = dynamic_cast<ObjectFile *>(s))
-                       objs.push_back(obj);
-               else
-                       throw invalid_argument("GnuArchiver::create_target");
-       }
-
-       const Component &comp = *objs.front()->get_component();
-       StaticLibrary *lib = new StaticLibrary(builder, comp, objs);
-       lib->set_tool(*this);
-       return lib;
-}
-
-Task *GnuArchiver::run(const Target &target) const
-{
-       const StaticLibrary &lib = dynamic_cast<const StaticLibrary &>(target);
-       const Component &comp = *lib.get_component();
-
-       vector<string> argv;
-       argv.push_back(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);
-}