]> git.tdb.fi Git - builder.git/blobdiff - source/gnulinker.cpp
Rework Tool::prepare to be able to work on other objects than self
[builder.git] / source / gnulinker.cpp
index 2416449d63c5654a6f6dce62d6a620a6af1420c7..f37cf99cf766ae567ca4645b2df03886c9562cd3 100644 (file)
@@ -98,15 +98,17 @@ string GnuLinker::create_build_signature(const BuildInfo &binfo) const
        return result;
 }
 
-void GnuLinker::do_prepare()
+void GnuLinker::do_prepare(ToolData &tool) const
 {
        bool path_found = false;
-       const FS::Path &sysroot = build_info.sysroot;
+       const FS::Path &sysroot = tool.build_info.sysroot;
+       const std::string &tool_tag = static_cast<Tool &>(tool).get_tag();
 
-       if(executable)
+       const FileTarget *exe = static_cast<Tool &>(tool).get_executable();
+       if(exe)
        {
                ExternalTask::Arguments argv;
-               argv.push_back(executable->get_path().str());
+               argv.push_back(exe->get_path().str());
                argv.push_back("-Wl,--verbose");
                argv.push_back("-nostdlib");
                if(!sysroot.empty())
@@ -139,8 +141,8 @@ void GnuLinker::do_prepare()
                                }
 
                                path /= output.substr(search_dir, end-search_dir);
-                               builder.get_logger().log("tools", "Got %s system path: %s", tag, path);
-                               system_path.push_back(path);
+                               builder.get_logger().log("tools", "Got %s system path: %s", tool_tag, path);
+                               tool.system_path.push_back(path);
                                path_found = true;
 
                                start = end+3;
@@ -152,26 +154,26 @@ void GnuLinker::do_prepare()
 
        if(!path_found)
        {
-               builder.get_logger().log("tools", "No %s system path found, using defaults", tag);
+               builder.get_logger().log("tools", "No %s system path found, using defaults", tool_tag);
                if(!sysroot.empty())
-                       system_path.push_back(sysroot/"usr/lib");
+                       tool.system_path.push_back(sysroot/"usr/lib");
                else if(architecture->is_native())
                {
-                       system_path.push_back("/lib");
-                       system_path.push_back("/usr/lib");
+                       tool.system_path.push_back("/lib");
+                       tool.system_path.push_back("/usr/lib");
                        if(architecture->match_name("pc-32-linux"))
                        {
-                               system_path.push_back("/lib/i386-linux-gnu");
-                               system_path.push_back("/usr/lib/i386-linux-gnu");
+                               tool.system_path.push_back("/lib/i386-linux-gnu");
+                               tool.system_path.push_back("/usr/lib/i386-linux-gnu");
                        }
                        else if(architecture->match_name("pc-64-linux"))
                        {
-                               system_path.push_back("/lib/x86_64-linux-gnu");
-                               system_path.push_back("/usr/lib/x86_64-linux-gnu");
+                               tool.system_path.push_back("/lib/x86_64-linux-gnu");
+                               tool.system_path.push_back("/usr/lib/x86_64-linux-gnu");
                        }
                }
                else
-                       system_path.push_back(format("/usr/%s/lib", architecture->get_cross_prefix()));
+                       tool.system_path.push_back(format("/usr/%s/lib", architecture->get_cross_prefix()));
        }
 }