summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-03 16:01:04 -0300
committerWerner Almesberger <werner@almesberger.net>2016-09-03 19:52:24 -0300
commit13f0b12be13e584884f00c726873f83d70f2c1d9 (patch)
treed1205930c9866c898f7aa0c766fc52149b0175eb
parentef43492d8f72d192e98a1f31d6069ab250609d81 (diff)
downloadeeshow-13f0b12be13e584884f00c726873f83d70f2c1d9.tar.gz
eeshow-13f0b12be13e584884f00c726873f83d70f2c1d9.tar.bz2
eeshow-13f0b12be13e584884f00c726873f83d70f2c1d9.zip
main/eeplot.c: combine front- and backend command line processing
... and do away with the -- option
-rw-r--r--Makefile20
-rw-r--r--README30
-rw-r--r--main/eeplot.c70
-rwxr-xr-xsch2pdf8
-rwxr-xr-xtest/genpng6
-rw-r--r--web/index.html2
6 files changed, 57 insertions, 79 deletions
diff --git a/Makefile b/Makefile
index 93f1592..9af9238 100644
--- a/Makefile
+++ b/Makefile
@@ -136,24 +136,24 @@ sch:
eeschema test.sch
test: eeplot
- ./eeplot test.lib test.sch -- fig -o out.fig
+ ./eeplot -o out.fig test.lib test.sch
fig2dev -L png -m 2 out.fig _out.png
[ ! -r ref.png ] || \
compare -metric AE ref.png _out.png _diff.png || \
qiv -t -R -D _diff.png ref.png _out.png
testref: eeplot
- ./eeplot test.lib test.sch -- fig -o fig:- | \
+ ./eeplot -o fig:- test.lib test.sch | \
fig2dev -L png -m 2 >ref.png
png: eeplot
- ./eeplot test.lib test.sch -- png -o _out.png -s 2
+ ./eeplot -o _out.png -s 2 test.lib test.sch
[ ! -r pngref.png ] || \
compare -metric AE pngref.png _out.png _diff.png || \
qiv -t -R -D _diff.png pngref.png _out.png
pngref: eeplot
- ./eeplot test.lib test.sch -- png -o pngref.png -s 2
+ ./eeplot -o pngref.png -s 2 test.lib test.sch
clean::
rm -f out.fig _out.png _diff.png
@@ -166,9 +166,9 @@ KICAD_LIBS = ../../qi/kicad-libs/components
SHEET ?= 12
neo900: eeplot
- ./eeplot $(NEO900_HW)/neo900.lib \
+ ./eeplot -o out.fig $(NEO900_HW)/neo900.lib \
$(KICAD_LIBS)/powered.lib \
- $(NEO900_HW)/neo900_SS_$(SHEET).sch -- fig -o out.fig
+ $(NEO900_HW)/neo900_SS_$(SHEET).sch
neo900.pdf: eeplot sch2pdf neo900-template.fig
./sch2pdf -o $@ -t neo900-template.fig \
@@ -176,7 +176,7 @@ neo900.pdf: eeplot sch2pdf neo900-template.fig
$(NEO900_HW)/neo900.sch
pdf: eeplot
- ./eeplot $(NEO900_HW)/neo900.pro -- pdf -o neo900.pdf
+ ./eeplot -o neo900.pdf $(NEO900_HW)/neo900.pro
#----- Regression test based on Neo900 schematics -----------------------------
@@ -201,10 +201,8 @@ leak: eediff
$(SUPP:%=--suppressions=%.supp) \
./eediff $(NEO900_HW)/neo900.pro -- \
diff $(NEO900_HW)/neo900.pro >/dev/null
-# ./eeplot -N 1 $(NEO900_HW)/neo900.pro \
-# -- pdf -o pdf:- >/dev/null
-# ./eeplot -N 1 $(NEO900_HW)/neo900.pro \
-# -- png -o png:- >/dev/null
+# ./eeplot -o pdf:- -N 1 $(NEO900_HW)/neo900.pro >/dev/null
+# ./eeplot -o png:- -N 1 $(NEO900_HW)/neo900.pro >/dev/null
#----- Install / uninstall ---------------------------------------------------
diff --git a/README b/README
index 2f5fbd4..5868d80 100644
--- a/README
+++ b/README
@@ -64,28 +64,30 @@ Invocation
The general form of invocation for rendering is as follows:
-eeplotfile.pro [file.sch] -- format [options]
+eeplot -o output [options] file.pro [file.sch]
or
-eeplot [-1] [-e] file.lib ... file.sch -- format [options]
+eeplot -o output [options] [-1] [-e] file.lib ... file.sch
-Common if using PDF, the option -1 can be used (after "eeshow") to
-process only one sheet, not recursing into sub-sheets. -e enables
-the rendering of additional information, e.g., pin types.
+The option -o is always required. The filename extension selects the
+output driver, and can be overridden with the type: prefix. If selecting
+standard output the type prefix is always required, e.g., png:-
-For PDF and PNG, the options -s scale and -o output-file can be used to
-control the size of the output and the output file. By default, eeshow
-writes to standard output.
+If using PDF, the option -1 can be used (after "eeshow") to process only
+one sheet, not recursing into sub-sheets. -e enables the rendering of
+additional information, e.g., pin types.
+
+For PDF and PNG, the option -s scale can be used to control the size of
+the output.
Examples:
-eeplot test.lib test.sch -- png -s 2 -o test.png
+eeplot -s 2 -o test.png test.lib test.sch
-eeplot neo900.lib kicad-libs/components/powered.lib neo900.sch \
- -- pdf -o neo900.pdf
+eeplot -o neo900.pdf neo900.lib kicad-libs/components/powered.lib neo900.sch
-eeplot neo900.pro neo900_SS_4.sch -- pdf -o neo900-sheet04.pdf
+eeplot -o neo900-sheet04.pdf neo900.pro neo900_SS_4.sch
More details on the above example can be found in the file DEMO.
@@ -96,8 +98,8 @@ Revision access
If the files are stored in a git repository, a revisions can be selected
by prefixing file names with the commit ID, e.g.,
-eeplot neo900.lib kicad-libs/components/powered.lib 6a9f71:neo900_SS_5.sch \
- -- png -s 2 -o old.png
+eeplot -o old.png -s neo900.lib kicad-libs/components/powered.lib \
+ 6a9f71:neo900_SS_5.sch \
Revision selection propagates to dependent files, unless explicitly
overridden. E.g., the above example selects also revision 6a9f71 of
diff --git a/main/eeplot.c b/main/eeplot.c
index 3a508b0..a78f73c 100644
--- a/main/eeplot.c
+++ b/main/eeplot.c
@@ -79,7 +79,7 @@ static const struct gfx_ops *find_by_output(int argc, char **argv)
for (ops = ops_list; ops != ARRAY_END(ops_list); ops++)
for (i = 0; i != (*ops)->n_ext; i++)
- if (!strncasecmp((*ops)->ext[i], ext, n) ||
+ if (!strncasecmp((*ops)->ext[i], ext, n) &&
strlen((*ops)->ext[i]) == n)
return *ops;
fatal("graphics backend for \"%s\" not found\n", ext);
@@ -89,8 +89,8 @@ static const struct gfx_ops *find_by_output(int argc, char **argv)
void usage(const char *name)
{
fprintf(stderr,
-"usage: %s [-1] [-e] [-v ...] kicad_file ...\n"
-" %*s-- driver_spec\n"
+"usage: %s -o [type:]output_file [-1] [-e] [-v ...] [driver_opts]\n"
+" %*skicad_file ...\n"
" %s -V\n"
" %s gdb ...\n"
"\n"
@@ -100,30 +100,28 @@ void usage(const char *name)
"\n"
" -1 show only one sheet - do not recurse into sub-sheets\n"
" -e show extra information (e.g., pin types)\n"
+" -o [type:]output_file\n"
+" output file. - for standard output. File type is derived from\n"
+" extension and can be overridden with type: prefix (fig, png, pdf).\n"
" -v increase verbosity of diagnostic output\n"
-" -E shell_command ...\n"
-" execute the specified shell command when the GUI is ready.\n"
-" Sets EESHOW_WINDOW_ID to the X11 window ID.\n"
" -V print revision (version) number and exit\n"
" gdb run eeshow under gdb\n"
"\n"
-"FIG driver spec:\n"
-" fig [-o output.fig] [-t template.fig] [-D var=value ...]\n"
+"FIG files:\n"
+" [-t template.fig] [-D var=value ...]\n"
"\n"
-" -o output.fig write FIG to specified file (default; standard output)\n"
" -t template.fig merge this file with generated output\n"
" -D var=value substitute \"<var>\" with \"value\" in template\n"
"\n"
-"Cairo PNG driver spec:\n"
-" png [-o output.png] [-s scale]\n"
+"PNG files:\n"
+" [-s scale]\n"
"\n"
-" -o output.png write PNG to specified file (default; standard output)\n"
" -s scale scale by indicated factor (default: 1.0)\n"
"\n"
-"Cairo PDF driver spec:\n"
-" pdf [-o output.pdf] [-s scale] [-T]\n"
+"PDF files:\n"
+" [-s scale] [-T]\n"
"\n"
-" see PNG for -o and -s\n"
+" see PNG for -s\n"
" -T do not add table of contents\n"
, name, (int) strlen(name) + 1, "", name, name);
exit(1);
@@ -142,25 +140,20 @@ int main(int argc, char **argv)
bool one_sheet = 0;
struct pl_ctx *pl = NULL;
char c;
- int dashdash;
unsigned i;
struct file_names file_names;
struct file_names *fn = &file_names;
- int gfx_argc;
- char **gfx_argv;
+ char *opts;
const struct gfx_ops *ops;
struct gfx *gfx;
int retval;
run_under_gdb(argc, argv);
- for (dashdash = 1; dashdash != argc; dashdash++)
- if (!strcmp(argv[dashdash], "--"))
- break;
- if (dashdash == argc)
- usage(*argv);
+ ops = find_by_output(argc, argv);
- while ((c = getopt(dashdash, argv, OPTIONS)) != EOF)
+ alloc_printf(&opts, "%s%s", OPTIONS, ops->opts);
+ while ((c = getopt(argc, argv, opts)) != EOF)
switch (c) {
case '1':
one_sheet = 1;
@@ -183,33 +176,20 @@ int main(int argc, char **argv)
case 'V':
fprintf(stderr, "%s %sZ\n", version, build_date);
return 1;
- default:
+ case '?':
usage(*argv);
+ default:
+ break;
}
+ free(opts);
- if (dashdash - optind < 1)
+ if (argc - optind < 1)
usage(*argv);
- classify_files(&file_names, argv + optind, dashdash - optind);
+ classify_files(&file_names, argv + optind, argc - optind);
if (!file_names.pro && !file_names.sch)
fatal("project or top sheet name required");
- ops = find_by_output(argc, argv);
-
- if (dashdash == argc) {
- gfx_argc = 1;
- gfx_argv = alloc_type_n(char *, 2);
- gfx_argv[0] = (char *) ops->ext[0];
- gfx_argv[1] = NULL;
- } else {
- gfx_argc = argc - dashdash - 1;
- if (!gfx_argc)
- usage(*argv);
- gfx_argv = alloc_type_n(char *, gfx_argc + 1);
- memcpy(gfx_argv, argv + dashdash + 1,
- sizeof(const char *) * (gfx_argc + 1));
- }
-
if (file_names.pro) {
if (!file_open(&pro_file, file_names.pro, NULL))
return 1;
@@ -217,13 +197,11 @@ int main(int argc, char **argv)
}
gfx = gfx_init(ops);
- if (!gfx_args(gfx, gfx_argc, gfx_argv, OPTIONS))
+ if (!gfx_args(gfx, argc, argv, OPTIONS))
return 1;
if (!gfx_multi_sheet(gfx))
one_sheet = 1;
- free(gfx_argv);
-
sch_init(&sch_ctx, !one_sheet);
if (!file_open(&sch_file, fn->sch, file_names.pro ? &pro_file : NULL))
return 1;
diff --git a/sch2pdf b/sch2pdf
index 6233971..ec9be52 100755
--- a/sch2pdf
+++ b/sch2pdf
@@ -56,8 +56,8 @@ while [ "$2" ]; do
shift
done
-./eeplot $libs "$1" \
- -- fig -o fig:- $template "TITLE=`basename \"$1\" .sch`" NUMBER=$num |
+./eeplot -o fig:- $template -D"TITLE=`basename \"$1\" .sch`" -DNUMBER=$num \
+ $libs "$1" |
fig2dev -L pdf >"$out"
sheet=false
@@ -83,8 +83,8 @@ while read line; do
num=`expr $num + 1`
$quiet || echo "$file" 1>&2
- ./eeplot $libs `dirname "$1"`/$file \
- -- fig -o fig:- $template "TITLE=$name" NUMBER=$num |
+ ./eeplot -o fig:- $template -D"TITLE=$name" -DNUMBER=$num \
+ $libs `dirname "$1"`/$file | \
fig2dev -L pdf >_tmp.pdf
pdfunite "$out" _tmp.pdf _tmp2.pdf
mv _tmp2.pdf "$out"
diff --git a/test/genpng b/test/genpng
index 2ffbe33..0119964 100755
--- a/test/genpng
+++ b/test/genpng
@@ -28,9 +28,9 @@ while [ $sheet -le 38 ]; do
in=$dir/neo900-ee/hw/neo900_SS_`expr $sheet - 1`.sch
fi
file=$dir/$prefix$sn.png
- $dir/../eeplot $dir/neo900-ee/hw/neo900.lib \
- $dir/kicad-libs/components/powered.lib "$in" \
- -- fig -o fig:- -t $dir/frame.fig SHEET=$sn |
+ $dir/../eeplot -o fig:- -t $dir/frame.fig -DSHEET=$sn \
+ $dir/neo900-ee/hw/neo900.lib \
+ $dir/kicad-libs/components/powered.lib "$in" | \
fig2dev -L png -m 2 >$file
sheet=`expr $sheet + 1`
done
diff --git a/web/index.html b/web/index.html
index 8b7fd28..4dde98e 100644
--- a/web/index.html
+++ b/web/index.html
@@ -203,7 +203,7 @@ The most common use may be to render the schematics as PDF, with the
command <code>eeplot</code>. Example:
<P>
<PRE>
-eeplot neo900.pro -- pdf -o neo900.pdf
+eeplot -o neo900.pdf neo900.pro
</PRE>
<P>
The command <code>eediff</code> makes a pixel-wised comparison of two