Skip to content

Make Rocks (too)

March 18, 2007

William writes:

Nothing made this more clear than working with Rake, Make, and Ant—all in the same day. Make is ridiculous, Ant is reasonable, and Rake rocks.

He has a nice example of how to do flash-y things without flash and how to use rake to do cool things. However, I think it doesn’t justify his “Make is ridiculous” statement at all. Here’s a solution to his problem using make and bash (might be proper sh, who knows):

Makefile

IMAGES:=$(wildcard resources/images/*.jpg) $(wildcard resources/images/*.png)resources/images.xml: $(IMAGES)

 bash resources/images.xml.sh $(IMAGES) > resources/images.xml

images.xml.settings.sh

SWF_VERSION=7

SWF_WIDTH=450

SWF_HEIGHT=550

SWF_BACKGROUND="#ffffff"

SWF_FRAMERATE=24

images.xml.sh

# load settings

. images.xml.settings.sh# header

cat << END

<?xml version="1.0" encoding="iso-8859-1"?>

<movie version="$SWF_VERSION"

       width="$SWF_WIDTH"

       height="$SFW_HEIGHT"

       framerate="$SWF_FRAMERATE">

  <background color="$SWF_BACKGROUND"/>

  <frame>

    <library>

END

# line for each clip

for fname in $*; do

  name=`basename "$fname" | sed -r 's/\.(png|jpg)$//'`

  echo "      <clip id=\"$name\" import=\"$fname\"/>"

done

# footer

cat << END

    </library>

  </frame>

</movie>

END

I haven’t tested it elsewhere but on my laptop, but I’m reasonably confident this setup will work by default on just about all linux/unix/mac os x machines out there, including ones from 10 years ago. It also doesn’t require one to learn a new language (ruby) or a new domain-specific language (rake) if you’re an “old fart”, integrates easily with most existing build systems one can imagine, and has about the same number of lines of code.

Advertisements

Comments are closed.

%d bloggers like this: