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