]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # Copyright 2003, 2004, 2006 Vladimir Prus |
2 | # Distributed under the Boost Software License, Version 1.0. | |
1e59de90 TL |
3 | # (See accompanying file LICENSE.txt or copy at |
4 | # https://www.bfgroup.xyz/b2/LICENSE.txt) | |
7c673cae FG |
5 | |
6 | # This module defines the 'alias' rule and the associated target class. | |
7 | # | |
8 | # Alias is just a main target which returns its source targets without any | |
9 | # processing. For example: | |
10 | # | |
11 | # alias bin : hello test_hello ; | |
12 | # alias lib : helpers xml_parser ; | |
13 | # | |
14 | # Another important use of 'alias' is to conveniently group source files: | |
15 | # | |
16 | # alias platform-src : win.cpp : <os>NT ; | |
17 | # alias platform-src : linux.cpp : <os>LINUX ; | |
18 | # exe main : main.cpp platform-src ; | |
19 | # | |
20 | # Lastly, it is possible to create a local alias for some target, with different | |
21 | # properties: | |
22 | # | |
23 | # alias big_lib : : @/external_project/big_lib/<link>static ; | |
24 | # | |
25 | ||
26 | import "class" : new ; | |
11fdf7f2 | 27 | import param ; |
7c673cae FG |
28 | import project ; |
29 | import property-set ; | |
30 | import targets ; | |
31 | ||
32 | ||
33 | class alias-target-class : basic-target | |
34 | { | |
35 | rule __init__ ( name : project : sources * : requirements * | |
36 | : default-build * : usage-requirements * ) | |
37 | { | |
38 | basic-target.__init__ $(name) : $(project) : $(sources) : | |
39 | $(requirements) : $(default-build) : $(usage-requirements) ; | |
40 | } | |
41 | ||
42 | rule construct ( name : source-targets * : property-set ) | |
43 | { | |
44 | return [ property-set.empty ] $(source-targets) ; | |
45 | } | |
46 | ||
47 | rule compute-usage-requirements ( subvariant ) | |
48 | { | |
49 | local base = [ basic-target.compute-usage-requirements $(subvariant) ] ; | |
50 | return [ $(base).add [ $(subvariant).sources-usage-requirements ] ] ; | |
51 | } | |
1e59de90 TL |
52 | |
53 | rule skip-from-usage-requirements ( ) | |
54 | { | |
55 | } | |
7c673cae FG |
56 | } |
57 | ||
58 | ||
59 | # Declares the 'alias' target. It will process its sources virtual-targets by | |
60 | # returning them unaltered as its own constructed virtual-targets. | |
61 | # | |
62 | rule alias ( name : sources * : requirements * : default-build * : | |
63 | usage-requirements * ) | |
64 | { | |
11fdf7f2 TL |
65 | param.handle-named-params |
66 | sources requirements default-build usage-requirements ; | |
67 | ||
7c673cae FG |
68 | local project = [ project.current ] ; |
69 | ||
70 | targets.main-target-alternative | |
71 | [ new alias-target-class $(name) : $(project) | |
72 | : [ targets.main-target-sources $(sources) : $(name) : no-renaming ] | |
73 | : [ targets.main-target-requirements $(requirements) : $(project) ] | |
74 | : [ targets.main-target-default-build $(default-build) : $(project) | |
75 | ] | |
76 | : [ targets.main-target-usage-requirements $(usage-requirements) : | |
77 | $(project) ] | |
78 | ] ; | |
79 | } | |
80 | ||
81 | ||
82 | IMPORT $(__name__) : alias : : alias ; |