GnuArchiver::GnuArchiver(Builder &b):
Tool(b, "AR")
{
+ executable = builder.get_vfs().find_binary("ar");
+
input_suffixes.push_back(".o");
}
const Component &comp = *lib.get_component();
vector<string> argv;
- argv.push_back("ar");
+ argv.push_back(executable->get_path().str());
argv.push_back("rc");
FS::Path work_dir = comp.get_package().get_source();
Tool(b, t),
name(n)
{
+ executable = builder.get_vfs().find_binary(name);
+
const Architecture &arch = builder.get_current_arch();
if(arch.is_native())
system_path.push_back("/usr/include");
const Component &comp = object.get_component();
ExternalTask::Arguments argv;
- argv.push_back(name);
+ argv.push_back(executable->get_path().str());
argv.push_back("-c");
const BuildInfo &binfo = comp.get_build_info();
#include "component.h"
#include "executable.h"
#include "externaltask.h"
-#include "gnucxxcompiler.h"
+#include "gnucompiler.h"
#include "gnulinker.h"
#include "objectfile.h"
#include "sharedlibrary.h"
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
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();
private:
class Linker: public SubTool
{
- private:
- std::string command;
-
public:
Linker(GnuLinker &, const std::string &);
Tool::Tool(Builder &b, const string &t):
builder(b),
- tag(t)
+ tag(t),
+ executable(0)
{ }
bool Tool::accepts_suffix(const string &suffix, bool aux) const
class Builder;
class Component;
+class FileTarget;
class Target;
class Task;
protected:
Builder &builder;
std::string tag;
+ FileTarget *executable;
SuffixList input_suffixes;
SuffixList aux_suffixes;
SearchPath system_path;
virtual ~Tool() { }
const std::string &get_tag() const { return tag; }
+ // XXX The executable target should be retrieved when first needed
+ FileTarget *get_executable() const { return executable; }
const SuffixList &get_input_suffixes() const { return input_suffixes; }
const SuffixList &get_auxiliary_suffixes() const { return aux_suffixes; }
bool accepts_suffix(const std::string &, bool = false) const;