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
|
// file : build2/cc/compile -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#ifndef BUILD2_CC_COMPILE
#define BUILD2_CC_COMPILE
#include <butl/path-map>
#include <build2/types>
#include <build2/utility>
#include <build2/rule>
#include <build2/cc/types>
#include <build2/cc/common>
namespace build2
{
class depdb;
namespace cc
{
class compile: public rule, virtual common
{
public:
compile (data&&);
virtual match_result
match (slock&, action, target&, const string& hint) const override;
virtual recipe
apply (slock&, action, target&) const override;
target_state
perform_update (action, const target&) const;
target_state
perform_clean (action, const target&) const;
private:
void
append_lib_options (const scope&,
cstrings&,
const target&,
lorder) const;
void
hash_lib_options (const scope&,
sha256&,
const target&,
lorder) const;
// Mapping of include prefixes (e.g., foo in <foo/bar>) for auto-
// generated headers to directories where they will be generated.
//
// We are using a prefix map of directories (dir_path_map) instead of
// just a map in order to also cover sub-paths (e.g., <foo/more/bar> if
// we continue with the example). Specifically, we need to make sure we
// don't treat foobar as a sub-directory of foo.
//
// @@ The keys should be normalized.
//
using prefix_map = butl::dir_path_map<dir_path>;
void
append_prefixes (prefix_map&, const target&, const variable&) const;
void
append_lib_prefixes (const scope&, prefix_map&, target&, lorder) const;
prefix_map
build_prefix_map (const scope&, target&, lorder) const;
// Reverse-lookup target type from extension.
//
const target_type*
map_extension (const scope&, const string&, const string&) const;
// Header dependency injection.
//
void
inject (slock&, action, target&, lorder, file&, depdb&) const;
private:
const string rule_id;
};
}
}
#endif // BUILD2_CC_COMPILE
|