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