1 # Copyright 2003, 2004, 2006 Vladimir Prus
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE_1_0.txt or copy at
4 # http://www.boost.org/LICENSE_1_0.txt)
6 # This module defines the 'alias' rule and the associated target class.
8 # Alias is just a main target which returns its source targets without any
9 # processing. For example:
11 # alias bin : hello test_hello ;
12 # alias lib : helpers xml_parser ;
14 # Another important use of 'alias' is to conveniently group source files:
16 # alias platform-src : win.cpp : <os>NT ;
17 # alias platform-src : linux.cpp : <os>LINUX ;
18 # exe main : main.cpp platform-src ;
20 # Lastly, it is possible to create a local alias for some target, with different
23 # alias big_lib : : @/external_project/big_lib/<link>static ;
26 import "class" : new ;
32 class alias-target-class : basic-target
34 rule __init__ ( name : project : sources * : requirements *
35 : default-build * : usage-requirements * )
37 basic-target.__init__ $(name) : $(project) : $(sources) :
38 $(requirements) : $(default-build) : $(usage-requirements) ;
41 rule construct ( name : source-targets * : property-set )
43 return [ property-set.empty ] $(source-targets) ;
46 rule compute-usage-requirements ( subvariant )
48 local base = [ basic-target.compute-usage-requirements $(subvariant) ] ;
49 return [ $(base).add [ $(subvariant).sources-usage-requirements ] ] ;
54 # Declares the 'alias' target. It will process its sources virtual-targets by
55 # returning them unaltered as its own constructed virtual-targets.
57 rule alias ( name : sources * : requirements * : default-build * :
58 usage-requirements * )
60 local project = [ project.current ] ;
62 targets.main-target-alternative
63 [ new alias-target-class $(name) : $(project)
64 : [ targets.main-target-sources $(sources) : $(name) : no-renaming ]
65 : [ targets.main-target-requirements $(requirements) : $(project) ]
66 : [ targets.main-target-default-build $(default-build) : $(project)
68 : [ targets.main-target-usage-requirements $(usage-requirements) :
74 IMPORT $(__name__) : alias : : alias ;