Imported Upstream version 1.51.0
[platform/upstream/boost.git] / tools / build / v2 / tools / notfile.py
1 # Status: ported.
2 # Base revision: 64429.
3 #
4 #  Copyright (c) 2005-2010 Vladimir Prus.
5 #
6 #  Use, modification and distribution is subject to the Boost Software
7 #  License Version 1.0. (See accompanying file LICENSE_1_0.txt or
8 #  http://www.boost.org/LICENSE_1_0.txt)
9
10
11 import b2.build.type as type
12 import b2.build.generators as generators
13 import b2.build.virtual_target as virtual_target
14 import b2.build.toolset as toolset
15 import b2.build.targets as targets
16
17 from b2.manager import get_manager
18 from b2.util import bjam_signature
19
20 type.register("NOTFILE_MAIN")
21
22 class NotfileGenerator(generators.Generator):
23
24     def run(self, project, name, ps, sources):
25         pass
26         action_name = ps.get('action')[0]
27         if action_name[0] == '@':
28             action = virtual_target.Action(get_manager(), sources, action_name[1:], ps)
29         else:
30             action = virtual_target.Action(get_manager(), sources, "notfile.run", ps)
31
32         return [get_manager().virtual_targets().register(
33             virtual_target.NotFileTarget(name, project, action))]
34
35 generators.register(NotfileGenerator("notfile.main", False, [], ["NOTFILE_MAIN"]))
36
37 toolset.flags("notfile.run", "ACTION", [], ["<action>"])
38
39 get_manager().engine().register_action("notfile.run", "$(ACTION)")
40
41 @bjam_signature((["target_name"], ["action"], ["sources", "*"], ["requirements", "*"],
42                  ["default_build", "*"]))
43 def notfile(target_name, action, sources, requirements, default_build):
44
45     requirements.append("<action>" + action)
46
47     return targets.create_typed_metatarget(target_name, "NOTFILE_MAIN", sources, requirements,
48                                            default_build, [])
49
50
51 get_manager().projects().add_rule("notfile", notfile)