From: david x callaway (dxc_at_[hidden])
Date: 2006-12-23 11:02:33
common.Clean doesn't appear to be conditioned on --clean:
actions piecemeal together existing Clean
I got a variation of the code I sent earlier to almost work. with this
I can say
rm-on-clean *~ relative/path/blah.txt name.txt ; # etc
and it seems to work, including files and directories with whitespace in
them. if you insist, you can give a file like "x\\y.txt" on linux, and
it seems to correctly get flipped, so I assume the opposite would happen
with unix-style paths on windows. I don't have a windows box though, so
I'm not sure about that.
the major problem I had was getting it to work in subdirectory Jamfiles.
does the code look right? it seems to work, but it seems awfully
complicated to do something simple. the idea is to flip the '/' or '\\'
first, then build the full path to the (possible) pattern, then glob,
then delete the files.
it won't delete things over in the install directories because these are
not generated files, but I don't care about that since I will typically
just wipe them from the top.
---- rule rm-on-clean ( files * )
local argv = [ modules.peek : ARGV ] ;
if "clean" in $(argv) || "--clean" in $(argv)
local cmd ;
if [ os.on-windows ]
cmd = "del /f /q" ;
cmd = "rm -f" ;
local native_names ;
# flip the leaning toothpicks before expansion
for local name in $(files)
local normalized = [ path.make $(name) ] ;
native_names += [ path.native $(normalized) ] ;
local caller = [ utility.caller-file ] ;
local dirname = [ path.parent $(caller) ] ;
for local name in $(native_names)
local del_list = [ path.glob $(dirname) : $(name) ] ;
for local file in $(del_list)
if [ path.exists $(file) ]
ECHO "$(cmd) $(file)" ;
SHELL "$(cmd) \"$(file)\"" ;
---- snip ----
Rene Rivera wrote:
> david x callaway wrote:
>> anyway, my first question would be does the rule already exist in m11,
>> or do I need to add the code below or something similar to make it
>> work? it would be nice if I could just do
>> rm-on-clean : *~ *.whatever file1.txt etc.txt ;
> AFAICT you can, since M<9, do:
> import common ;
> common.Clean : /some-native-paths/ ;
> Unfortunately you'd have to deal with generating those native paths to
> feed to that "Clean" action as I don't see a clean rule that does the
> usual platform independent path handling.
> Volodya, is there something I'm missing?
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