X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpackagemanager.cpp;h=1a481fb17925a86bf03a6a47b0871fa39ca6e953;hb=e943994f881a060b184aeee869a32a464f504a62;hp=55498467d636a694f957e58a3dd475fd3b185b87;hpb=5fd0dd8b26ca8910901a750b3d6643c11cf0488e;p=builder.git diff --git a/source/packagemanager.cpp b/source/packagemanager.cpp index 5549846..1a481fb 100644 --- a/source/packagemanager.cpp +++ b/source/packagemanager.cpp @@ -33,6 +33,11 @@ void PackageManager::append_package_path(const FS::Path &p) pkg_path.push_back(p); } +void PackageManager::append_binary_package_path(const FS::Path &p) +{ + binpkg_path.push_back(p); +} + void PackageManager::set_no_externals(bool x) { no_externals = x; @@ -72,6 +77,15 @@ Package *PackageManager::find_package(const string &name) } } + FS::Path path = get_binary_package_file(name); + if(!path.empty()) + { + builder.load_build_file(path); + i = packages.find(name); + if(i!=packages.end()) + return i->second; + } + Package *pkg = 0; try { @@ -149,7 +163,7 @@ FS::Path PackageManager::get_package_location(const string &name) if(pkg_dirs.empty()) { - for(list::const_iterator i=pkg_path.begin(); i!=pkg_path.end(); ++i) + for(SearchPath::const_iterator i=pkg_path.begin(); i!=pkg_path.end(); ++i) { builder.get_logger().log("files", format("Traversing %s", *i)); list files = list_files(*i); @@ -171,9 +185,9 @@ FS::Path PackageManager::get_package_location(const string &name) } bool msp = !name.compare(0, 3, "msp"); - for(list::const_iterator i=pkg_dirs.begin(); i!=pkg_dirs.end(); ++i) + for(SearchPath::const_iterator i=pkg_dirs.begin(); i!=pkg_dirs.end(); ++i) { - string base = basename(*i); + string base = FS::basename(*i); unsigned dash = base.rfind('-'); if(!base.compare(0, dash, name)) @@ -184,3 +198,31 @@ FS::Path PackageManager::get_package_location(const string &name) return FS::Path(); } + +FS::Path PackageManager::get_binary_package_file(const string &name) +{ + builder.get_logger().log("packagemgr", format("Looking for binary package %s", name)); + + if(binpkg_files.empty()) + { + for(list::const_iterator i=binpkg_path.begin(); i!=binpkg_path.end(); ++i) + { + builder.get_logger().log("files", format("Traversing %s", *i)); + list files = list_filtered(*i, "\\.bpk$"); + for(list::const_iterator j=files.begin(); j!=files.end(); ++j) + binpkg_files.push_back(*i / *j); + builder.get_logger().log("packagemgr", format("%d binary packages found in %s", files.size(), *i)); + } + + builder.get_logger().log("packagemgr", format("%d binary packages found", binpkg_files.size())); + } + + for(SearchPath::const_iterator i=binpkg_files.begin(); i!=binpkg_files.end(); ++i) + { + string base = FS::basepart(FS::basename(*i)); + if(base==name) + return *i; + } + + return FS::Path(); +}