]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | # Copyright 2002-2017 Rene Rivera |
2 | # Copyright 2002-2017 Vladimir Prus | |
3 | # Distributed under the Boost Software License, Version 1.0. | |
1e59de90 TL |
4 | # (See accompanying file LICENSE.txt or copy at |
5 | # https://www.bfgroup.xyz/b2/LICENSE.txt) | |
b32b8144 FG |
6 | |
7 | import "class" : new ; | |
8 | import generators ; | |
9 | ||
10 | class searched-lib-generator : generator | |
11 | { | |
12 | import property-set ; | |
13 | ||
14 | rule __init__ ( ) | |
15 | { | |
16 | # The requirements cause the generators to be tried *only* when we are | |
17 | # building a lib target with a 'search' feature. This seems ugly --- all | |
18 | # we want is to make sure searched-lib-generator is not invoked deep | |
19 | # inside transformation search to produce intermediate targets. | |
20 | generator.__init__ searched-lib-generator : : SEARCHED_LIB ; | |
21 | } | |
22 | ||
23 | rule run ( project name ? : property-set : sources * ) | |
24 | { | |
25 | if $(name) | |
26 | { | |
27 | # If 'name' is empty, it means we have not been called to build a | |
28 | # top-level target. In this case, we just fail immediately, because | |
29 | # searched-lib-generator cannot be used to produce intermediate | |
30 | # targets. | |
31 | ||
32 | local properties = [ $(property-set).raw ] ; | |
33 | local shared ; | |
34 | if <link>shared in $(properties) | |
35 | { | |
36 | shared = true ; | |
37 | } | |
38 | ||
39 | local search = [ feature.get-values <search> : $(properties) ] ; | |
40 | ||
1e59de90 | 41 | local a = [ new null-action [ $(property-set).add-raw <relevant>link <relevant>search ] ] ; |
b32b8144 FG |
42 | local lib-name = [ feature.get-values <name> : $(properties) ] ; |
43 | lib-name ?= $(name) ; | |
44 | local t = [ new searched-lib-target $(lib-name) : $(project) | |
45 | : $(shared) : $(search) : $(a) ] ; | |
46 | # We return sources for a simple reason. If there is | |
47 | # lib png : z : <name>png ; | |
48 | # the 'z' target should be returned, so that apps linking to 'png' | |
49 | # will link to 'z', too. | |
1e59de90 | 50 | return [ property-set.create <xdll-path>$(search) <relevant>link <relevant>search <relevant>name ] |
b32b8144 FG |
51 | [ virtual-target.register $(t) ] $(sources) ; |
52 | } | |
53 | } | |
54 | } | |
55 | ||
56 | generators.register [ new searched-lib-generator ] ; | |
57 | ||
58 | class searched-lib-target : abstract-file-target | |
59 | { | |
60 | rule __init__ ( name | |
61 | : project | |
62 | : shared ? | |
63 | : search * | |
64 | : action | |
65 | ) | |
66 | { | |
67 | abstract-file-target.__init__ $(name) : SEARCHED_LIB : $(project) | |
68 | : $(action) : ; | |
69 | ||
70 | self.shared = $(shared) ; | |
71 | self.search = $(search) ; | |
72 | } | |
73 | ||
74 | rule shared ( ) | |
75 | { | |
76 | return $(self.shared) ; | |
77 | } | |
78 | ||
79 | rule search ( ) | |
80 | { | |
81 | return $(self.search) ; | |
82 | } | |
83 | ||
84 | rule actualize-location ( target ) | |
85 | { | |
86 | NOTFILE $(target) ; | |
87 | } | |
88 | ||
11fdf7f2 TL |
89 | rule relevant ( ) |
90 | { | |
1e59de90 | 91 | return [ property-set.create <relevant>link <relevant>search ] ; |
11fdf7f2 TL |
92 | } |
93 | ||
b32b8144 FG |
94 | rule path ( ) |
95 | { | |
96 | } | |
97 | } |