mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-20 02:14:04 +02:00
Merged the functionality of gitsch2ppm into schhist2web.
- scripts/normalizeschps: don't edit in place and thus become capable of running in a pipe - scripts/schps2ppm: considered - to be an option and thus didn't accept it as input file name - scripts/schhist2web: open-coded functionality of "gitsch2ppm" - scripts/gitsch2ppm: removed
This commit is contained in:
parent
b3f2014863
commit
800577353e
@ -1,82 +0,0 @@
|
||||
#!/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"
|
@ -18,7 +18,7 @@ LINEWIDTH=120
|
||||
usage()
|
||||
{
|
||||
cat <<EOF 1>&2
|
||||
usage: $0 [options] file ...
|
||||
usage: $0 [options] [in.ps [out.ps]]
|
||||
|
||||
-w points Postscript line width (default: $LINEWIDTH)
|
||||
EOF
|
||||
@ -38,8 +38,11 @@ while true; do
|
||||
esac
|
||||
done
|
||||
|
||||
for n in "$@"; do
|
||||
sed -i '
|
||||
[ -z "$3" ] || usage
|
||||
in=${1:--}
|
||||
out=${2:-/dev/stdout}
|
||||
|
||||
sed '
|
||||
1c%!PS-Adobe-3.0\
|
||||
currentdict /DidNormalize known not { \
|
||||
/setlinewidth { '$LINEWIDTH' 2 copy lt { exch } if pop \
|
||||
@ -53,7 +56,6 @@ for n in "$@"; do
|
||||
}
|
||||
/%%DocumentMedia: A2.*/{s/A2/A4/;a-18 -12 translate 0.49 dup scale
|
||||
}
|
||||
$agrestore' "$n"
|
||||
done
|
||||
$agrestore' "$in" >"$out"
|
||||
|
||||
# /%%Orientation: Landscape/d' "$n"
|
||||
|
@ -190,18 +190,25 @@ for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do
|
||||
echo Name change $schname to $new 1>&2
|
||||
schname="$new"
|
||||
fi
|
||||
trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\"" 0
|
||||
tmp=`pwd`/_schhist2web
|
||||
trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\" \"$tmp\"" 0
|
||||
if [ ! -d "$cache/ppm_$n" ]; then
|
||||
rm -rf "$cache/ppm_$n"
|
||||
mkdir "$cache/ppm_$n"
|
||||
rm -rf "$cache/ppm_$n" "$cache/fat_$n"
|
||||
mkdir "$cache/ppm_$n" "$cache/fat_$n"
|
||||
#
|
||||
# potential optimization here: remember Postscript files from previous
|
||||
# run (or their md5sum) and check if they have changed. If not, skip
|
||||
# the ghostscript run and just put a symlink, replacing the less
|
||||
# efficient optimization below.
|
||||
#
|
||||
gitsch2ppm $sanitize -k "$dir" "$schname" $n "$cache/ppm_$n" || exit
|
||||
gitsch2ppm -c -w 500 "$dir" "$schname" $n "$cache/fat_$n" || exit
|
||||
gitsch2ps $sanitize "$dir" "$schname" $n "$tmp" || exit
|
||||
for m in "$tmp"/*.ps; do
|
||||
ppm="$cache/ppm_$n/`basename "$m" .ps`.ppm"
|
||||
normalizeschps "$m" | schps2ppm - "$ppm" || exit
|
||||
ppm="$cache/fat_$n/`basename "$m" .ps`.ppm"
|
||||
normalizeschps -w 500 "$m" | schps2ppm - "$ppm" || exit
|
||||
done
|
||||
rm -rf "$tmp"
|
||||
fi
|
||||
for m in "$cache/ppm_$n/"*; do
|
||||
[ "$m" = "$cache/ppm_$n/*" ] && break
|
||||
|
@ -31,10 +31,9 @@ while true; do
|
||||
-r) [ -z "$2" ] && usage
|
||||
RES="$2"
|
||||
shift 2;;
|
||||
-*)
|
||||
usage;;
|
||||
*)
|
||||
break;;
|
||||
-) break;;
|
||||
-*) usage;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user