X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmsvclinker.cpp;h=62e9d2af0a8def642427bbcdbe43f1299652b08b;hb=1ed833343bc83b83c5f61cbfd74423bbba677a04;hp=46d89f7194a5565692b0a1c032f0d2a206180cc2;hpb=c0e0728ff439ddb364cee26f164e46705beac822;p=builder.git diff --git a/source/msvclinker.cpp b/source/msvclinker.cpp index 46d89f7..62e9d2a 100644 --- a/source/msvclinker.cpp +++ b/source/msvclinker.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include "builder.h" #include "component.h" @@ -27,21 +26,18 @@ MsvcLinker::MsvcLinker(Builder &b, const Architecture &a, const MicrosoftTools & processing_unit = COMPONENT; set_command((ms_tools.get_vc_bin_dir()/"link.exe").str(), false); + set_run(_run); } -Target *MsvcLinker::create_target(const list &sources, const string &arg) +Target *MsvcLinker::create_target(const vector &sources, const string &arg) { if(sources.empty()) throw invalid_argument("MsvcLinker::create_target"); - list objs; - for(list::const_iterator i=sources.begin(); i!=sources.end(); ++i) - { - if(ObjectFile *obj = dynamic_cast(*i)) - objs.push_back(obj); - else - throw invalid_argument("MsvcLinker::create_target"); - } + vector objs; + objs.reserve(sources.size()); + for(Target *s: sources) + objs.push_back(&dynamic_cast(*s)); const Component &comp = *objs.front()->get_component(); Binary *bin = 0; @@ -55,7 +51,7 @@ Target *MsvcLinker::create_target(const list &sources, const string &a string MsvcLinker::create_build_signature(const BuildInfo &binfo) const { - string result = FS::basename(executable->get_path()); + string result = Tool::create_build_signature(binfo); result += ','; if(binfo.strip) result += 's'; @@ -80,21 +76,21 @@ void MsvcLinker::do_prepare() system_path.push_back(win_sdk_dir/"lib"/win_sdk_ver/"um"/arch_dir); string path; - for(SearchPath::const_iterator i=system_path.begin(); i!=system_path.end(); ++i) + for(const FS::Path &p: system_path) { - append(path, ";", i->str()); - builder.get_logger().log("tools", format("Got %s system path: %s", tag, *i)); + append(path, ";", p.str()); + builder.get_logger().log("tools", "Got %s system path: %s", tag, p); } setenv("LIB", path); } -Task *MsvcLinker::run(const Target &target) const +Task *MsvcLinker::_run(const Binary &bin) { - const Binary &bin = dynamic_cast(target); + const Tool &tool = *bin.get_tool(); vector argv; - argv.push_back(executable->get_path().str()); + argv.push_back(tool.get_executable()->get_path().str()); argv.push_back("/NOLOGO"); FS::Path work_dir = bin.get_component()->get_package().get_source_directory(); @@ -103,10 +99,10 @@ Task *MsvcLinker::run(const Target &target) const argv.push_back("/DLL"); BuildInfo binfo; - target.collect_build_info(binfo); + bin.collect_build_info(binfo); - /*for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) - argv.push_back("/LIBPATH:"+i->str());*/ + /*for(const FS::Path &p: binfo.libpath) + argv.push_back("/LIBPATH:"+p.str());*/ if(binfo.strip) argv.push_back("/INCREMENTAL:NO"); else @@ -114,11 +110,10 @@ Task *MsvcLinker::run(const Target &target) const argv.push_back("/OUT:"+relative(bin.get_path(), work_dir).str()); - const Target::Dependencies &depends = target.get_dependencies(); - for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) + for(Target *d: bin.get_dependencies()) { - FileTarget *file = dynamic_cast(*i); - Target *tgt = (*i)->get_real_target(); + FileTarget *file = dynamic_cast(d); + Target *tgt = d->get_real_target(); if(ObjectFile *obj = dynamic_cast(tgt)) argv.push_back(relative(obj->get_path(), work_dir).str());