#include <list>
#include <string>
-#include <msp/parser/loader.h>
+#include <msp/datafile/objectloader.h>
#include "buildinfo.h"
-#include "component.h"
#include "config.h"
-#include "packageref.h"
class Builder;
+class Package;
+typedef std::list<Package *> PackageList;
+
+/**
+A package is a distributable piece of software. Package information may be
+obtained in several ways: Build files of source packages, pkg-config for binary
+packages and the builderrc file for binary packages with no pkg-config support.
+*/
class Package
{
public:
- class Loader: public Msp::Parser::Loader
+ class Loader: public Msp::DataFile::ObjectLoader<Package>
{
public:
Loader(Package &);
- Package &get_object() { return pkg; }
- ~Loader();
private:
- Package &pkg;
-
void require(const std::string &);
- void program(const std::string &);
- void library(const std::string &);
- void headers(const std::string &);
- void build_info();
};
- Package(Builder &, const std::string &, const Msp::Path::Path &);
- void set_path(const Msp::Path::Path &);
- const std::string &get_name() const { return name; }
- const Msp::Path::Path &get_source() const { return source; }
- const ComponentList &get_components() const { return components; }
- bool get_buildable() const { return buildable; }
- const Config &get_config() const { return config; }
- const PkgRefList &get_requires() const { return requires; }
- const BuildInfo &get_build_info() const { return build_info; }
- const BuildInfo &get_exported_binfo() const { return export_binfo; }
- Builder &get_builder() const { return builder; }
- bool get_need_path() const { return need_path; }
- void resolve_refs();
- void create_build_info();
- void process_options(const RawOptionMap &);
-
- static Package *create(Builder &, const std::string &);
-private:
- enum InstallFlags
- {
- INCLUDE=1,
- BIN=2,
- LIB=4,
- DATA=8
- };
-
- Builder &builder;
-
- std::string name;
- std::string version;
- std::string description;
-
- bool buildable;
- Msp::Path::Path source;
- PkgRefList requires;
- BuildInfo build_info;
- BuildInfo export_binfo;
- ComponentList components;
- Config config;
- bool build_info_ready;
-
- bool need_path;
- Msp::Path::Path path;
-
- Package(Builder &, const std::string &, const std::vector<std::string> &);
- void init_buildable();
- unsigned get_install_flags();
+protected:
+ Builder &builder;
+
+ std::string name;
+
+ PackageList requires;
+ BuildInfo export_binfo;
+ bool prepared;
+
+ bool use_pkgconfig;
+
+ Package(Builder &, const std::string &);
+public:
+ virtual ~Package() { }
+
+ const std::string &get_name() const { return name; }
+ Builder &get_builder() const { return builder; }
+ const PackageList &get_requires() const { return requires; }
+
+ const BuildInfo &get_exported_binfo() const { return export_binfo; }
+
+ /// Indicates whether or not this package supports pkg-config
+ bool get_use_pkgconfig() const { return use_pkgconfig; }
+
+ /** Prepares the package for building. Recursively prepares all required
+ packages, populates build info and creates targets. */
+ void prepare();
+
+ bool is_prepared() const { return prepared; }
+protected:
+ virtual void create_build_info() { }
+
+ virtual void create_targets() { }
+
+public:
+ virtual void save_caches() { }
};
#endif