+++ /dev/null
-#ifndef PACKAGEMANAGER_H_
-#define PACKAGEMANAGER_H_
-
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-#include <msp/fs/path.h>
-
-class Builder;
-class Package;
-
-/**
-Keeps track of packages. Also responsible for locating previously unknown
-packages by name.
-*/
-class PackageManager
-{
-private:
- Builder &builder;
- std::vector<Msp::FS::Path> pkg_path;
- std::vector<Msp::FS::Path> pkg_dirs;
- std::vector<Msp::FS::Path> binpkg_path;
- std::vector<Msp::FS::Path> binpkg_files;
- bool no_externals = false;
- std::map<std::string, Package *> packages;
- Package *main_pkg = 0;
- std::set<std::string> not_found;
- bool env_set = false;
-
-public:
- PackageManager(Builder &b): builder(b) { }
- ~PackageManager();
-
- /// 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);
-
- /** Adds a package to the manager. Called from Package constructor. */
- void add_package(Package *);
-
- /** Returns a package from the cache. */
- Package *get_package(const std::string &) const;
-
- /** Returns the package that was added first. This should be considered
- the primary build target. */
- Package &get_main_package() const;
-
- const std::map<std::string, Package *> &get_packages() const { return packages; }
-
- /** Locates a package and loads it if necessary. */
- Package *find_package(const std::string &);
-
-private:
- std::string run_pkgconfig(const std::string &, const std::string &);
-
- /** Determines the source directory of a package. Pkg-config is consulted
- first, and if it fails, the package path is searched for matches. The
- package is expected to be located in a directory named after itself. */
- 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 &);
-
-public:
- void save_all_caches() const;
-};
-
-#endif