X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fgnucompiler.cpp;h=e2c5c0e71a494e7bb11079a5be0f76725f135b93;hb=6ed04f66e56958890c2ecca82fa3885f10f8adf0;hp=8df1a72a92debc7542df10f137f76d29f1f8e18a;hpb=25a315f3cb5805614c513ac762ea1bd512ce82cb;p=builder.git diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 8df1a72..e2c5c0e 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -40,15 +40,44 @@ Target *GnuCompiler::create_target(const list &sources, const string & 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()); argv.push_back("-c"); const BuildInfo &binfo = comp.get_build_info(); - for(BuildInfo::WordList::const_iterator i=binfo.warnings.begin(); i!=binfo.warnings.end(); ++i) - argv.push_back("-W"+*i); + if(binfo.warning_level>=1) + { + argv.push_back("-Wall"); + if(binfo.warning_level>=2) + { + argv.push_back("-Wextra"); + argv.push_back("-Wundef"); + } + if(binfo.warning_level>=3) + { + argv.push_back("-pedantic"); + argv.push_back("-Wno-long-long"); + argv.push_back("-Wshadow"); + argv.push_back("-Winline"); + if(tag=="CC") + { + argv.push_back("-Wc++-compat"); + argv.push_back("-Wstrict-prototypes"); + } + } + if(binfo.warning_level>=4) + { + // Some truly paranoid warnings + argv.push_back("-Wstrict-overflow=4"); + argv.push_back("-Wfloat-equal"); + argv.push_back("-Wconversion"); + argv.push_back("-Wwrite-strings"); + } + if(binfo.fatal_warnings) + argv.push_back("-Werror"); + } for(BuildInfo::PathList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i) argv.push_back("-I"+i->str()); for(BuildInfo::DefineMap::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i) @@ -69,7 +98,7 @@ 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 &native_arch = builder.get_native_arch(); @@ -82,7 +111,7 @@ Task *GnuCompiler::run(const Target &target) const FS::Path obj_path = object.get_path(); FS::Path src_path = object.get_source().get_path(); - FS::Path work_dir = comp.get_package().get_source(); + FS::Path work_dir = comp.get_package().get_source_directory(); argv.push_back("-o"); argv.push_back(relative(obj_path, work_dir).str());