mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-26 14:45:20 +02:00
a241265aaf
- scripts/gitsch2ppm: new option -k to keep checked-out tree - scripts/gitsch2ppm: new option -c to reuse Postscript files from -k run - scripts/gitsch2ppm: removed C-style use of "break" from "case" - scripts/schhist2web: use gitsch2ppm -k and -c to half number of eeschema runs
117 lines
2.2 KiB
Bash
Executable File
117 lines
2.2 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.
|
|
#
|
|
|
|
|
|
RES=1280x850
|
|
LINEWIDTH=120
|
|
|
|
|
|
ps2ppm()
|
|
{
|
|
X=`echo $RES | sed 's/x.*//'`
|
|
Y=`echo $RES | sed 's/.*x//'`
|
|
IRES=${Y}x$X
|
|
res=`expr 72 \* $X / 800`
|
|
|
|
( cat <<EOF
|
|
%!PS-Adobe-3.0
|
|
/setlinewidth { $LINEWIDTH 2 copy lt { exch } if pop setlinewidth } bind def
|
|
EOF
|
|
sed 1d <"$1"; ) |
|
|
gs -sDEVICE=ppmraw -sOutputFile=- -g$IRES -r$res \
|
|
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q - |
|
|
pnmflip -r270 |
|
|
cat >`dirname "$1"`/`basename "$1" .ps`.ppm
|
|
}
|
|
|
|
|
|
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)
|
|
-w points Postscript line width (default: $LINEWIDTH)
|
|
EOF
|
|
exit 1
|
|
}
|
|
|
|
|
|
cache=false
|
|
keep=false
|
|
while true; do
|
|
case "$1" in
|
|
-c) cache=true
|
|
shift;;
|
|
-k) keep=true
|
|
shift;;
|
|
-r) [ -z "$2" ] && usage
|
|
RES="$2"
|
|
shift 2;;
|
|
-w) [ -z "$2" ] && usage
|
|
LINEWIDTH="$2"
|
|
shift 2;;
|
|
-*)
|
|
usage;;
|
|
*)
|
|
break;;
|
|
esac
|
|
done
|
|
|
|
[ ! -z "$3" -a -z "$5" ] || usage
|
|
dir="$1"
|
|
schem="$2"
|
|
sdir=`dirname "$schem"`
|
|
if [ -z "$4" ]; then
|
|
commit=HEAD
|
|
outdir="$3"
|
|
else
|
|
commit="$3"
|
|
outdir="$4"
|
|
fi
|
|
|
|
[ "$dir" != "${dir#/}" ] || dir=`pwd`/$dir
|
|
|
|
[ "$commit" != HEAD -o -f "$dir/$schem" ] || usage
|
|
[ -d "$dir/.git" ] || usage
|
|
|
|
tmp="$dir/../_gitsch2ppm"
|
|
sch="$tmp/$sdir"
|
|
|
|
if ! $cache; then
|
|
rm -rf "$tmp"
|
|
rm -rf "$outdir"
|
|
|
|
git clone -s -n "$dir/.git" "$tmp" || exit
|
|
( cd "$tmp" && git checkout -q "$commit"; ) || exit
|
|
|
|
if [ ! -f "$tmp/$schem" ]; then
|
|
echo "$schem not found (checked out into $tmp)" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
( cd "$sch" && rm -f *.ps *.ppm && eeschema --plot "$tmp/$schem"; ) || exit
|
|
fi
|
|
|
|
for n in "$sch"/*.ps; do
|
|
ps2ppm "$n"
|
|
done
|
|
|
|
mkdir -p "$outdir"
|
|
|
|
mv "$sch"/*.ppm "$outdir"
|
|
|
|
$keep || rm -rf "$tmp"
|