Root/
| 1 | #!/bin/bash |
| 2 | # |
| 3 | # sch2pdf - Generate PDF from schematics, using eeshow |
| 4 | # |
| 5 | # Written 2016 by Werner Almesberger |
| 6 | # Copyright 2016 by Werner Almesberger |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | |
| 14 | # |
| 15 | # Known bugs: |
| 16 | # - expects first sheet to be index page |
| 17 | # - only renders sub-sheets |
| 18 | # - has all the limitations of eeshow (see TODO) |
| 19 | # |
| 20 | |
| 21 | |
| 22 | usage() |
| 23 | { |
| 24 | cat <<EOF 1>&2 |
| 25 | usage: $0 [-n first_num] [-o output.pdf] [-q] [-t template.fig ] |
| 26 | file.lib ... file.sch |
| 27 | EOF |
| 28 | exit 1 |
| 29 | } |
| 30 | |
| 31 | |
| 32 | out=out.pdf |
| 33 | quiet=false |
| 34 | template= |
| 35 | num=1 |
| 36 | while [ "$1" ]; do |
| 37 | case "$1" in |
| 38 | -n) num=$2 |
| 39 | shift 2;; |
| 40 | -o) out=$2 |
| 41 | shift 2;; |
| 42 | -q) quiet=true |
| 43 | shift;; |
| 44 | -t) template="-t $2" |
| 45 | shift 2;; |
| 46 | -*) usage;; |
| 47 | *) break;; |
| 48 | esac |
| 49 | done |
| 50 | |
| 51 | [ "$1" ] || usage |
| 52 | |
| 53 | libs= |
| 54 | while [ "$2" ]; do |
| 55 | libs="$libs $1" |
| 56 | shift |
| 57 | done |
| 58 | |
| 59 | ./eeshow $libs "$1" \ |
| 60 | -- fig $template "TITLE=`basename \"$1\" .sch`" NUMBER=$num | |
| 61 | fig2dev -L pdf >"$out" |
| 62 | |
| 63 | sheet=false |
| 64 | while read line; do |
| 65 | if ! $sheet; then |
| 66 | [ "${line#\$Sheet}" != "$line" ] && sheet=true |
| 67 | continue |
| 68 | else |
| 69 | if [ "${line#\$EndSheet}" != "$line" ]; then |
| 70 | sheet=false |
| 71 | continue |
| 72 | fi |
| 73 | fi |
| 74 | |
| 75 | if [ "${line#F0 \"}" != "$line" ]; then |
| 76 | name=${line#F0 \"} |
| 77 | name=${name%%\"*} |
| 78 | fi |
| 79 | [ "${line#F1 \"}" = "$line" ] && continue |
| 80 | file=${line#F1 \"} |
| 81 | file=${file%%\"*} |
| 82 | |
| 83 | num=`expr $num + 1` |
| 84 | |
| 85 | $quiet || echo "$file" 1>&2 |
| 86 | ./eeshow $libs `dirname "$1"`/$file \ |
| 87 | -- fig $template "TITLE=$name" NUMBER=$num | |
| 88 | fig2dev -L pdf >_tmp.pdf |
| 89 | pdfunite "$out" _tmp.pdf _tmp2.pdf |
| 90 | mv _tmp2.pdf "$out" |
| 91 | done <"$1" |
| 92 | exit |
| 93 |
Branches:
master
