I am trying to create an automated process with Waf to optimize, minify, etc. the source files of a website based on the HTML5 boilerplate's ANT build script. Part of this includes running all the PNG's in the img directory through two utilities, optipng
and advpng
.
This is my current best attempt at these tasks:
def build(ctx):
ctx(
rule = '${OPTIPNG} -quiet -o5 -i 1 -out ${TGT} ${SRC}',
source = 'img1.png',
target = 'img1-opt.png'
)
ctx(
rule = '${ADVPNG} -z -1 ${SRC}',
source = SOMETHING,
target = SOMETHING ELSE
)
I first run optipng on img1, where my first problem arises. I would like the output file to have the same name as the input file. However, setting target
to the same name results in Waf detecting a deadlock. So, I moved ahead by appending a suffix.
advpng
is a bit strange in that it doesn't create a new output file: it modifies the input file in place. So, I now need a way to access the output of optipng
, which now resides in the build's output directory.
What is the proper way of accomplishing this task?