Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/build/v2/test/dll_path.py @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1#!/usr/bin/python
2
3#  Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
4#  distribute this software is granted provided this copyright notice appears in
5#  all copies. This software is provided "as is" without express or implied
6#  warranty, and with no claim as to its suitability for any purpose.
7
8#  Test that the <dll-path> property is correctly set when using
9#  <hardcode-dll-paths>true.
10from BoostBuild import Tester, List
11from string import find
12
13
14t = Tester()
15
16# The point of this test is to have exe "main" which uses library "b",
17# which uses library "a". When "main" is built with <hardcode-dll-paths>true,
18# paths to both libraries should be present as values of <dll-path> feature.
19# We create a special target type which reports <dll-path> values on its sources
20# and compare the list of found values with out expectations.
21
22t.write("Jamfile", """
23exe main : main.cpp b//b ;
24explicit main ;
25
26path-list mp : main ;
27""")
28
29t.write("main.cpp", """
30int main() { return 0; }
31
32""")
33
34t.write("project-root.jam", """
35using dll-paths ;
36""")
37
38t.write("dll-paths.jam", """
39import type ;
40import generators ;
41import feature ;
42import sequence ;
43import print ;
44import "class" : new ;
45
46rule init ( )
47{
48    type.register PATH_LIST : pathlist ;
49   
50    class dll-paths-list-generator : generator
51    {
52        rule __init__ ( )
53        {
54            generator.__init__ dll-paths.list : EXE : PATH_LIST ;
55        }
56       
57        rule generated-targets ( sources + : property-set : project name ? )       
58        {
59            local dll-paths ;
60            for local s in $(sources)
61            {
62                local a = [ $(s).action ] ;
63                if $(a)
64                {
65                    local p = [ $(a).properties ] ;
66                    dll-paths += [ $(p).get <dll-path> ] ;
67                }                                               
68            }
69            return [ generator.generated-targets $(sources)
70              : [ $(property-set).add-raw $(dll-paths:G=<dll-path>) ] : $(project) $(name) ] ;
71           
72        }
73    }
74    generators.register [ new dll-paths-list-generator ] ;
75   
76}
77
78rule list ( target : sources * : properties * )
79{
80    local paths = [ feature.get-values <dll-path> : $(properties) ] ;
81    paths = [ sequence.insertion-sort $(paths) ] ;
82    print.output $(target) ;
83    print.text $(paths) ;
84}
85
86""")
87
88t.write("a/a.cpp", """
89void
90#if defined(_WIN32)
91__declspec(dllexport)
92#endif
93foo() {}
94
95
96""")
97
98t.write("a/Jamfile", """
99lib a : a.cpp ;
100""")
101
102t.write("b/b.cpp", """
103void
104#if defined(_WIN32)
105__declspec(dllexport)
106#endif
107bar() {}
108
109
110""")
111
112t.write("b/Jamfile", """
113lib b : b.cpp ../a//a ;
114""")
115
116t.run_build_system("hardcode-dll-paths=true")
117
118t.expect_addition("bin/$toolset/debug/mp.pathlist")
119
120es1 = t.adjust_names(["a/bin/$toolset/debug"])[0]
121es2 = t.adjust_names(["b/bin/$toolset/debug"])[0]
122content = t.read("bin/$toolset/debug/mp.pathlist")
123
124t.fail_test(find(content, es1) == -1)
125t.fail_test(find(content, es2) == -1)
126
127t.cleanup()
128
Note: See TracBrowser for help on using the repository browser.