aboutsummaryrefslogtreecommitdiff
path: root/build2/config/module
blob: 5becfd4572bda444c1ec3f50019c02bdba34c6af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// file      : build2/config/module -*- C++ -*-
// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef BUILD2_CONFIG_MODULE
#define BUILD2_CONFIG_MODULE

#include <butl/prefix-map>

#include <build2/types>
#include <build2/utility>

#include <build2/module>
#include <build2/variable>

namespace build2
{
  namespace config
  {
    // An ordered list of modules each with an ordered list of list of
    // config.* variables and their "save flags" (see save_variable()) that
    // are used (as opposed to just being specified) in this configuration.
    // Populated by the config utility functions (required(), optional())
    // and saved in the order populated.
    //
    struct saved_variable
    {
      reference_wrapper<const variable> var;
      uint64_t flags;
    };

    using saved_variables = vector<saved_variable>;

    struct saved_modules: butl::prefix_map<string, saved_variables, '.'>
    {
      vector<const_iterator> sequence;

      iterator
      insert (string name)
      {
        auto p (emplace (move (name), saved_variables ()));

        if (p.second)
          sequence.push_back (p.first);

        return p.first;
      }
    };

    struct module: module_base
    {
      config::saved_modules saved_modules;
      static const string name;
    };

    void
    boot (scope&, const location&, unique_ptr<module_base>&);

    bool
    init (scope&,
          scope&,
          const location&,
          unique_ptr<module_base>&,
          bool,
          bool,
          const variable_map&);
  }
}

#endif // BUILD2_CONFIG_MODULE