From 552d98e3f874eba74c869ad17138035a3107caa2 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 28 Dec 2004 17:54:35 +0000 Subject: [PATCH] Fix a regression in the 'glob' rule -- it is broken with the current bjam. Handle ".." correctly. [SVN r26595] --- v2/test/glob.py | 14 +++++++++++++- v2/util/path.jam | 29 +++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/v2/test/glob.py b/v2/test/glob.py index aaf400e87..46cd0e394 100644 --- a/v2/test/glob.py +++ b/v2/test/glob.py @@ -37,10 +37,22 @@ t.write("d2/d/Jamfile", """ lib l : [ glob *.cpp ] ; """) -t.run_build_system(subdir="d1") +t.write("d3/d/Jamfile", """ +exe a : [ glob ../*.cpp ] ; +""") +t.write("d3/a.cpp", """ +int main() +{ + return 0; +} +""") +t.run_build_system(subdir="d1") t.expect_addition("d1/bin/$toolset/debug/a.exe") +t.run_build_system(subdir="d3/d") +t.expect_addition("d3/d/bin/$toolset/debug/a.exe") + t.rm("d2/d/bin") t.run_build_system(subdir="d2/d") t.expect_addition("d2/d/bin/$toolset/debug/l.dll") diff --git a/v2/util/path.jam b/v2/util/path.jam index 66ded3c25..74aa9197a 100644 --- a/v2/util/path.jam +++ b/v2/util/path.jam @@ -217,9 +217,34 @@ rule glob ( dirs * : patterns + ) } else { - for dir in $(dirs) + # When a pattern has not directory, we glob directly. + # Take care of special ".." value. The "GLOB" rule simply ignores + # the ".." element (and ".") element in directory listings. This is + # needed so that + # + # [ glob libs/*/Jamfile ] + # + # don't return + # + # libs/../Jamfile (which is the same as ./Jamfile) + # + # On the other hand, when ".." is explicitly present in the pattern + # we need to return it. + # + for local dir in $(dirs) { - result += [ sequence.transform make : [ GLOB [ native $(dir) ] : $(patterns) ] ] ; + for local p in $(patterns) + { + if $(p) != ".." + { + result += [ sequence.transform make + : [ GLOB [ native $(dir) ] : $(p) ] ] ; + } + else + { + result += [ path.join $(dir) .. ] ; + } + } } } return $(result) ;