1 # Copyright (c) 2009 Vladimir Prus
3 # Use, modification and distribution is subject to the Boost Software
4 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
5 # http://www.boost.org/LICENSE_1_0.txt)
7 # Implements 'convert' target that takes a bunch of source and
8 # tries to convert each one to the specified type.
12 # convert objects obj : a.cpp b.cpp ;
19 import "class" : new ;
21 class convert-target-class : typed-target
23 rule __init__ ( name : project : type
24 : sources * : requirements * : default-build * : usage-requirements * )
26 typed-target.__init__ $(name) : $(project) : $(type)
27 : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ;
30 rule construct ( name : source-targets * : property-set )
32 local r = [ generators.construct $(self.project) : $(self.type)
33 : [ property-set.create [ $(property-set).raw ] # [ feature.expand
34 <main-target-type>$(self.type) ]
36 : $(source-targets) ] ;
39 errors.error "unable to construct" [ full-name ] ;
47 rule convert ( name type : sources * : requirements * : default-build *
48 : usage-requirements * )
50 local project = [ project.current ] ;
52 # This is a circular module dependency, so it must be imported here
53 modules.import targets ;
54 targets.main-target-alternative
55 [ new convert-target-class $(name) : $(project) : [ type.type-from-rule-name $(type) ]
56 : [ targets.main-target-sources $(sources) : $(name) ]
57 : [ targets.main-target-requirements $(requirements) : $(project) ]
58 : [ targets.main-target-default-build $(default-build) : $(project) ]
59 : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ]
62 IMPORT $(__name__) : convert : : convert ;