summaryrefslogtreecommitdiff
path: root/tools/build/src/tools/generators/searched-lib-generator.jam
blob: b3435daa3514f109f6dfa3558ce079c0e46e13eb (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
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
# Copyright 2002-2017 Rene Rivera
# Copyright 2002-2017 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

import "class" : new ;
import generators ;

class searched-lib-generator : generator
{
    import property-set ;

    rule __init__ ( )
    {
        # The requirements cause the generators to be tried *only* when we are
        # building a lib target with a 'search' feature. This seems ugly --- all
        # we want is to make sure searched-lib-generator is not invoked deep
        # inside transformation search to produce intermediate targets.
        generator.__init__ searched-lib-generator : : SEARCHED_LIB ;
    }

    rule run ( project name ? : property-set : sources * )
    {
        if $(name)
        {
            # If 'name' is empty, it means we have not been called to build a
            # top-level target. In this case, we just fail immediately, because
            # searched-lib-generator cannot be used to produce intermediate
            # targets.

            local properties = [ $(property-set).raw ] ;
            local shared ;
            if <link>shared in $(properties)
            {
                shared = true ;
            }

            local search = [ feature.get-values <search> : $(properties) ] ;

            local a = [ new null-action [ $(property-set).add-raw <relevant>link ] ] ;
            local lib-name = [ feature.get-values <name> : $(properties) ] ;
            lib-name ?= $(name) ;
            local t = [ new searched-lib-target $(lib-name) : $(project)
                : $(shared) : $(search) : $(a) ] ;
            # We return sources for a simple reason. If there is
            #    lib png : z : <name>png ;
            # the 'z' target should be returned, so that apps linking to 'png'
            # will link to 'z', too.
            return [ property-set.create <xdll-path>$(search) <relevant>link ]
                   [ virtual-target.register $(t) ] $(sources) ;
        }
    }
}

generators.register [ new searched-lib-generator ] ;

class searched-lib-target : abstract-file-target
{
    rule __init__ ( name
        : project
        : shared ?
        : search *
        : action
    )
    {
        abstract-file-target.__init__ $(name) : SEARCHED_LIB : $(project)
          : $(action) : ;

        self.shared = $(shared) ;
        self.search = $(search) ;
    }

    rule shared ( )
    {
        return $(self.shared) ;
    }

    rule search ( )
    {
        return $(self.search) ;
    }

    rule actualize-location ( target )
    {
        NOTFILE $(target) ;
    }

    rule relevant ( )
    {
        return [ property-set.create <relevant>link ] ;
    }

    rule path ( )
    {
    }
}