From 76b9d2d819212aea392aabc6eab26de77dd4f536 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 2 Dec 2004 09:41:31 +0000 Subject: [PATCH] Allow the 'path.glob' and 'glob' Jamfile rule to accept wildcards in directory names. For example: exe a : [ glob */*.cpp ] ; now works. [SVN r26398] --- v2/build/project.jam | 40 ++++++++++++++++++---------------------- v2/util/path.jam | 17 +++++++++++++++-- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/v2/build/project.jam b/v2/build/project.jam index 43c9574f0..d5d0b88bf 100644 --- a/v2/build/project.jam +++ b/v2/build/project.jam @@ -710,32 +710,28 @@ module project-rules local location = [ project.attribute $(__name__) source-location ] ; - local all-paths ; - if ! $(wildcards:D) + local result ; + local paths = [ path.glob $(location) : $(wildcards) ] ; + if $(wildcards:D) { - # No directory in any wildcard -- the simplest case. - all-paths = [ path.glob $(location) : $(wildcards) ] ; - all-paths = $(all-paths:D="") ; - } - else - { - for local w in $(wildcards) + # The paths we've found are relative to current directory, + # but the names specified in sources list are assumed to + # be relative to source directory of the corresponding + # prject. So, just make the name absolute. + for local p in $(paths) { - local l = [ path.join $(location) $(w:D) ] ; - local paths = [ path.glob $(l) : $(w:D="") ] ; - # The paths we've found are relative to current directory, - # but the names specified in sources list are assumed to - # be relative to source directory of the corresponding - # prject. So, just make the name absolute. - for local p in $(paths) - { - all-paths += [ path.root $(p) [ path.pwd ] ] ; - } - } - + result += [ path.root $(p) [ path.pwd ] ] ; + } + } + else + { + # There were not directory in wildcard, so the files are all + # in the source directory of the project. Just drop the + # directory, instead of making paths absolute. + result = $(paths:D="") ; } - return $(all-paths) ; + return $(result) ; } } diff --git a/v2/util/path.jam b/v2/util/path.jam index fddda362f..092153af3 100644 --- a/v2/util/path.jam +++ b/v2/util/path.jam @@ -193,10 +193,23 @@ rule pwd ( ) rule glob ( dirs * : patterns + ) { local result ; - for dir in $(dirs) + if $(patterns:D) { - result += [ sequence.transform make : [ GLOB [ native $(dir) ] : $(patterns) ] ] ; + # Have directory in pattern, do something more complex. + for local p in $(patterns) + { + # First glob for directory part. + local globbed-dirs = [ glob $(dirs) : $(p:D) ] ; + result += [ glob $(globbed-dirs) : $(p:D="") ] ; + } } + else + { + for dir in $(dirs) + { + result += [ sequence.transform make : [ GLOB [ native $(dir) ] : $(patterns) ] ] ; + } + } return $(result) ; }