1 # Copyright 2002-2017 Rene Rivera
2 # Copyright 2002-2017 Vladimir Prus
3 # Distributed under the Boost Software License, Version 1.0.
4 # (See accompanying file LICENSE_1_0.txt or copy at
5 # http://www.boost.org/LICENSE_1_0.txt)
9 import virtual-target ;
11 # Declare a special compiler generator. The only thing it does is changing the
12 # type used to represent 'action' in the constructed dependency graph to
13 # 'compile-action'. That class in turn adds additional include paths to handle
14 # cases when a source file includes headers which are generated themselves.
16 class C-compiling-generator : generator
18 rule __init__ ( id : source-types + : target-types + : requirements *
19 : optional-properties * )
21 generator.__init__ $(id) : $(source-types) : $(target-types) :
22 $(requirements) : $(optional-properties) ;
27 return compile-action ;
32 rule register-c-compiler ( id : source-types + : target-types + : requirements *
33 : optional-properties * )
35 generators.register [ new C-compiling-generator $(id) : $(source-types) :
36 $(target-types) : $(requirements) : $(optional-properties) ] ;
39 # FIXME: this is ugly, should find a better way (we would like client code to
40 # register all generators as "generators.some-rule" instead of
41 # "some-module.some-rule".)
43 IMPORT $(__name__) : register-c-compiler : : generators.register-c-compiler ;
45 class compile-action : action
49 rule __init__ ( targets * : sources * : action-name : properties * )
51 action.__init__ $(targets) : $(sources) : $(action-name) : $(properties) ;
54 # For all virtual targets for the same dependency graph as self, i.e. which
55 # belong to the same main target, add their directories to the include path.
57 rule adjust-properties ( property-set )
59 local s = [ $(self.targets[1]).creating-subvariant ] ;
62 return [ $(property-set).add-raw
63 [ $(s).implicit-includes "include" : H ] ] ;
67 return $(property-set) ;