- const Target::Dependencies &depends = target.get_depends();
- for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
- if(ObjectFile *obj = dynamic_cast<ObjectFile *>(*i))
- {
- const Tool *tool = obj->get_tool();
- if(dynamic_cast<const GnuCxxCompiler *>(tool))
- command = "g++";
- }
+GnuLinker::Linker::Linker(GnuLinker &p, const string &compiler_tag):
+ SubTool(p)
+{
+ const Tool &compiler = builder.get_toolchain().get_tool(compiler_tag);
+ if(dynamic_cast<const GnuCompiler *>(&compiler))
+ executable = compiler.get_executable();
+ else
+ {
+ string command;
+ if(compiler_tag=="CC")
+ command = "gcc";
+ else if(compiler_tag=="CXX")
+ command = "g++";
+ else
+ throw invalid_argument("GnuLinker::Linker::Linker");
+ if(architecture->is_cross())
+ command = format("%s-%s", architecture->get_cross_prefix(), command);
+ executable = builder.get_vfs().find_binary(command);
+ }
+}
+
+Target *GnuLinker::Linker::create_target(const list<Target *> &sources, const string &arg) const
+{
+ return parent.create_target(sources, arg);
+}
+
+string GnuLinker::Linker::create_build_signature(const BuildInfo &binfo) const
+{
+ string result = FS::basename(executable->get_path());
+ result += ',';
+ if(binfo.libmode<=BuildInfo::STATIC)
+ result += 't';
+ else
+ result += 'd';
+ if(binfo.strip)
+ result += 's';
+ result += ",l";
+ result += join(binfo.libs.begin(), binfo.libs.end(), ",l");
+ return result;
+}
+
+Task *GnuLinker::Linker::run(const Target &target) const
+{
+ const Binary &bin = dynamic_cast<const Binary &>(target);