]> git.tdb.fi Git - builder.git/blobdiff - source/gnulinker.cpp
Use dynamic_cast to reference when incorrect type is not acceptable
[builder.git] / source / gnulinker.cpp
index 4048f1c5fefbe362b2dc0e358475cad70bd4b024..ddad8d1904abb06fb7252128b7bd586593599a81 100644 (file)
@@ -47,14 +47,10 @@ Target *GnuLinker::create_target(const list<Target *> &sources, const string &ar
        Linker *linker = default_linker;
        for(Target *s: sources)
        {
-               if(ObjectFile *obj = dynamic_cast<ObjectFile *>(s))
-               {
-                       objs.push_back(obj);
-                       if(obj->get_tool()->get_tag()=="CXX")
-                               linker = cxx_linker;
-               }
-               else
-                       throw invalid_argument("GnuLinker::create_target");
+               ObjectFile &obj = dynamic_cast<ObjectFile &>(*s);
+               objs.push_back(&obj);
+               if(obj.get_tool()->get_tag()=="CXX")
+                       linker = cxx_linker;
        }
 
        const Component &comp = *objs.front()->get_component();
@@ -174,7 +170,7 @@ void GnuLinker::do_prepare()
                        }
                }
                else
-                       system_path.push_back("/usr/"+architecture->get_cross_prefix()+"/lib");
+                       system_path.push_back(format("/usr/%s/lib", architecture->get_cross_prefix()));
        }
 }
 
@@ -198,7 +194,7 @@ GnuLinker::Linker::Linker(GnuLinker &p, const string &ct):
 
 string GnuLinker::Linker::create_build_signature(const BuildInfo &binfo) const
 {
-       string result = FS::basename(executable->get_path());
+       string result = Tool::create_build_signature(binfo);
        result += ',';
        if(binfo.libmode<=BuildInfo::STATIC)
                result += 't';
@@ -232,7 +228,7 @@ Task *GnuLinker::Linker::run(const Target &target) const
 {
        const Binary &bin = dynamic_cast<const Binary &>(target);
 
-       vector<string> argv;
+       ExternalTask::Arguments argv;
        argv.push_back(executable->get_path().str());
 
        FS::Path work_dir = bin.get_component()->get_package().get_source_directory();