Imported Upstream version 1.51.0
[platform/upstream/boost.git] / tools / build / v2 / tools / message.py
1 # Status: ported.
2 # Base revision: 64488.
3 #
4 # Copyright 2008, 2010 Vladimir Prus
5 # Distributed under the Boost Software License, Version 1.0.
6 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7
8 # Defines main target type 'message', that prints a message when built for the
9 # first time.
10
11 import b2.build.targets as targets
12 import b2.build.property_set as property_set
13
14 from b2.manager import get_manager
15
16 class MessageTargetClass(targets.BasicTarget):
17
18     def __init__(self, name, project, *args):
19
20         targets.BasicTarget.__init__(self, name, project, [])
21         self.args = args
22         self.built = False
23
24     def construct(self, name, sources, ps):
25
26         if not self.built:
27             for arg in self.args:
28                 if type(arg) == type([]):
29                     arg = " ".join(arg)                
30                 print arg
31             self.built = True
32
33         return (property_set.empty(), [])
34
35 def message(name, *args):
36
37     if type(name) == type([]):
38         name = name[0]
39
40     t = get_manager().targets()
41     
42     project = get_manager().projects().current()
43         
44     return t.main_target_alternative(MessageTargetClass(*((name, project) + args)))
45
46 get_manager().projects().add_rule("message", message)