packages.insert(PackageMap::value_type(pkg->get_name(), pkg));
}
+Package *PackageManager::get_package(const string &name) const
+{
+ PackageMap::const_iterator i = packages.find(name);
+ if(i!=packages.end())
+ return i->second;
+
+ return 0;
+}
+
Package &PackageManager::get_main_package() const
{
if(!main_pkg)
if(not_found.count(name))
return 0;
- PackageMap::iterator i = packages.find(name);
- if(i!=packages.end())
- return i->second;
+ if(Package *pkg = get_package(name))
+ return pkg;
if(!no_externals)
{
if(!path.empty())
{
builder.load_build_file(path/"Build");
- i = packages.find(name);
+ PackageMap::iterator i = packages.find(name);
if(i!=packages.end())
return i->second;
}
if(!path.empty())
{
builder.load_build_file(path);
- i = packages.find(name);
- if(i!=packages.end())
- return i->second;
+ if(Package *pkg = get_package(name))
+ return pkg;
}
try
void add_package(Package *);
/** Returns a package from the cache. */
- Package *get_package(const std::string &);
+ Package *get_package(const std::string &) const;
/** Returns the package that was added first. This should be considered
the primary build target. */