The real fun of the day however, is this baby:
# # A magic function that generates file tasks that copy all headers from # directory ind # to directory outd. Any missing directories are created as # needed. # # The return value is a list suitable for the right hand side of a task, e.g. # # task :headers => header_magic(src, dest) # def header_magic(ind, outd) dirs = [] hdrs = [] find_files(ind, /.*\.h[hxp]*$/) do |p| outdir = File.dirname p.sub(ind, outd) outfile = File.join(outd, File.basename(p)) directory outdir file outfile => p do cp_r p, outdir end dirs.push outdir hdrs.push outfile CLEAN.include outfile, outdir end dirs+hdrs end
find_files is another custom function, it simply takes a block and yields and file names matching the specified pattern. (In this case, more liberal than the usual header extensions but sufficient for my needs)
I call it header_magic, because it after all the other stuff I played with, it's the closest to Clarke's third law. Which is exactly what I want!
footnote: I just have my top level clean task nuke the entire build tree; so the CLEAN part hasn't been tested.
No comments:
Post a Comment