From b1c51196b34f644e821f351c2acdb48619aed2e3 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 24 Apr 2013 11:48:06 +0300 Subject: [PATCH] Support gcc's -iquote feature --- source/buildinfo.cpp | 7 +++++++ source/buildinfo.h | 2 ++ source/csourcefile.cpp | 4 +++- source/gnucompiler.cpp | 9 +++++++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index ad06ed8..5ea1b34 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -57,6 +57,7 @@ void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level) threads = bi.threads; if(level==LOCAL) { + local_incpath.insert(local_incpath.end(), bi.local_incpath.begin(), bi.local_incpath.end()); libmode = bi.libmode; for(LibModeMap::const_iterator i=bi.libmodes.begin(); i!=bi.libmodes.end(); ++i) libmodes[i->first] = i->second; @@ -83,6 +84,7 @@ BuildInfo::Loader::Loader(BuildInfo &bi): add("library", &Loader::library); add("libmode", &BuildInfo::libmode); add("libmode", &Loader::libmode_for_lib); + add("local_incpath", &Loader::local_incpath); add("optimize", &BuildInfo::optimize); add("strip", &BuildInfo::strip); add("threads", &BuildInfo::threads); @@ -115,6 +117,11 @@ void BuildInfo::Loader::library(const string &s) obj.libs.push_back(s); } +void BuildInfo::Loader::local_incpath(const string &s) +{ + obj.local_incpath.push_back(s); +} + void operator>>(const LexicalConverter &conv, BuildInfo::LibraryMode &libmode) { diff --git a/source/buildinfo.h b/source/buildinfo.h index e0ff0bf..ee831f3 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -31,6 +31,7 @@ public: void libmode_for_lib(const std::string &, LibraryMode); void libpath(const std::string &); void library(const std::string &); + void local_incpath(const std::string &); }; enum UpdateLevel @@ -73,6 +74,7 @@ public: DefineMap defines; PathList incpath; + PathList local_incpath; PathList libpath; WordList libs; Tracked libmode; diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index ca061d2..13c74b9 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -48,8 +48,10 @@ void CSourceFile::find_dependencies() cache.set_values(this, "includes", includes); } - const BuildInfo::PathList &incpath = component->get_build_info().incpath; + const BuildInfo &build_info = component->get_build_info_for_path(path); + const BuildInfo::PathList &incpath = build_info.incpath; BuildInfo::PathList local_incpath = incpath; + local_incpath.insert(local_incpath.begin(), build_info.local_incpath.begin(), build_info.local_incpath.end()); local_incpath.push_front(FS::dirname(path).str()); for(IncludeList::iterator i=includes.begin(); i!=includes.end(); ++i) diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index a3052df..06ad5a9 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -67,7 +67,7 @@ Task *GnuCompiler::run(const Target &target) const argv.push_back(executable->get_path().str()); argv.push_back("-c"); - const BuildInfo &binfo = comp.get_build_info(); + const BuildInfo &binfo = comp.get_build_info_for_path(object.get_source().get_path()); if(binfo.warning_level>=1) { argv.push_back("-Wall"); @@ -99,6 +99,11 @@ Task *GnuCompiler::run(const Target &target) const if(binfo.fatal_warnings) argv.push_back("-Werror"); } + for(BuildInfo::PathList::const_iterator i=binfo.local_incpath.begin(); i!=binfo.local_incpath.end(); ++i) + { + argv.push_back("-iquote"); + argv.push_back(i->str()); + } 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) @@ -119,7 +124,7 @@ Task *GnuCompiler::run(const Target &target) const } if(binfo.threads) argv.push_back("-pthread"); - if(comp.get_type()==Component::LIBRARY && architecture->get_system()!="windows") + if((comp.get_type()==Component::LIBRARY || comp.get_type()==Component::MODULE) && architecture->get_system()!="windows") argv.push_back("-fPIC"); const Architecture &native_arch = builder.get_native_arch(); -- 2.45.2