2010-08-27 09:54:26 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# gitsch2ppm - Generate PPM files for KiCad schematics in git
|
|
|
|
#
|
|
|
|
# Written 2010 by Werner Almesberger
|
|
|
|
# Copyright 2010 Werner Almesberger
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF 1>&2
|
|
|
|
usage: $0 [options] top-dir top-schem [commit] outdir
|
|
|
|
|
2010-08-27 20:31:05 +03:00
|
|
|
-c use cached Postscript files (from previous run, with -k)
|
|
|
|
-k keep checked-out tree (for immediate reuse with -c)
|
2010-08-27 09:54:26 +03:00
|
|
|
-r XxY image resolution (default: $RES)
|
2010-08-28 02:42:40 +03:00
|
|
|
-S sanitize the KiCad profile
|
2010-08-27 09:54:26 +03:00
|
|
|
-w points Postscript line width (default: $LINEWIDTH)
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-27 20:31:05 +03:00
|
|
|
cache=false
|
|
|
|
keep=false
|
2010-08-30 07:53:59 +03:00
|
|
|
res=
|
|
|
|
sanitize=
|
|
|
|
width=
|
2010-08-27 09:54:26 +03:00
|
|
|
while true; do
|
|
|
|
case "$1" in
|
2010-08-27 20:31:05 +03:00
|
|
|
-c) cache=true
|
|
|
|
shift;;
|
|
|
|
-k) keep=true
|
|
|
|
shift;;
|
2010-08-27 09:54:26 +03:00
|
|
|
-r) [ -z "$2" ] && usage
|
2010-08-30 07:53:59 +03:00
|
|
|
res="-r $2"
|
2010-08-27 20:31:05 +03:00
|
|
|
shift 2;;
|
2010-08-30 07:53:59 +03:00
|
|
|
-S) sanitize=-S
|
2010-08-28 02:42:40 +03:00
|
|
|
shift;;
|
2010-08-27 09:54:26 +03:00
|
|
|
-w) [ -z "$2" ] && usage
|
2010-08-30 07:53:59 +03:00
|
|
|
width="-r $2"
|
2010-08-27 20:31:05 +03:00
|
|
|
shift 2;;
|
2010-08-27 09:54:26 +03:00
|
|
|
-*)
|
|
|
|
usage;;
|
|
|
|
*)
|
|
|
|
break;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2010-08-30 07:53:59 +03:00
|
|
|
tmp=`pwd`/_gitsch2ppm
|
|
|
|
eval outdir=\${$#}
|
2010-08-27 09:54:26 +03:00
|
|
|
|
2010-08-30 07:53:59 +03:00
|
|
|
# with thanks to http://www.faqs.org/faqs/unix-faq/faq/part2/section-12.html
|
|
|
|
argv=
|
|
|
|
while [ $# -gt 1 ]; do
|
|
|
|
argv="$argv \"$1\""
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
eval set x "$argv"
|
|
|
|
shift
|
2010-08-27 09:54:26 +03:00
|
|
|
|
2010-08-27 20:31:05 +03:00
|
|
|
if ! $cache; then
|
|
|
|
rm -rf "$tmp"
|
|
|
|
rm -rf "$outdir"
|
2010-08-30 07:53:59 +03:00
|
|
|
gitsch2ps $sanitize "$@" "$tmp"
|
|
|
|
for n in "$tmp"/*.ps; do
|
|
|
|
normalizeschps $width "$n"
|
|
|
|
done
|
2010-08-27 20:31:05 +03:00
|
|
|
fi
|
2010-08-27 09:54:26 +03:00
|
|
|
|
|
|
|
mkdir -p "$outdir"
|
2010-08-30 07:53:59 +03:00
|
|
|
for n in "$tmp"/*.ps; do
|
|
|
|
schps2ppm $res "$n" "$outdir/`basename \"${n%.ps}.ppm\"`"
|
|
|
|
done
|
2010-08-27 09:54:26 +03:00
|
|
|
|
2010-08-27 20:31:05 +03:00
|
|
|
$keep || rm -rf "$tmp"
|