1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-07-17 05:48:29 +03:00
ben-wpan/scripts/gitsch2ppm
Werner Almesberger b3f2014863 Split gitsch2ppm into its constituents.
- scripts/gitsch2ps: generate PS files for KiCad schematics in git
- scripts/normalizeschps: normalize eeschema Postscript
- scripts/schps2ppm: generate PPM files from normalized Eeschema Postscript
- scripts/gitsch2ppm: wrapper and cache manager for the above scripts
2010-08-30 01:53:59 -03:00

83 lines
1.6 KiB
Bash
Executable File

#!/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
-c use cached Postscript files (from previous run, with -k)
-k keep checked-out tree (for immediate reuse with -c)
-r XxY image resolution (default: $RES)
-S sanitize the KiCad profile
-w points Postscript line width (default: $LINEWIDTH)
EOF
exit 1
}
cache=false
keep=false
res=
sanitize=
width=
while true; do
case "$1" in
-c) cache=true
shift;;
-k) keep=true
shift;;
-r) [ -z "$2" ] && usage
res="-r $2"
shift 2;;
-S) sanitize=-S
shift;;
-w) [ -z "$2" ] && usage
width="-r $2"
shift 2;;
-*)
usage;;
*)
break;;
esac
done
tmp=`pwd`/_gitsch2ppm
eval outdir=\${$#}
# 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
if ! $cache; then
rm -rf "$tmp"
rm -rf "$outdir"
gitsch2ps $sanitize "$@" "$tmp"
for n in "$tmp"/*.ps; do
normalizeschps $width "$n"
done
fi
mkdir -p "$outdir"
for n in "$tmp"/*.ps; do
schps2ppm $res "$n" "$outdir/`basename \"${n%.ps}.ppm\"`"
done
$keep || rm -rf "$tmp"