]> git.tdb.fi Git - builder.git/blobdiff - source/gnucompiler.cpp
Add gcc's private library directory to ClangLinker's system path
[builder.git] / source / gnucompiler.cpp
index beff9f9a5674e3735e9fe7abeb7bc98c9bcce930..3236631d756d69b10a0fc0172b4f580972d0a863 100644 (file)
@@ -6,7 +6,6 @@
 #include "builder.h"
 #include "component.h"
 #include "csourcefile.h"
-#include "externaltask.h"
 #include "gnucompiler.h"
 #include "objcsourcefile.h"
 #include "objectfile.h"
@@ -50,7 +49,7 @@ GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t):
                throw invalid_argument("GnuCompiler::GnuCompiler");
 
        set_command((tag=="CXX" ? "g++" : "gcc"), true);
-       set_run(_run);
+       set_run_external(_run);
 }
 
 Target *GnuCompiler::create_source(const Component &comp, const FS::Path &path) const
@@ -104,8 +103,12 @@ string GnuCompiler::create_build_signature(const BuildInfo &binfo) const
 
 void GnuCompiler::do_prepare(ToolData &tool) const
 {
+       tool.extra_data = 0U;
        prepare_syspath(tool);
        prepare_version(tool);
+
+       if(tag=="CXX")
+               tool.build_info.libs.push_back("stdc++");
 }
 
 void GnuCompiler::prepare_syspath(ToolData &tool) const
@@ -194,23 +197,22 @@ unsigned GnuCompiler::query_version(const string &exe_path, const string &arg) c
        argv.push_back(arg);
 
        builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
+       unsigned ver = 0;
        try
        {
                string version_str = strip(ExternalTask::run_and_capture_output(argv));
 
                vector<string> version_parts = split(version_str, '.');
-               unsigned ver = 0;
                for(unsigned i=0; (i<3 && i<version_parts.size()); ++i)
                        ver |= lexical_cast<unsigned>(version_parts[i])<<(16-8*i);
-               return ver;
        }
        catch(const runtime_error &)
        { }
 
-       return 0;
+       return ver;
 }
 
-Task *GnuCompiler::_run(const ObjectFile &object)
+ExternalTask::Arguments GnuCompiler::_run(const ObjectFile &object, FS::Path &work_dir)
 {
        const Tool &tool = *object.get_tool();
        const Architecture &arch = *tool.get_architecture();
@@ -342,11 +344,10 @@ Task *GnuCompiler::_run(const ObjectFile &object)
 
        FS::Path obj_path = object.get_path();
        FS::Path src_path = object.get_source().get_path();
-       FS::Path work_dir = object.get_component()->get_package().get_source_directory();
 
        argv.push_back("-o");
        argv.push_back(relative(obj_path, work_dir).str());
        argv.push_back(relative(src_path, work_dir).str());
 
-       return new ExternalTask(argv, work_dir);
+       return argv;
 }