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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// file : build/module -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#ifndef BUILD_MODULE
#define BUILD_MODULE
#include <map>
#include <build/types>
#include <build/utility>
#include <build/diagnostics>
namespace build
{
class scope;
class location;
class module
{
public:
virtual
~module () = default;
};
extern "C"
using module_boot_function =
void (scope& root, const location&, unique_ptr<module>&);
// Return false if the module configuration (normally based on the default
// values) was unsuccessful but this is not (yet) an error. One example
// would be the optional use of a module. Or a module might remain
// unconfigured for as long as it is actually not used (e.g., install,
// dist). The return value is used to set the <module>.configured variable.
//
extern "C"
using module_init_function =
bool (scope& root,
scope& base,
const location&,
unique_ptr<module>&,
bool first, // First time for this project.
bool optional); // Loaded with 'using?' (optional module).
struct module_state
{
bool boot; // True if the module boot'ed but not yet init'ed.
module_init_function* init;
unique_ptr<build::module> module;
const location loc; // Boot location.
};
using loaded_module_map = std::map<string, module_state>;
// Load and boot the specified module.
//
void
boot_module (const string& name, scope& root, const location&);
// Load (if not already loaded) and initialize the specified module. Used
// by the parser but also by some modules to load prerequisite modules.
// Return true if the module was both successfully loaded and configured
// (false can only be returned if optional).
//
bool
load_module (bool optional,
const std::string& name,
scope& root,
scope& base,
const location&);
// Builtin modules.
//
struct module_functions
{
module_boot_function* boot;
module_init_function* init;
};
using available_module_map = std::map<string, module_functions>;
extern available_module_map builtin_modules;
}
#endif // BUILD_MODULE
|