]> git.tdb.fi Git - builder.git/blobdiff - source/gnulinker.cpp
Store a target representing the executable in each tool
[builder.git] / source / gnulinker.cpp
index 6eef8b3268da567f17385307e5c3022825fcd68a..32f2bf3bb1843c72b3d4249541bccfcd8359eb55 100644 (file)
@@ -7,7 +7,7 @@
 #include "component.h"
 #include "executable.h"
 #include "externaltask.h"
-#include "gnucxxcompiler.h"
+#include "gnucompiler.h"
 #include "gnulinker.h"
 #include "objectfile.h"
 #include "sharedlibrary.h"
@@ -83,12 +83,20 @@ Task *GnuLinker::run(const Target &) const
 GnuLinker::Linker::Linker(GnuLinker &p, const string &compiler_tag):
        SubTool(p)
 {
-       if(compiler_tag=="CC")
-               command = "gcc";
-       else if(compiler_tag=="CXX")
-               command = "g++";
+       const Tool &compiler = builder.get_toolchain().get_tool(compiler_tag);
+       if(dynamic_cast<const GnuCompiler *>(&compiler))
+               executable = compiler.get_executable();
        else
-               throw invalid_argument("GnuLinker::Linker::Linker");
+       {
+               string command;
+               if(compiler_tag=="CC")
+                       command = "gcc";
+               else if(compiler_tag=="CXX")
+                       command = "g++";
+               else
+                       throw invalid_argument("GnuLinker::Linker::Linker");
+               executable = builder.get_vfs().find_binary(command);
+       }
 }
 
 Target *GnuLinker::Linker::create_target(const list<Target *> &sources, const string &arg) const
@@ -101,7 +109,7 @@ Task *GnuLinker::Linker::run(const Target &target) const
        const Binary &bin = dynamic_cast<const Binary &>(target);
 
        vector<string> argv;
-       argv.push_back(command);
+       argv.push_back(executable->get_path().str());
 
        const Component &comp = *bin.get_component();