Boost logo

Boost-Build :

Subject: Re: [Boost-build] bjam install rule to install a directory hierarchy
From: Mark E. Hamilton (mhamilt_at_[hidden])
Date: 2011-07-14 19:26:56


Hi,

FWIW, I made a change to path.glob-tree (shown below) to allow me to
optionally exclude directories from the list it returns. This does what
I want, but I really don't want to modify path.jam if there's a better
way to do what I need.

# If files-only is passed any directories matched by the exclude-patterns
# will still be searched recursively, but the directory names will be
removed
# from teh returned list. (Ie, only the files found will be returned.) This
# can be useful when using the glob-tree rule in an install rule.
#
rule glob-tree ( roots * : patterns + : exclude-patterns * : files-only * )
{
     return [ sequence.transform path.make : [ .glob-tree [
sequence.transform
         path.native : $(roots) ] : $(patterns) : $(exclude-patterns) :
$(files-only ] ] ;
}

local rule .glob-tree ( roots * : patterns * : exclude-patterns * :
files-only * )
{
     local excluded ;
     if $(exclude-patterns)
     {
         excluded = [ GLOB $(roots) : $(exclude-patterns) ] ;
     }
     local result = [ set.difference [ GLOB $(roots) : $(patterns) ] :
$(excluded) ] ;
     local subdirs ;
     for local d in [ set.difference [ GLOB $(roots) : * ] : $(excluded) ]
     {
         if ! ( $(d:D=) in . .. ) && ! [ CHECK_IF_FILE $(d) ]
         {
             subdirs += $(d) ;

             if $(files-only
               {
               result = [ set.difference $(result) : $(d) ] ;
               }
         }
     }
     if $(subdirs)
     {
         result += [ .glob-tree $(subdirs) : $(patterns) :
$(exclude-patterns) : $(files-only ] ;
     }
     return $(result) ;
}

-- 
----------------
Mark E. Hamilton
GAITS, Inc.
Sandia National Laboratory, NM.
505-844-7666

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk