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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
// file : build/dist/module.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#include <build/dist/module>
#include <build/scope>
#include <build/file>
#include <build/diagnostics>
#include <build/config/utility>
#include <build/dist/rule>
#include <build/dist/operation>
using namespace std;
using namespace butl;
namespace build
{
namespace dist
{
static rule rule_;
extern "C" bool
dist_init (scope& r,
scope& b,
const location& l,
unique_ptr<module>&,
bool first,
bool)
{
tracer trace ("dist::init");
if (&r != &b)
fail (l) << "dist module must be initialized in bootstrap.build";
if (!first)
{
warn (l) << "multiple dist module initializations";
return true;
}
const dir_path& out_root (r.out_path ());
level5 ([&]{trace << "for " << out_root;});
// Enter module variables.
//
if (first)
{
auto& v (var_pool);
v.find ("dist", bool_type);
v.find ("dist.package", string_type);
v.find ("dist.root", dir_path_type);
v.find ("config.dist.root", dir_path_type);
//@@ VAR type
//
v.find ("dist.cmd", string_type);
v.find ("config.dist.cmd", string_type);
v.find ("dist.archives", strings_type);
v.find ("config.dist.archives", strings_type);
}
// Register meta-operation.
//
r.meta_operations.insert (dist_id, dist);
// Register our wildcard rule. Do it explicitly for the alias
// to prevent something like insert<target>(dist_id, test_id)
// taking precedence.
//
r.rules.insert<target> (dist_id, 0, "dist", rule_);
r.rules.insert<alias> (dist_id, 0, "dist.alias", rule_);
// Configuration.
//
// Note that we don't use any defaults for root -- the location
// must be explicitly specified or we will complain if and when
// we try to dist.
//
using namespace config;
bool s (specified (r, "config.dist"));
// dist.root
//
{
value& v (r.assign ("dist.root"));
if (s)
{
const value& cv (optional_absolute (r, "config.dist.root"));
if (cv && !cv.empty ())
v = cv;
}
}
// dist.cmd
//
{
value& v (r.assign ("dist.cmd"));
if (s)
{
const value& cv (required (r, "config.dist.cmd", "install").first);
if (cv && !cv.empty ())
v = cv;
}
else
v = "install";
}
// dist.archives
//
{
value& v (r.assign ("dist.archives"));
if (s)
{
const value& cv (optional (r, "config.dist.archives"));
if (cv && !cv.empty ())
v = cv;
}
}
return true;
}
}
}
|