]> git.tdb.fi Git - builder.git/commitdiff
Support specifying library modes on a per-library basis
authorMikko Rasa <tdb@tdb.fi>
Sat, 29 Sep 2012 20:22:26 +0000 (23:22 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 29 Sep 2012 20:22:26 +0000 (23:22 +0300)
source/binary.cpp
source/buildinfo.cpp
source/buildinfo.h

index d56ab17b0b59020ae30dc2825654d6c186b485b9..5856c19e539bde29901e7d7ba0fdfcf1247e2077 100644 (file)
@@ -31,8 +31,6 @@ void Binary::find_dependencies()
        if(!component)
                return;
 
-       BuildInfo::LibraryMode libmode = component->get_build_info().libmode;
-
        list<const Component *> queue;
        list<Target *> dep_libs;
        queue.push_back(component);
@@ -44,6 +42,7 @@ void Binary::find_dependencies()
                const BuildInfo &binfo = c->get_build_info();
                for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
                {
+                       BuildInfo::LibraryMode libmode = component->get_build_info().get_libmode_for(*i);
                        Target *lib = builder.get_vfs().find_library(*i, binfo.libpath, libmode);
                        if(lib)
                        {
index c02d115fd1b252e409191834a9ca45730efeaaf1..ad06ed89a52e0b23e56401e1c9e414040a6152d6 100644 (file)
@@ -36,6 +36,14 @@ BuildInfo::BuildInfo():
        fatal_warnings(false)
 { }
 
+BuildInfo::LibraryMode BuildInfo::get_libmode_for(const string &lib) const
+{
+       LibModeMap::const_iterator i = libmodes.find(lib);
+       if(i!=libmodes.end())
+               return i->second;
+       return libmode;
+}
+
 void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level)
 {
        for(DefineMap::const_iterator i=bi.defines.begin(); i!=bi.defines.end(); ++i)
@@ -50,6 +58,8 @@ void BuildInfo::update_from(const BuildInfo &bi, UpdateLevel level)
        if(level==LOCAL)
        {
                libmode = bi.libmode;
+               for(LibModeMap::const_iterator i=bi.libmodes.begin(); i!=bi.libmodes.end(); ++i)
+                       libmodes[i->first] = i->second;
                debug = bi.debug;
                optimize = bi.optimize;
                strip = bi.strip;
@@ -72,6 +82,7 @@ BuildInfo::Loader::Loader(BuildInfo &bi):
        add("libpath",  &Loader::libpath);
        add("library",  &Loader::library);
        add("libmode",  &BuildInfo::libmode);
+       add("libmode",  &Loader::libmode_for_lib);
        add("optimize", &BuildInfo::optimize);
        add("strip",    &BuildInfo::strip);
        add("threads",  &BuildInfo::threads);
@@ -89,6 +100,11 @@ void BuildInfo::Loader::define(const string &d, const string &v)
        obj.defines[d] = v;
 }
 
+void BuildInfo::Loader::libmode_for_lib(const string &l, LibraryMode m)
+{
+       obj.libmodes[l] = m;
+}
+
 void BuildInfo::Loader::libpath(const string &s)
 {
        obj.libpath.push_back(s);
index 595fe1a55ccd5bb414ebbe5febec8f86431465b2..e0ff0bff74ccf15cf0177f2cfee3e04db265d108 100644 (file)
@@ -28,6 +28,7 @@ public:
        private:
                void incpath(const std::string &);
                void define(const std::string &, const std::string &);
+               void libmode_for_lib(const std::string &, LibraryMode);
                void libpath(const std::string &);
                void library(const std::string &);
        };
@@ -68,12 +69,14 @@ public:
        typedef std::map<std::string, std::string> DefineMap;
        typedef std::list<Msp::FS::Path> PathList;
        typedef std::list<std::string> WordList;
+       typedef std::map<std::string, LibraryMode> LibModeMap;
 
        DefineMap defines;
        PathList incpath;
        PathList libpath;
        WordList libs;
        Tracked<LibraryMode> libmode;
+       LibModeMap libmodes;
        Tracked<bool> threads;
        Tracked<bool> debug;
        Tracked<int> optimize;
@@ -83,6 +86,11 @@ public:
 
        BuildInfo();
 
+       /** Returns the library mode for linking a particular library.  If no mode
+       has been specified for that library, the the global library mode is
+       returned. */
+       LibraryMode get_libmode_for(const std::string &) const;
+
        /** Updates the BuildInfo from another one.  Lists are concatenated, with
        the first occurrence of each item preserved.  Scalars are overwritten.