]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/src/tools/generators/archive-generator.jam
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / src / tools / generators / archive-generator.jam
CommitLineData
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
7import "class" : new ;
8import generators ;
9
10# The generator class for handling STATIC_LIB creation.
11#
12class archive-generator : generator
13{
11fdf7f2 14 import generators ;
b32b8144
FG
15 import property-set ;
16
17 rule __init__ ( id composing ? : source-types + : target-types +
18 : requirements * )
19 {
20 composing ?= true ;
21 generator.__init__ $(id) $(composing) : $(source-types)
22 : $(target-types) : $(requirements) ;
23 }
24
25 rule run ( project name ? : property-set : sources + )
26 {
27 sources += [ $(property-set).get <library> ] ;
28
11fdf7f2
TL
29 property-set = [ $(property-set).add-raw <relevant>link ] ;
30
b32b8144
FG
31 local result = [ generator.run $(project) $(name) : $(property-set)
32 : $(sources) ] ;
33
34 # For static linking, if we get a library in source, we can not directly
35 # link to it so we need to cause our dependencies to link to that
36 # library. There are two approaches:
37 # - adding the library to the list of returned targets.
38 # - using the <library> usage requirements.
39 # The problem with the first is:
40 #
41 # lib a1 : : <file>liba1.a ;
42 # lib a2 : a2.cpp a1 : <link>static ;
43 # install dist : a2 ;
44 #
45 # here we will try to install 'a1', even though it is not necessary in
46 # the general case. With the second approach, even indirect dependants
47 # will link to the library, but it should not cause any harm. So, return
48 # all LIB sources together with created targets, so that dependants link
49 # to them.
11fdf7f2 50 local usage-requirements = <relevant>link ;
b32b8144
FG
51 if [ $(property-set).get <link> ] = static
52 {
53 for local t in $(sources)
54 {
f67539c2 55 if [ $(t).type ] && [ type.is-derived [ $(t).type ] LIB ]
b32b8144
FG
56 {
57 usage-requirements += <library>$(t) ;
58 }
59 }
60 }
61
11fdf7f2 62 return [ generators.add-usage-requirements $(result) : $(usage-requirements) ] ;
b32b8144
FG
63 }
64}
65
66
67rule register-archiver ( id composing ? : source-types + : target-types +
68 : requirements * )
69{
70 generators.register [ new archive-generator $(id) $(composing)
71 : $(source-types) : $(target-types) : $(requirements) ] ;
72}
73
74IMPORT $(__name__) : register-archiver : : generators.register-archiver ;