hid/*: layer_sort() Only copper layers participate in the layer stack
[geda-pcb/pcjc2.git] / tools / pcbdiff
blobc84da34c8bea1057bf0e8b6343791720393ebf91
1 #! /bin/sh
3 usage ()
5 echo Usage:
6 echo \\tpcbdiff firstfile secondfile
7 echo \\tView a graphical diff of PCB files
8 echo
9 echo \\tTo use with git, just place this script in your PATH and do
10 echo \\tgit difftool -x pcbdiff ...
11 echo
12 echo \\tTo use with mercurial, add the following lines to your .hgrc:
13 echo \\t\\t[extensions]
14 echo \\t\\thgext.extdiff =
15 echo \\t\\t[extdiff]
16 echo \\t\\tcmd.pcbdiff = /PATH/TO/pcbdiff
17 echo \\tthen to invoke it, do
18 echo \\thg pcbdiff ...
19 echo
20 echo \\tTo use with subversion, place it in your PATH and do
21 echo \\tsvn diff --diff-cmd pcbdiff ...
23 echo \\tRequirements: Imagemagick and gschem be installed
26 PCB=`which pcb`
27 if test -z "${PCB}"; then
28 MISSING=pcb
31 CONVERT=`which convert`
32 if test -z "${CONVERT}"; then
33 MISSING=convert
36 COMPOSITE=`which composite`
37 if test -z "${COMPOSITE}"; then
38 MISSING=composite
41 VIEWER=`which display`
42 if test -z "${VIEWER}"; then
43 MISSING=display
46 if test -z "${MISSING}"; then
47 true
48 else
49 echo "Binary for \"${MISSING}\" not found." >&2
50 echo "Either it is not installed, or not in your PATH" >&2
51 exit 1
54 #In case the script was invoked with extra option arguments, throw them away
55 shift `expr $# - 2`
57 LEFTFILE="${1}"
58 RIGHTFILE="${2}"
59 if test -d "${LEFTFILE}" -o -d "${RIGHTFILE}"
60 then echo "ERROR: pcbdiff cannot diff entire directories"
61 exit 1
64 LEFTPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
65 RIGHTPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
66 LEFTBNW=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
67 RIGHTBNW=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
68 DIFFPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
70 "${PCB}" -x png --dpi ${PCBDIFF_DPI:-200} --photo-mode --outfile ${LEFTPNG} "${LEFTFILE}"
71 "${PCB}" -x png --dpi ${PCBDIFF_DPI:-200} --photo-mode --outfile ${RIGHTPNG} "${RIGHTFILE}"
72 "${CONVERT}" -colorspace gray $LEFTPNG $LEFTBNW
73 "${CONVERT}" -colorspace gray $RIGHTPNG $RIGHTBNW
74 "${COMPOSITE}" -stereo 0 $LEFTBNW $RIGHTBNW $DIFFPNG
75 "${VIEWER}" $DIFFPNG
76 rm $LEFTPNG
77 rm $RIGHTPNG
78 rm $LEFTBNW
79 rm $RIGHTBNW
80 rm $DIFFPNG