]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # Copyright Gennadiy Rozental |
2 | # Copyright 2006 Rene Rivera | |
3 | # Copyright 2003, 2004, 2006 Vladimir Prus | |
4 | # Distributed under the Boost Software License, Version 1.0. | |
1e59de90 | 5 | # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) |
7c673cae FG |
6 | |
7 | # The STLPort is usable by means of 'stdlib' feature. When | |
8 | # stdlib=stlport is specified, default version of STLPort will be used, | |
9 | # while stdlib=stlport-4.5 will use specific version. | |
10 | # The subfeature value 'hostios' means to use host compiler's iostreams. | |
11 | # | |
12 | # The specific version of stlport is selected by features: | |
13 | # The <runtime-link> feature selects between static and shared library | |
14 | # The <runtime-debugging>on selects STLPort with debug symbols | |
15 | # and stl debugging. | |
16 | # There's no way to use STLPort with debug symbols but without | |
17 | # stl debugging. | |
18 | ||
19 | # TODO: must implement selection of different STLPort installations based | |
20 | # on used toolset. | |
21 | # Also, finish various flags: | |
22 | # | |
23 | # This is copied from V1 toolset, "+" means "implemented" | |
24 | #+flags $(CURR_TOOLSET) DEFINES <stlport-iostream>off : _STLP_NO_OWN_IOSTREAMS=1 _STLP_HAS_NO_NEW_IOSTREAMS=1 ; | |
25 | #+flags $(CURR_TOOLSET) DEFINES <stlport-extensions>off : _STLP_NO_EXTENSIONS=1 ; | |
26 | # flags $(CURR_TOOLSET) DEFINES <stlport-anachronisms>off : _STLP_NO_ANACHRONISMS=1 ; | |
27 | # flags $(CURR_TOOLSET) DEFINES <stlport-cstd-namespace>global : _STLP_VENDOR_GLOBAL_CSTD=1 ; | |
28 | # flags $(CURR_TOOLSET) DEFINES <exception-handling>off : _STLP_NO_EXCEPTIONS=1 ; | |
29 | # flags $(CURR_TOOLSET) DEFINES <stlport-debug-alloc>on : _STLP_DEBUG_ALLOC=1 ; | |
30 | #+flags $(CURR_TOOLSET) DEFINES <runtime-build>debug : _STLP_DEBUG=1 _STLP_DEBUG_UNINITIALIZED=1 ; | |
31 | #+flags $(CURR_TOOLSET) DEFINES <runtime-link>dynamic : _STLP_USE_DYNAMIC_LIB=1 ; | |
32 | ||
33 | ||
34 | import feature : feature subfeature ; | |
35 | import project ; | |
36 | import "class" : new ; | |
37 | import targets ; | |
38 | import property-set ; | |
39 | import common ; | |
40 | import type ; | |
41 | ||
42 | # Make this module into a project. | |
43 | project.initialize $(__name__) ; | |
44 | project stlport ; | |
45 | ||
46 | # The problem: how to request to use host compiler's iostreams? | |
47 | # | |
48 | # Solution 1: Global 'stlport-iostream' feature. | |
49 | # That's ugly. Subfeature make more sense for stlport-specific thing. | |
50 | # Solution 2: Use subfeature with two values, one of which ("use STLPort iostream") | |
51 | # is default. | |
52 | # The problem is that such subfeature will appear in target paths, and that's ugly | |
53 | # Solution 3: Use optional subfeature with only one value. | |
54 | ||
55 | feature.extend stdlib : stlport ; | |
56 | feature.compose <stdlib>stlport : <library>/stlport//stlport ; | |
57 | ||
58 | # STLport iostreams or native iostreams | |
59 | subfeature stdlib stlport : iostream : hostios : optional propagated ; | |
60 | ||
61 | # STLport extensions | |
62 | subfeature stdlib stlport : extensions : noext : optional propagated ; | |
63 | ||
64 | # STLport anachronisms -- NOT YET SUPPORTED | |
65 | # subfeature stdlib stlport : anachronisms : on off ; | |
66 | ||
67 | # STLport debug allocation -- NOT YET SUPPORTED | |
68 | #subfeature stdlib stlport : debug-alloc : off on ; | |
69 | ||
70 | # Declare a special target class to handle the creation of search-lib-target | |
71 | # instances for STLport. We need a special class, because otherwise we'll have | |
72 | # - declare prebuilt targets for all possible toolsets. And by the time 'init' | |
73 | # is called we don't even know the list of toolsets that are registered | |
74 | # - when host iostreams are used, we really should produce nothing. It would | |
75 | # be hard/impossible to achieve this using prebuilt targets. | |
76 | ||
77 | class stlport-target-class : basic-target | |
78 | { | |
79 | import feature project type errors generators ; | |
80 | import set : difference ; | |
81 | ||
82 | rule __init__ ( project : headers ? : libraries * : version ? ) | |
83 | { | |
84 | basic-target.__init__ stlport : $(project) ; | |
85 | self.headers = $(headers) ; | |
86 | self.libraries = $(libraries) ; | |
87 | self.version = $(version) ; | |
88 | self.version.5 = [ MATCH "^(5[.][0123456789]+).*" : $(version) ] ; | |
89 | ||
90 | local requirements ; | |
91 | requirements += <stdlib-stlport:version>$(self.version) ; | |
11fdf7f2 TL |
92 | requirements += <relevant>runtime-debugging ; |
93 | requirements += <relevant>toolset ; | |
94 | requirements += <relevant>runtime-link ; | |
7c673cae FG |
95 | self.requirements = [ property-set.create $(requirements) ] ; |
96 | } | |
97 | ||
98 | rule generate ( property-set ) | |
99 | { | |
100 | # Since this target is built with <stdlib>stlport, it will also | |
101 | # have <library>/stlport//stlport in requirements, which will | |
102 | # cause a loop in main target references. Remove that property | |
103 | # manually. | |
104 | ||
105 | property-set = [ property-set.create | |
106 | [ difference | |
107 | [ $(property-set).raw ] : | |
108 | <library>/stlport//stlport | |
109 | <stdlib>stlport | |
110 | ] | |
111 | ] ; | |
112 | return [ basic-target.generate $(property-set) ] ; | |
113 | } | |
114 | ||
115 | rule construct ( name : source-targets * : property-set ) | |
116 | { | |
117 | # Deduce the name of stlport library, based on toolset and | |
118 | # debug setting. | |
119 | local raw = [ $(property-set).raw ] ; | |
120 | local hostios = [ feature.get-values <stdlib-stlport:iostream> : $(raw) ] ; | |
121 | local toolset = [ feature.get-values <toolset> : $(raw) ] ; | |
122 | ||
123 | if $(self.version.5) | |
124 | { | |
125 | # Version 5.x | |
126 | ||
127 | # STLport host IO streams no longer supported. So we always | |
128 | # need libraries. | |
129 | ||
130 | # name: stlport(stl)?[dg]?(_static)?.M.R | |
131 | local name = stlport ; | |
132 | if [ feature.get-values <runtime-debugging> : $(raw) ] = "on" | |
133 | { | |
134 | name += stl ; | |
135 | switch $(toolset) | |
136 | { | |
137 | case gcc* : name += g ; | |
138 | case darwin* : name += g ; | |
139 | case * : name += d ; | |
140 | } | |
141 | } | |
142 | ||
143 | if [ feature.get-values <runtime-link> : $(raw) ] = "static" | |
144 | { | |
145 | name += _static ; | |
146 | } | |
147 | ||
148 | # Starting with version 5.2.0, the STLport static libraries no | |
149 | # longer include a version number in their name | |
150 | local version.pre.5.2 = [ MATCH "^(5[.][01]+).*" : $(version) ] ; | |
151 | if $(version.pre.5.2) || [ feature.get-values <runtime-link> : | |
152 | $(raw) ] != "static" | |
153 | { | |
154 | name += .$(self.version.5) ; | |
155 | } | |
156 | ||
157 | name = $(name:J=) ; | |
158 | ||
159 | if [ feature.get-values <install-dependencies> : $(raw) ] = "on" | |
160 | { | |
161 | #~ Allow explicitly asking to install the STLport lib by | |
162 | #~ referring to it directly: | |
163 | #~ /stlport//stlport/<install-dependencies>on | |
164 | #~ This allows for install packaging of all libs one might need | |
165 | #~ for a standalone distribution. | |
166 | import path : make : path-make ; | |
167 | local runtime-link | |
168 | = [ feature.get-values <runtime-link> : $(raw) ] ; | |
169 | local lib-file.props | |
170 | = [ property-set.create $(raw) <link>$(runtime-link) ] ; | |
171 | local lib-file.prefix | |
172 | = [ type.generated-target-prefix $(runtime-link:U)_LIB : | |
173 | $(lib-file.props) ] ; | |
174 | local lib-file.suffix | |
175 | = [ type.generated-target-suffix $(runtime-link:U)_LIB : | |
176 | $(lib-file.props) ] ; | |
177 | lib-file.prefix | |
178 | ?= "" "lib" ; | |
179 | lib-file.suffix | |
180 | ?= "" ; | |
181 | local lib-file | |
182 | = [ GLOB $(self.libraries) [ modules.peek : PATH ] : | |
183 | $(lib-file.prefix)$(name).$(lib-file.suffix) ] ; | |
184 | lib-file | |
185 | = [ new file-reference [ path-make $(lib-file[1]) ] : | |
186 | $(self.project) ] ; | |
187 | lib-file | |
188 | = [ $(lib-file).generate "" ] ; | |
189 | local lib-file.requirements | |
190 | = [ targets.main-target-requirements | |
191 | [ $(lib-file.props).raw ] <file>$(lib-file[-1]) | |
192 | : $(self.project) ] ; | |
193 | return [ generators.construct $(self.project) $(name) : LIB : | |
194 | $(lib-file.requirements) ] ; | |
195 | } | |
196 | else | |
197 | { | |
198 | #~ Otherwise, it is just regular library usage. | |
199 | return [ generators.construct | |
200 | $(self.project) $(name) : SEARCHED_LIB : $(property-set) ] ; | |
201 | } | |
202 | } | |
203 | else if ! $(hostios) && $(toolset) != msvc | |
204 | { | |
205 | # We don't need libraries if host istreams are used. For | |
206 | # msvc, automatic library selection will be used. | |
207 | ||
208 | # name: stlport_<toolset>(_stldebug)? | |
209 | local name = stlport ; | |
210 | name = $(name)_$(toolset) ; | |
211 | if [ feature.get-values <runtime-debugging> : $(raw) ] = "on" | |
212 | { | |
213 | name = $(name)_stldebug ; | |
214 | } | |
215 | ||
216 | return [ generators.construct | |
217 | $(self.project) $(name) : SEARCHED_LIB : $(property-set) ] ; | |
218 | } | |
219 | else | |
220 | { | |
221 | return [ property-set.empty ] ; | |
222 | } | |
223 | } | |
224 | ||
225 | rule compute-usage-requirements ( subvariant ) | |
226 | { | |
227 | local usage-requirements = | |
228 | <include>$(self.headers) | |
229 | <dll-path>$(self.libraries) | |
230 | <library-path>$(self.libraries) | |
231 | ; | |
232 | ||
233 | local rproperties = [ $(subvariant).build-properties ] ; | |
234 | # CONSIDER: should this "if" sequence be replaced with | |
235 | # some use of 'property-map' class? | |
236 | if [ $(rproperties).get <runtime-debugging> ] = "on" | |
237 | { | |
238 | usage-requirements += | |
239 | <define>_STLP_DEBUG=1 | |
240 | <define>_STLP_DEBUG_UNINITIALIZED=1 ; | |
241 | } | |
242 | if [ $(rproperties).get <runtime-link> ] = "shared" | |
243 | { | |
244 | usage-requirements += | |
245 | <define>_STLP_USE_DYNAMIC_LIB=1 ; | |
246 | } | |
247 | if [ $(rproperties).get <stdlib-stlport:extensions> ] = noext | |
248 | { | |
249 | usage-requirements += | |
250 | <define>_STLP_NO_EXTENSIONS=1 ; | |
251 | } | |
252 | if [ $(rproperties).get <stdlib-stlport:iostream> ] = hostios | |
253 | { | |
254 | usage-requirements += | |
255 | <define>_STLP_NO_OWN_IOSTREAMS=1 | |
256 | <define>_STLP_HAS_NO_NEW_IOSTREAMS=1 ; | |
257 | } | |
258 | if $(self.version.5) | |
259 | { | |
260 | # Version 5.x | |
261 | if [ $(rproperties).get <threading> ] = "single" | |
262 | { | |
263 | # Since STLport5 doesn't normally support single-thread | |
264 | # we force STLport5 into the multi-thread mode. Hence | |
265 | # getting what other libs provide of single-thread code | |
266 | # linking against a multi-thread lib. | |
267 | usage-requirements += | |
268 | <define>_STLP_THREADS=1 ; | |
269 | } | |
270 | } | |
271 | ||
272 | return [ property-set.create $(usage-requirements) ] ; | |
273 | } | |
274 | } | |
275 | ||
276 | rule stlport-target ( headers ? : libraries * : version ? ) | |
277 | { | |
278 | local project = [ project.current ] ; | |
279 | ||
280 | targets.main-target-alternative | |
281 | [ new stlport-target-class $(project) : $(headers) : $(libraries) | |
282 | : $(version) | |
283 | ] ; | |
284 | } | |
285 | ||
286 | local .version-subfeature-defined ; | |
287 | ||
288 | # Initialize stlport support. | |
289 | rule init ( | |
290 | version ? : | |
291 | headers : # Location of header files | |
292 | libraries * # Location of libraries, lib and bin subdirs of STLport. | |
293 | ) | |
294 | { | |
295 | # FIXME: need to use common.check-init-parameters here. | |
296 | # At the moment, that rule always tries to define subfeature | |
297 | # of the 'toolset' feature, while we need to define subfeature | |
298 | # of <stdlib>stlport, so tweaks to check-init-parameters are needed. | |
299 | if $(version) | |
300 | { | |
301 | if ! $(.version-subfeature-defined) | |
302 | { | |
303 | feature.subfeature stdlib stlport : version : : propagated ; | |
304 | .version-subfeature-defined = true ; | |
305 | } | |
306 | feature.extend-subfeature stdlib stlport : version : $(version) ; | |
307 | } | |
308 | ||
309 | # Declare the main target for this STLPort version. | |
310 | stlport-target $(headers) : $(libraries) : $(version) ; | |
311 | } | |
312 |