File: tag.py

package info (click to toggle)
boost-build 2.0-m12-2
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 8,692 kB
  • ctags: 6,963
  • sloc: ansic: 39,914; sh: 9,086; python: 6,120; xml: 5,524; cpp: 1,467; yacc: 456; asm: 353; makefile: 184
file content (106 lines) | stat: -rw-r--r-- 2,527 bytes parent folder | download | duplicates (3)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/python

#  Copyright (C) Pedro Ferreira 2003. Permission to copy, use, modify, sell and
#  distribute this software is granted provided this copyright notice appears in
#  all copies. This software is provided "as is" without express or implied
#  warranty, and with no claim as to its suitability for any purpose.

from BoostBuild import Tester, List
import string

t = Tester()

t.write("project-root.jam", "")
t.write("Jamfile", """ 
import virtual-target ;
rule tag ( name : type ? : property-set )
{
    local tags ;
    local v = [ $(property-set).get <variant> ] ;
    if $(v) = debug
    {
        tags += d ;
    }
    else if $(v) = release
    {
        tags += r ;
    }
    
    local l = [ $(property-set).get <link> ] ;
    if $(l) = shared
    {
        tags += s ;
    }
    else if $(l) = static
    {
        tags += t ;
    }
    
    if $(tags)
    {
        return [ virtual-target.add-prefix-and-suffix $(name)_$(tags:J="") 
            : $(type) : $(property-set) ] ;
    }
    
}

# Test both fully-qualified and local name of the rule
exe a : a.cpp : <tag>@$(__name__).tag ;
lib b : a.cpp : <tag>@tag ;
stage c : a ;
""")

t.write("a.cpp", """ 
int main()
{
    return 0;
}

#ifdef _MSC_VER
__declspec (dllexport) void x () {} 
#endif
""")

file_list = \
List("bin/$toolset/debug/a_ds.exe") + \
List("bin/$toolset/debug/b_ds.dll") + \
List("c/a_ds.exe") + \
List("bin/$toolset/release/a_rs.exe") + \
List("bin/$toolset/release/b_rs.dll") + \
List("c/a_rs.exe") + \
List("bin/$toolset/debug/link-static/a_dt.exe") + \
List("bin/$toolset/debug/link-static/b_dt.lib") + \
List("c/a_dt.exe") + \
List("bin/$toolset/release/link-static/a_rt.exe") + \
List("bin/$toolset/release/link-static/b_rt.lib") + \
List("c/a_rt.exe")

variants = "debug release link=static,shared"

t.run_build_system(variants)
t.expect_addition(file_list)

t.run_build_system(variants + " clean")
t.expect_removal(file_list)

# Regression test: the 'tag' feature did not work in directories that
# had dot in names.
t.write("version-1.32.0/Jamroot", """
project test : requirements <tag>@$(__name__).tag ;

rule tag ( name : type ? : property-set )
{
   # Do nothing, just make sure the rule is invoked OK.
   ECHO "The tag rule was invoked" ;
}
exe a : a.cpp ;
""")

t.write("version-1.32.0/a.cpp", "int main() { return 0; }\n")

t.run_build_system(subdir="version-1.32.0")
t.expect_addition("version-1.32.0/bin/$toolset/debug/a.exe")
t.fail_test(string.find(t.stdout(), "The tag rule was invoked") == -1)

t.cleanup()