]> git.tdb.fi Git - builder.git/commitdiff
Support gcc's -iquote feature
authorMikko Rasa <tdb@tdb.fi>
Wed, 24 Apr 2013 08:48:06 +0000 (11:48 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 24 Apr 2013 08:48:06 +0000 (11:48 +0300)
source/buildinfo.cpp
source/buildinfo.h
source/csourcefile.cpp
source/gnucompiler.cpp

index ad06ed89a52e0b23e56401e1c9e414040a6152d6..5ea1b344069c034c07636b3e0a848b05fe64b9b7 100644 (file)
@@ -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)
 {
index e0ff0bff74ccf15cf0177f2cfee3e04db265d108..ee831f3c4da453dfdfc3c16567e5350a9174026d 100644 (file)
@@ -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<LibraryMode> libmode;
index ca061d2b19e581ccdc1f6f308c2848533f8135c9..13c74b9dcef247402490da7d7638de379c50f067 100644 (file)
@@ -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)
index a3052df1a6d4a4b2041ec5940e75239d4f6ffccf..06ad5a9d7e0037735cbc89c18bb2709bd7053070 100644 (file)
@@ -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();