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.
|
---|
5 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
---|
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) ;
|
---|
92 | self.requirements = [ property-set.create $(requirements) ] ;
|
---|
93 | }
|
---|
94 |
|
---|
95 | rule generate ( property-set )
|
---|
96 | {
|
---|
97 | # Since this target is built with <stdlib>stlport, it will also
|
---|
98 | # have <library>/stlport//stlport in requirements, which will
|
---|
99 | # cause a loop in main target references. Remove that property
|
---|
100 | # manually.
|
---|
101 |
|
---|
102 | property-set = [ property-set.create
|
---|
103 | [ difference
|
---|
104 | [ $(property-set).raw ] :
|
---|
105 | <library>/stlport//stlport
|
---|
106 | <stdlib>stlport
|
---|
107 | ]
|
---|
108 | ] ;
|
---|
109 | return [ basic-target.generate $(property-set) ] ;
|
---|
110 | }
|
---|
111 |
|
---|
112 | rule construct ( name : source-targets * : property-set )
|
---|
113 | {
|
---|
114 | # Deduce the name of stlport library, based on toolset and
|
---|
115 | # debug setting.
|
---|
116 | local raw = [ $(property-set).raw ] ;
|
---|
117 | local hostios = [ feature.get-values <stdlib-stlport:iostream> : $(raw) ] ;
|
---|
118 | local toolset = [ feature.get-values <toolset> : $(raw) ] ;
|
---|
119 |
|
---|
120 | if $(self.version.5)
|
---|
121 | {
|
---|
122 | # Version 5.x
|
---|
123 |
|
---|
124 | # STLport host IO streams no longer supported. So we always
|
---|
125 | # need libraries.
|
---|
126 |
|
---|
127 | # name: stlport(stl)?[dg]?(_static)?.M.R
|
---|
128 | local name = stlport ;
|
---|
129 | if [ feature.get-values <runtime-debugging> : $(raw) ] = "on"
|
---|
130 | {
|
---|
131 | name += stl ;
|
---|
132 | switch $(toolset)
|
---|
133 | {
|
---|
134 | case gcc* : name += g ;
|
---|
135 | case darwin* : name += g ;
|
---|
136 | case * : name += d ;
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | if [ feature.get-values <runtime-link> : $(raw) ] = "static"
|
---|
141 | {
|
---|
142 | name += _static ;
|
---|
143 | }
|
---|
144 |
|
---|
145 | name += .$(self.version.5) ;
|
---|
146 | name = $(name:J=) ;
|
---|
147 |
|
---|
148 | if [ feature.get-values <install-dependencies> : $(raw) ] = "on"
|
---|
149 | {
|
---|
150 | #~ Allow explicitly asking to install the STLport lib by
|
---|
151 | #~ refering to it directly: /stlport//stlport/<install-dependencies>on
|
---|
152 | #~ This allows for install packaging of all libs one might need for
|
---|
153 | #~ a standalone distribution.
|
---|
154 | import path : make : path-make ;
|
---|
155 | local runtime-link
|
---|
156 | = [ feature.get-values <runtime-link> : $(raw) ] ;
|
---|
157 | local lib-file.props
|
---|
158 | = [ property-set.create $(raw) <link>$(runtime-link) ] ;
|
---|
159 | local lib-file.prefix
|
---|
160 | = [ type.generated-target-prefix $(runtime-link:U)_LIB : $(lib-file.props) ] ;
|
---|
161 | local lib-file.suffix
|
---|
162 | = [ type.generated-target-suffix $(runtime-link:U)_LIB : $(lib-file.props) ] ;
|
---|
163 | lib-file.prefix
|
---|
164 | ?= "" "lib" ;
|
---|
165 | lib-file.suffix
|
---|
166 | ?= "" ;
|
---|
167 | local lib-file
|
---|
168 | = [ GLOB $(self.libraries) [ modules.peek : PATH ] :
|
---|
169 | $(lib-file.prefix)$(name).$(lib-file.suffix) ] ;
|
---|
170 | lib-file
|
---|
171 | = [ new file-reference [ path-make $(lib-file[1]) ] : $(self.project) ] ;
|
---|
172 | lib-file
|
---|
173 | = [ $(lib-file).generate "" ] ;
|
---|
174 | local lib-file.requirements
|
---|
175 | = [ targets.main-target-requirements
|
---|
176 | [ $(lib-file.props).raw ] <file>$(lib-file[-1])
|
---|
177 | : $(self.project) ] ;
|
---|
178 | return [ generators.construct $(self.project) $(name) : LIB : $(lib-file.requirements) ] ;
|
---|
179 | }
|
---|
180 | else
|
---|
181 | {
|
---|
182 | #~ Otherwise, it's just a regular usage of the library.
|
---|
183 | return [ generators.construct
|
---|
184 | $(self.project) $(name) : SEARCHED_LIB : $(property-set) ] ;
|
---|
185 | }
|
---|
186 | }
|
---|
187 | else if ! $(hostios) && $(toolset) != msvc
|
---|
188 | {
|
---|
189 | # We don't need libraries if host istreams are used. For
|
---|
190 | # msvc, automatic library selection will be used.
|
---|
191 |
|
---|
192 | # name: stlport_<toolset>(_stldebug)?
|
---|
193 | local name = stlport ;
|
---|
194 | name = $(name)_$(toolset) ;
|
---|
195 | if [ feature.get-values <runtime-debugging> : $(raw) ] = "on"
|
---|
196 | {
|
---|
197 | name = $(name)_stldebug ;
|
---|
198 | }
|
---|
199 |
|
---|
200 | return [ generators.construct
|
---|
201 | $(self.project) $(name) : SEARCHED_LIB : $(property-set) ] ;
|
---|
202 | }
|
---|
203 | else
|
---|
204 | {
|
---|
205 | return [ property-set.empty ] ;
|
---|
206 | }
|
---|
207 | }
|
---|
208 |
|
---|
209 | rule compute-usage-requirements ( subvariant )
|
---|
210 | {
|
---|
211 | local usage-requirements =
|
---|
212 | <include>$(self.headers)
|
---|
213 | <dll-path>$(self.libraries)
|
---|
214 | <library-path>$(self.libraries)
|
---|
215 | ;
|
---|
216 |
|
---|
217 | local rproperties = [ $(subvariant).build-properties ] ;
|
---|
218 | # CONSIDER: should this "if" sequence be replaced with
|
---|
219 | # some use of 'property-map' class?
|
---|
220 | if [ $(rproperties).get <runtime-debugging> ] = "on"
|
---|
221 | {
|
---|
222 | usage-requirements +=
|
---|
223 | <define>_STLP_DEBUG=1
|
---|
224 | <define>_STLP_DEBUG_UNINITIALIZED=1 ;
|
---|
225 | }
|
---|
226 | if [ $(rproperties).get <runtime-link> ] = "shared"
|
---|
227 | {
|
---|
228 | usage-requirements +=
|
---|
229 | <define>_STLP_USE_DYNAMIC_LIB=1 ;
|
---|
230 | }
|
---|
231 | if [ $(rproperties).get <stdlib-stlport:extensions> ] = noext
|
---|
232 | {
|
---|
233 | usage-requirements +=
|
---|
234 | <define>_STLP_NO_EXTENSIONS=1 ;
|
---|
235 | }
|
---|
236 | if [ $(rproperties).get <stdlib-stlport:iostream> ] = hostios
|
---|
237 | {
|
---|
238 | usage-requirements +=
|
---|
239 | <define>_STLP_NO_OWN_IOSTREAMS=1
|
---|
240 | <define>_STLP_HAS_NO_NEW_IOSTREAMS=1 ;
|
---|
241 | }
|
---|
242 | if $(self.version.5)
|
---|
243 | {
|
---|
244 | # Version 5.x
|
---|
245 | if [ $(rproperties).get <threading> ] = "single"
|
---|
246 | {
|
---|
247 | # Since STLport5 doesn't normally support single-thread
|
---|
248 | # we force STLport5 into the multi-thread mode. Hence
|
---|
249 | # getting what other libs provide of single-thread code
|
---|
250 | # linking against a multi-thread lib.
|
---|
251 | usage-requirements +=
|
---|
252 | <define>_STLP_THREADS=1 ;
|
---|
253 | }
|
---|
254 | }
|
---|
255 |
|
---|
256 | return [ property-set.create $(usage-requirements) ] ;
|
---|
257 | }
|
---|
258 | }
|
---|
259 |
|
---|
260 | rule stlport-target ( headers ? : libraries * : version ? )
|
---|
261 | {
|
---|
262 | local project = [ project.current ] ;
|
---|
263 |
|
---|
264 | targets.main-target-alternative
|
---|
265 | [ new stlport-target-class $(project) : $(headers) : $(libraries)
|
---|
266 | : $(version)
|
---|
267 | ] ;
|
---|
268 | }
|
---|
269 |
|
---|
270 | local .version-subfeature-defined ;
|
---|
271 |
|
---|
272 | # Initialize stlport support.
|
---|
273 | rule init (
|
---|
274 | version ? :
|
---|
275 | headers : # Location of header files
|
---|
276 | libraries * # Location of libraries, lib and bin subdirs of STLport.
|
---|
277 | )
|
---|
278 | {
|
---|
279 | # FIXME: need to use common.check-init-parameters here.
|
---|
280 | # At the moment, that rule always tries to define subfeature
|
---|
281 | # of the 'toolset' feature, while we need to define subfeature
|
---|
282 | # of <stdlib>stlport, so tweaks to check-init-parameters are needed.
|
---|
283 | if $(version)
|
---|
284 | {
|
---|
285 | if ! $(.version-subfeature-defined)
|
---|
286 | {
|
---|
287 | feature.subfeature stdlib stlport : version : : propagated ;
|
---|
288 | .version-subfeature-defined = true ;
|
---|
289 | }
|
---|
290 | feature.extend-subfeature stdlib stlport : version : $(version) ;
|
---|
291 | }
|
---|
292 |
|
---|
293 | # Declare the main target for this STLPort version.
|
---|
294 | stlport-target $(headers) : $(libraries) : $(version) ;
|
---|
295 | }
|
---|
296 |
|
---|