summaryrefslogtreecommitdiff
path: root/jam-files/boost-build/tools/make.py
blob: 10baa1cb41be8f45d32f177c038efda30ee07805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Status: ported.
# Base revision: 64068

# Copyright 2003 Dave Abrahams 
# Copyright 2003 Douglas Gregor 
# Copyright 2006 Rene Rivera 
# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 

#  This module defines the 'make' main target rule.

from b2.build.targets import BasicTarget
from b2.build.virtual_target import Action, FileTarget
from b2.build import type
from b2.manager import get_manager
import b2.build.property_set


class MakeTarget(BasicTarget):
  
    def construct(self, name, source_targets, property_set):

        action_name = property_set.get("<action>")[0]            
        action = Action(get_manager(), source_targets, action_name[1:], property_set)
        target = FileTarget(self.name(), type.type(self.name()),
                            self.project(), action, exact=True)    
        return [ b2.build.property_set.empty(),
                 [self.project().manager().virtual_targets().register(target)]]

def make (target_name, sources, generating_rule,
          requirements=None, usage_requirements=None):

    target_name = target_name[0]
    generating_rule = generating_rule[0]
    if generating_rule[0] != '@':
        generating_rule = '@' + generating_rule

    if not requirements:
        requirements = []

        
    requirements.append("<action>%s" % generating_rule)
    
    m = get_manager()
    targets = m.targets()
    project = m.projects().current()
    engine = m.engine()
    engine.register_bjam_action(generating_rule)

    targets.main_target_alternative(MakeTarget(
        target_name, project,
        targets.main_target_sources(sources, target_name),
        targets.main_target_requirements(requirements, project),
        targets.main_target_default_build([], project),
        targets.main_target_usage_requirements(usage_requirements or [], project)))

get_manager().projects().add_rule("make", make)