delete cxx_linker;
}
-Target *GnuLinker::create_target(const list<Target *> &sources, const string &arg) const
+Target *GnuLinker::create_target(const list<Target *> &sources, const string &arg)
{
if(sources.empty())
throw invalid_argument("GnuLinker::create_target");
SharedLibrary *shlib = new SharedLibrary(builder, comp, objs);
if(architecture->get_system()=="windows")
{
- const Tool &dlltool = builder.get_toolchain().get_tool("DLL");
+ Tool &dlltool = builder.get_toolchain().get_tool("DLL");
dlltool.create_target(*shlib);
}
bin = shlib;
{
if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(&target))
{
- const Tool © = builder.get_toolchain().get_tool("CP");
+ Tool © = builder.get_toolchain().get_tool("CP");
InstalledFile *inst_tgt = dynamic_cast<InstalledFile *>(copy.create_target(target));
if(architecture->get_system()=="windows")
builder.get_build_graph().add_installed_target(*shlib->get_import_library());
}
-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);
- }
-}
+GnuLinker::Linker::Linker(GnuLinker &p, const string &ct):
+ SubTool(p),
+ compiler_tag(ct)
+{ }
-Target *GnuLinker::Linker::create_target(const list<Target *> &sources, const string &arg) const
+Target *GnuLinker::Linker::create_target(const list<Target *> &sources, const string &arg)
{
return parent.create_target(sources, arg);
}
return result;
}
+void GnuLinker::Linker::do_prepare()
+{
+ Tool &compiler = builder.get_toolchain().get_tool(compiler_tag);
+ if(dynamic_cast<GnuCompiler *>(&compiler))
+ {
+ compiler.prepare();
+ 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");
+
+ set_executable(command, true);
+ }
+}
+
Task *GnuLinker::Linker::run(const Target &target) const
{
const Binary &bin = dynamic_cast<const Binary &>(target);