]> git.tdb.fi Git - builder.git/blob - source/package.h
Add DependencyCache to speed up build preparation
[builder.git] / source / package.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef PACKAGE_H_
9 #define PACKAGE_H_
10
11 #include <list>
12 #include <string>
13 #include <msp/datafile/loader.h>
14 #include "buildinfo.h"
15 #include "component.h"
16 #include "condition.h"
17 #include "config.h"
18 #include "dependencycache.h"
19 #include "feature.h"
20 #include "packageref.h"
21
22 class Builder;
23 class Package;
24
25 typedef std::list<Package *> PackageList;
26
27 /**
28 A package is a distributable piece of software.  They consist of one or more
29 Components and may depend on other packages.  Packages also have configuration
30 to determine where files are installed and which features to include.
31 */
32 class Package
33 {
34 public:
35         enum InstallFlags
36         {
37                 INCLUDE=1,
38                 BIN=2,
39                 LIB=4,
40                 DATA=8
41         };
42
43         /// Loads a package from a file.
44         class Loader: public Msp::DataFile::Loader
45         {
46         public:
47                 Loader(Package &);
48                 Package &get_object() { return pkg; }
49         private:
50                 Package &pkg;
51                 
52                 void require(const std::string &);
53                 void feature(const std::string &, const std::string &);
54                 void condition(const std::string &);
55                 void program(const std::string &);
56                 void library(const std::string &);
57                 void module(const std::string &);
58                 void headers(const std::string &);
59                 void build_info();
60                 void tar_file(const std::string &);
61         };
62
63         Package(Builder &, const std::string &, const Msp::Path::Path &);
64         void                set_path(const Msp::Path::Path &);
65         const std::string   &get_name() const           { return name; }
66         const std::string   &get_version() const        { return version; }
67         const std::string   &get_description() const    { return description; }
68         const Msp::Path::Path &get_source() const       { return source; }
69         Msp::Path::Path     get_temp_dir() const;
70         Msp::Path::Path     get_out_dir() const;
71         Msp::Path::Path     get_prefix() const          { return config.get_option("prefix").value; }
72         const ComponentList &get_components() const     { return components; }
73         bool                get_buildable() const       { return buildable; }
74         const Config        &get_config() const         { return config; }
75         const PkgRefList    &get_requires() const       { return requires; }
76         const BuildInfo     &get_build_info() const     { return build_info; }
77         const BuildInfo     &get_exported_binfo() const { return export_binfo; }
78         Builder             &get_builder() const        { return builder; }
79         bool                get_need_path() const       { return need_path; }
80         unsigned            get_install_flags();
81         bool                get_use_pkgconfig() const   { return use_pkgconfig; }
82         const std::string   &get_arch() const           { return config.get_option("arch").value; }
83         LibMode             get_library_mode() const;
84         const PathList      &get_tar_files() const      { return tar_files; }
85         DependencyCache     &get_deps_cache() const     { return deps_cache; }
86         void                resolve_refs();
87         void                configure(const StringMap &, unsigned);
88
89         static Package *create(Builder &, const std::string &);
90 private:
91         Builder       &builder;
92         
93         std::string   name;
94         std::string   version;
95         std::string   description;
96         
97         bool          buildable;
98         Msp::Path::Path source;
99         PkgRefList    requires;
100         PackageList   all_reqs;
101         FeatureList   features;
102         BuildInfo     build_info;
103         BuildInfo     export_binfo;
104         ConditionList conditions;
105         ComponentList components;
106         Config        config;
107         bool          conf_done;
108         mutable DependencyCache deps_cache;
109         PathList      tar_files;
110
111         bool          use_pkgconfig;
112         bool          need_path;
113         Msp::Path::Path path;
114
115         Package(Builder &, const std::string &, const std::vector<std::string> &);
116         void     init_config();
117         void     create_build_info();
118 };
119
120 #endif