]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
f4a8e242adb69bb1f63b2caec1b736d822a8fdb3
[builder.git] / source / sourcepackage.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 SOURCEPACKAGE_H_
9 #define SOURCEPACKAGE_H_
10
11 #include <string>
12 #include "buildinfo.h"
13 #include "component.h"
14 #include "condition.h"
15 #include "config.h"
16 #include "dependencycache.h"
17 #include "feature.h"
18 #include "package.h"
19 #include "packageref.h"
20
21 class Builder;
22
23 /**
24 A package that can be built by Builder.
25 */
26 class SourcePackage: public Package
27 {
28 public:
29         enum InstallFlags
30         {
31                 INCLUDE=1,
32                 BIN=2,
33                 LIB=4,
34                 DATA=8
35         };
36
37         /// Loads a package from a file.
38         class Loader: public Package::Loader
39         {
40         public:
41                 Loader(Package &);
42                 SourcePackage &get_object() { return static_cast<SourcePackage &>(pkg); }
43         private:
44                 void feature(const std::string &, const std::string &);
45                 void condition(const std::string &);
46                 void program(const std::string &);
47                 void library(const std::string &);
48                 void module(const std::string &);
49                 void headers(const std::string &);
50                 void build_info();
51                 void tar_file(const std::string &);
52         };
53
54         SourcePackage(Builder &, const std::string &, const Msp::Path::Path &);
55         void                set_path(const Msp::Path::Path &);
56         const std::string   &get_name() const           { return name; }
57         const std::string   &get_version() const        { return version; }
58         const std::string   &get_description() const    { return description; }
59         const Msp::Path::Path &get_source() const       { return source; }
60         Msp::Path::Path     get_temp_dir() const;
61         Msp::Path::Path     get_out_dir() const;
62         Msp::Path::Path     get_prefix() const          { return config.get_option("prefix").value; }
63         const ComponentList &get_components() const     { return components; }
64         const Config        &get_config() const         { return config; }
65         const BuildInfo     &get_build_info() const     { return build_info; }
66         const BuildInfo     &get_exported_binfo() const { return export_binfo; }
67         Builder             &get_builder() const        { return builder; }
68         unsigned            get_install_flags();
69         const std::string   &get_arch() const           { return config.get_option("arch").value; }
70         LibMode             get_library_mode() const;
71         const PathList      &get_tar_files() const      { return tar_files; }
72         DependencyCache     &get_deps_cache() const     { return deps_cache; }
73         virtual void        resolve_refs();
74 private:
75         std::string   version;
76         std::string   description;
77
78         Msp::Path::Path source;
79         PackageList   all_reqs;
80         FeatureList   features;
81         BuildInfo     build_info;
82         ConditionList conditions;
83         ComponentList components;
84         Config        config;
85         bool          conf_done;
86         mutable DependencyCache deps_cache;
87         PathList      tar_files;
88
89         //Package(Builder &, const std::string &, const std::vector<std::string> &);
90         virtual void do_configure(const StringMap &, unsigned);
91         void         init_config();
92         virtual void create_build_info();
93 };
94
95 #endif