From adb0378d22d4a997abeb93ed9e17b0eb50431bfb Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 8 Apr 2015 23:00:16 -0500 Subject: [PATCH] Add more natural, i.e. direct, glob and glob-tree (ex) project local rules to make it easier to filter globs without repeating paths. --- src/build/project.jam | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/build/project.jam b/src/build/project.jam index 83d0377e4..b66d50e65 100644 --- a/src/build/project.jam +++ b/src/build/project.jam @@ -1001,6 +1001,32 @@ rule glob-internal ( project : wildcards + : excludes * : rule-name ) } +rule glob-path-root ( root path ) +{ + return [ path.root $(path) $(root) ] ; +} + +rule glob-internal-ex ( project : paths + : wildcards + : excludes * : rule-name ) +{ + # Make the paths we search in absolute, if they aren't already absolute. + # If the given paths are relative, they will be relative to the source + # directory. So that's what we root against. + local source-location + = [ path.root [ $(project).get source-location ] [ path.pwd ] ] ; + local search-paths + = [ sequence.transform project.glob-path-root $(source-location) : $(paths) ] ; + paths + = [ path.$(rule-name) $(search-paths) : $(wildcards) : $(excludes) ] ; + # The paths we have found are absolute, but the names specified in the + # sources list are assumed to be relative to the source directory of the + # corresponding project. Make the results relative to the source again. + local result + = [ sequence.transform path.relative-to $(source-location) : $(paths) ] ; + + return $(result) ; +} + + # This module defines rules common to all projects. # module project-rules @@ -1211,6 +1237,20 @@ module project-rules $(excludes) : glob-tree ] ; } + rule glob-ex ( paths + : wildcards + : excludes * ) + { + import project ; + return [ project.glob-internal-ex [ project.current ] + : $(paths) : $(wildcards) : $(excludes) : glob ] ; + } + + rule glob-tree-ex ( paths + : wildcards + : excludes * ) + { + import project ; + return [ project.glob-internal-ex [ project.current ] + : $(paths) : $(wildcards) : $(excludes) : glob-tree ] ; + } + # Calculates conditional requirements for multiple requirements at once. # This is a shorthand to reduce duplication and to keep an inline # declarative syntax. For example: