X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgnucompiler.cpp;h=36903937546a678f07e59e4bc2f101ddcb47b474;hb=5881b8499dc159564d2f69c3b037e16b4d1af4db;hp=1180b4e89f1218a5d9f678b4415b3e7bd1c0a398;hpb=4fea1031bf55f4f4d7f17f529a89aa5945018446;p=builder.git diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 1180b4e..3690393 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -13,19 +13,21 @@ using namespace std; using namespace Msp; -GnuCompiler::GnuCompiler(Builder &b, const string &t, const string &n): - Tool(b, t) +GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t, const string &c): + Tool(b, a, t) { - executable = builder.get_vfs().find_binary(n); + string command = c; + if(architecture->is_cross()) + command = format("%s-%s", architecture->get_cross_prefix(), command); + executable = builder.get_vfs().find_binary(command); - const Architecture &arch = builder.get_current_arch(); - if(arch.is_native()) + if(architecture->is_native()) system_path.push_back("/usr/include"); else - system_path.push_back("/usr/"+arch.get_cross_prefix()+"/include"); + system_path.push_back("/usr/"+architecture->get_cross_prefix()+"/include"); } -Target *GnuCompiler::create_target(const list &sources, const std::string &) const +Target *GnuCompiler::create_target(const list &sources, const string &) const { if(sources.size()!=1) throw invalid_argument("GnuCCompiler::create_target"); @@ -38,7 +40,7 @@ Target *GnuCompiler::create_target(const list &sources, const std::str Task *GnuCompiler::run(const Target &target) const { const ObjectFile &object = dynamic_cast(target); - const Component &comp = object.get_component(); + const Component &comp = *object.get_component(); ExternalTask::Arguments argv; argv.push_back(executable->get_path().str()); @@ -67,15 +69,14 @@ Task *GnuCompiler::run(const Target &target) const } if(binfo.threads) argv.push_back("-pthread"); - if(comp.get_type()==Component::LIBRARY) + if(comp.get_type()==Component::LIBRARY && architecture->get_system()!="windows") argv.push_back("-fPIC"); - const Architecture &arch = builder.get_current_arch(); const Architecture &native_arch = builder.get_native_arch(); - if(arch.get_bits()!=native_arch.get_bits()) - argv.push_back(format("-m%d", arch.get_bits())); + if(architecture->get_bits()!=native_arch.get_bits()) + argv.push_back(format("-m%d", architecture->get_bits())); - const string &cpu = arch.get_cpu(); + const string &cpu = architecture->get_cpu(); if(!cpu.empty()) argv.push_back("-march="+cpu);