diff --git a/src/build/property-set.jam b/src/build/property-set.jam index 5d8aaa2c1..718cd7c8e 100644 --- a/src/build/property-set.jam +++ b/src/build/property-set.jam @@ -162,6 +162,13 @@ local rule property-set ( raw-properties * ) } return $(self.added.$(ps)) ; } + + # Returns all values of 'feature'. + rule get ( feature ) + { + return [ feature.get-values $(feature) : $(self.raw) ] ; + } + } class property-set ; diff --git a/src/tools/builtin.jam b/src/tools/builtin.jam index e38d0aa02..381fb5b94 100644 --- a/src/tools/builtin.jam +++ b/src/tools/builtin.jam @@ -29,7 +29,7 @@ feature os : $(os) : propagated link-incompatible ; feature toolset : : implicit propagated link-incompatible symmetric ; -feature stdlib : native : propagated link-incompatible ; +feature stdlib : native : propagated link-incompatible composite ; feature link : shared static : propagated ; feature link-runtime : shared static : propagated ; diff --git a/src/tools/stlport.jam b/src/tools/stlport.jam index 65fd4aee9..f21774a23 100644 --- a/src/tools/stlport.jam +++ b/src/tools/stlport.jam @@ -1,79 +1,169 @@ # (C) Copyright Gennadiy Rozental 2002. -# (C) Copyright Vladimir Prus 2002. +# (C) Copyright Vladimir Prus 2003. # Permission to copy, use, # modify, sell and distribute this software is granted provided this # copyright notice appears in all copies. This software is provided # "as is" without express or implied warranty, and with no claim as # to its suitability for any purpose. +# The STLPort is usable by means of 'stdlib' feature. When +# stdlib=stlport is specified, default version of STLPort will be used, +# while stdlib=stlport-4.5 will use specific version. +# The subfeature value 'hostios' means to use host compiler's iostreams. +# +# The specific version of stlport is selected by features: +# The feature selects between static and shared library +# The on selects STLPort with debug symbols +# and stl debugging. +# There's no way to use STLPort with debug symbols but without +# stl debugging. + +# TODO: must implement selection of different STLPort installations based +# on used toolset. +# Also, finish various flags: +# +# This is copied from V1 toolset, "+" means "impelemnted" +#+flags $(CURR_TOOLSET) DEFINES off : _STLP_NO_OWN_IOSTREAMS=1 _STLP_HAS_NO_NEW_IOSTREAMS=1 ; +#+flags $(CURR_TOOLSET) DEFINES off : _STLP_NO_EXTENSIONS=1 ; +# flags $(CURR_TOOLSET) DEFINES off : _STLP_NO_ANACHRONISMS=1 ; +# flags $(CURR_TOOLSET) DEFINES global : _STLP_VENDOR_GLOBAL_CSTD=1 ; +# flags $(CURR_TOOLSET) DEFINES off : _STLP_NO_EXCEPTIONS=1 ; +# flags $(CURR_TOOLSET) DEFINES on : _STLP_DEBUG_ALLOC=1 ; +#+flags $(CURR_TOOLSET) DEFINES debug : _STLP_DEBUG=1 _STLP_DEBUG_UNINITIALIZED=1 ; +#+flags $(CURR_TOOLSET) DEFINES dynamic : _STLP_USE_DYNAMIC_LIB=1 ; + + import feature : feature subfeature ; +import project ; +import class : class new ; +import targets ; +import property-set ; + +# Make this module into a project. +project.initialize $(__name__) ; +project stlport ; + +# The problem: how to request to use host compiler's iostreams? +# +# Solution 1: Global 'stlport-iostream' feature. +# That's ugly. Subfeature make more sense for stlport-specific thing. +# Solution 2: Use subfeature with two values, one of which ("use STLPort iostream") +# is default. +# The problem is that such subfeature will appear in target paths, and that's ugly +# Solution 3: Use optional subfeature with only one value. feature.extend stdlib : stlport ; +feature.compose stlport : @/stlport/stlport ; + +subfeature stdlib stlport : version : : optional propagated link-incompatible ; # STLport iostreams or native iostreams -subfeature stdlib stlport : iostream : hostios : optional propagated ; +subfeature stdlib stlport : iostream : hostios : optional propagated ; # STLport extensions -#subfeature stdlib stlport : extensions : on off ; +subfeature stdlib stlport : extensions : noext : optional propagated ; -# STLport anachronisms -#subfeature stdlib stlport : anachronisms : on off ; +# STLport anachronisms -- NOT YET SUPPORTED +# subfeature stdlib stlport : anachronisms : on off ; -# STLport debug allocation +# STLport debug allocation -- NOT YET SUPPORTED #subfeature stdlib stlport : debug-alloc : off on ; -# Initialize stlport support. -rule init ( headers # Location of header files - : libraries ? # Location of libraries - ) -{ - .headers = $(headers) ; - .libraries = $(libraries) ; - - feature.action stlport : adjust-properties ; -} +# Declare a special target class to handle the creation of search-lib-target +# instances for STLport. We need a special class, because otherwise we'll have +# - declare prebuilt targets for all possible toolsets. And by the time 'init' +# is called we don't even know the list of toolsets that are registered +# - when host iostreams are used, we really should produce nothing. It would +# be hard/impossible to achieve this using prebuilt targets. -rule adjust-properties ( property : properties * ) +rule stlport-target-class ( project : headers ? : libraries ? : requirements * ) { - local result = $(.headers) ; + basic-target.__init__ stlport : $(project) : : $(requirements) ; + self.headers = $(headers) ; + self.libraries = $(libraries) ; - local need-library ; - if hostios in $(properties) + import feature project type errors generators ; + + rule construct ( source-targets * : property-set ) { - result += _STLP_NO_OWN_IOSTREAMS ; - } - else - { - result += $(.libraries) ; - need-library = true ; - } - - # Commented out until I find out why stlport won't link - # with debugging on, using Boost.Build or otherwise. - if $(0) { + # Deduce the name of stlport library, based on toolset and + # debug setting. + local raw = [ $(property-set).raw ] ; + local hostios = [ feature.get-values : $(raw) ] ; - local library ; - if debug in $(properties) + if ! $(hostios) + { + local toolset = [ feature.get-values : $(raw) ] ; + local debug = [ feature.get-values : $(raw) ] ; + + local name = stlport ; + name = $(name)_$(toolset) ; + if $(debug) = "on" + { + name = $(name)_stldebug ; + } + + return [ generators.construct $(self.project) $(name) : SEARCHED_LIB + : $(property-set) ] ; + } + + } + + rule compute-usage-requirements ( rproperties ) { - result += _STLP_DEBUG ; - library = stlport_gcc_debug pthread ; - } - else - { - library = stlport_gcc ; - } - } + local usage-requirements ; + usage-requirements += + $(self.headers) + $(self.libraries) + $(self.libraries) + ; + + # CONSIDER: should this "if" sequence be replaced with + # some use of 'property-map' class? + if [ $(rproperties).get ] = "on" + { + usage-requirements += _STLP_DEBUG=1 + _STLP_DEBUG_UNINITIALIZED=1 ; + } + if [ $(rproperties).get ] = "on" + { + usage-requirements += _STLP_USE_DYNAMIC_LIB=1 ; + } + if [ $(rproperties).get ] = noext + { + usage-requirements += _STLP_NO_EXTENSIONS=1 ; + } + if [ $(rproperties).get ] = hostios + { + usage-requirements += _STLP_NO_OWN_IOSTREAMS=1 + _STLP_HAS_NO_NEW_IOSTREAMS=1 ; + } + + return [ property-set.create $(usage-requirements) ] ; + } +} +class stlport-target-class : basic-target ; + + +rule stlport-target ( headers ? : libraries ? : requirements * ) +{ + local project = [ CALLER_MODULE ] ; - library = stlport_gcc ; - - - if $(need-library) - { - result += $(library) ; - } - - - return $(result) ; + targets.main-target-alternative + [ new stlport-target-class $(project) : $(headers) : $(libraries) + : [ targets.main-target-requirements $(requirements) : $(project) ] + ] ; } +# Initialize stlport support. +rule init ( version ? : + headers # Location of header files + : libraries ? # Location of libraries + ) +{ + feature.extend-subfeature stdlib stlport : version : $(version) ; + + # Declare the main target for this STLPort version. + stlport-target $(headers) : $(libraries) : stlport-$(version) ; +}