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.
8
# Test the 'glob' rule in Jamfile context.
9
from BoostBuild import Tester, List
13
# Create a temporary working directory
16
t.write("project-root.jam", """
19
t.write("Jamfile", """
22
t.write("d1/a.cpp", """
23
int main() { return 0; }
27
t.write("d1/Jamfile", """
28
exe a : [ glob *.cpp ] ../d2/d//l ;
31
t.write("d2/d/l.cpp", """
34
void force_import_lib_creation() {}
38
t.write("d2/d/Jamfile", """
39
lib l : [ glob *.cpp ] ;
42
t.write("d3/d/Jamfile", """
43
exe a : [ glob ../*.cpp ] ;
45
t.write("d3/a.cpp", """
52
t.run_build_system(subdir="d1")
53
t.expect_addition("d1/bin/$toolset/debug/a.exe")
55
t.run_build_system(subdir="d3/d")
56
t.expect_addition("d3/d/bin/$toolset/debug/a.exe")
59
t.run_build_system(subdir="d2/d")
60
t.expect_addition("d2/d/bin/$toolset/debug/l.dll")
62
# Test that when 'source-location' is explicitly-specified
63
# glob works relatively to source location
66
t.write("d1/src/a.cpp", """
67
int main() { return 0; }
71
t.write("d1/Jamfile", """
72
project : source-location src ;
73
exe a : [ glob *.cpp ] ../d2/d//l ;
76
t.run_build_system(subdir="d1")
77
t.expect_addition("d1/bin/$toolset/debug/a.exe")
79
# Test that wildcards can include directories
82
t.write("d1/src/foo/a.cpp", """
84
int main() { bar(); return 0; }
88
t.write("d1/src/bar/b.cpp", """
94
t.write("d1/Jamfile", """
95
project : source-location src ;
96
exe a : [ glob foo/*.cpp bar/*.cpp ] ../d2/d//l ;
99
t.run_build_system(subdir="d1")
100
t.expect_addition("d1/bin/$toolset/debug/a.exe")
102
# Test that 'glob' works with absolute names
105
# Note that to get current dir, we use bjam's PWD,
106
# not Python's os.getcwd, because the former will
107
# always return long path. The latter might return
108
# short path, and that will confuse path.glob.
109
t.write("d1/Jamfile", """
110
project : source-location src ;
111
local pwd = [ PWD ] ; # Always absolute
112
exe a : [ glob $(pwd)/src/foo/*.cpp $(pwd)/src/bar/*.cpp ] ../d2/d//l ;
115
t.run_build_system(subdir="d1")
116
t.expect_addition("d1/bin/$toolset/debug/a.exe")