summaryrefslogtreecommitdiff
path: root/tools/build/test/core_import_module.py
blob: c5bbd3e63817e3c35a5d771993e75c8b2d6616d5 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/python

# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

import BoostBuild

t = BoostBuild.Tester(pass_toolset=0)

t.write("code", """\
module a
{
    rule r1 ( )
    {
        ECHO R1 ;
    }

    local rule l1 ( )
    {
        ECHO A.L1 ;
    }
}
module a2
{
    rule r2 ( )
    {
        ECHO R2 ;
    }
}
IMPORT a2 : r2 : : a2.r2 ;

rule a.l1 ( )
{
    ECHO L1 ;
}

module b
{
    IMPORT_MODULE a : b ;
    rule test
    {
        # Call rule visible via IMPORT_MODULE
        a.r1 ;
        # Call rule in global scope
        a2.r2 ;
        # Call rule in global scope.  Doesn't find local rule
        a.l1 ;
        # Make l1 visible
        EXPORT a : l1 ;
        a.l1 ;
    }
}

IMPORT b : test : : test ;
test ;

module c
{
    rule test
    {
        ECHO CTEST ;
    }
}

IMPORT_MODULE c : ;
c.test ;

actions do-nothing { }
do-nothing all ;
""")

t.run_build_system(["-fcode"], stdout="""\
R1
R2
L1
A.L1
CTEST
""")

t.cleanup()