package_manager.append_package_path(cwd);
package_manager.append_package_path(cwd/"..");
+ package_manager.append_binary_package_path(FS::get_sys_data_dir(argv[0], "builder"));
package_manager.set_no_externals(no_externals);
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;
}
}
+ 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
{
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<FS::Path>::const_iterator i=binpkg_path.begin(); i!=binpkg_path.end(); ++i)
+ {
+ builder.get_logger().log("files", format("Traversing %s", *i));
+ list<string> files = list_filtered(*i, "\\.bpk$");
+ for(list<string>::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();
+}
Builder &builder;
SearchPath pkg_path;
SearchPath pkg_dirs;
+ SearchPath binpkg_path;
+ SearchPath binpkg_files;
bool no_externals;
PackageMap packages;
bool env_set;
/// Adds a location to look for source packages from.
void append_package_path(const Msp::FS::Path &);
+ /// Adds a location to look for binary packages from.
+ void append_binary_package_path(const Msp::FS::Path &);
+
/** Prevent creation of source packages. */
void set_no_externals(bool);
/** Determines the source directory of a package. Pkg-config is consulted
first, and if it fails, the package path is searched for matches. */
Msp::FS::Path get_package_location(const std::string &);
+
+ /** Determines the file containing a binary package. The file is expected
+ to be named after the package. */
+ Msp::FS::Path get_binary_package_file(const std::string &);
};
#endif