From: Mikko Rasa Date: Sat, 29 Sep 2012 20:22:26 +0000 (+0300) Subject: Support specifying library modes on a per-library basis X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=323285f97a1a6fe2628f818371a8b03f233dd036;p=builder.git Support specifying library modes on a per-library basis --- diff --git a/source/binary.cpp b/source/binary.cpp index d56ab17..5856c19 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -31,8 +31,6 @@ void Binary::find_dependencies() if(!component) return; - BuildInfo::LibraryMode libmode = component->get_build_info().libmode; - list queue; list 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) { diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index c02d115..ad06ed8 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -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); diff --git a/source/buildinfo.h b/source/buildinfo.h index 595fe1a..e0ff0bf 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -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 DefineMap; typedef std::list PathList; typedef std::list WordList; + typedef std::map LibModeMap; DefineMap defines; PathList incpath; PathList libpath; WordList libs; Tracked libmode; + LibModeMap libmodes; Tracked threads; Tracked debug; Tracked 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.