1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-17 21:03:43 +02:00

genex: generate PDF by default; new option -P to generate Postscript

This commit is contained in:
Werner Almesberger 2012-04-17 08:17:34 -03:00
parent 8e8a3c56c6
commit f8e10b31a7
3 changed files with 19 additions and 14 deletions

View File

@ -13,6 +13,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#include "comp.h" #include "comp.h"
#include "libs.h" #include "libs.h"
@ -22,11 +23,13 @@
static void usage(const char *name) static void usage(const char *name)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [-d] [-L libdir ...] [-l lib ...] hierarchy [descriptions ...]\n\n" "usage: %s [-d] [-P] [-L libdir ...] [-l lib ...] hierarchy\n"
" %*s [descriptions ...]\n\n"
" -d dump the tree instead of generating a PDF\n" " -d dump the tree instead of generating a PDF\n"
" -L libdir search all libraries in the specified directory\n" " -L libdir search all libraries in the specified directory\n"
" -l lib search the specified component library\n" " -l lib search the specified component library\n"
, name); " -P generate Postscript instead of PDF (mainly for debugging)\n"
, name, (int) strlen(name), "");
exit(1); exit(1);
} }
@ -35,10 +38,10 @@ int main(int argc, char **argv)
{ {
FILE *file; FILE *file;
int c; int c;
int dump = 0; int dump = 0, postscript = 0;
char **arg; char **arg;
while ((c = getopt(argc, argv, "dL:l:")) != EOF) while ((c = getopt(argc, argv, "dL:l:P")) != EOF)
switch (c) { switch (c) {
case 'd': case 'd':
dump = 1; dump = 1;
@ -49,6 +52,9 @@ int main(int argc, char **argv)
case 'l': case 'l':
add_lib(optarg); add_lib(optarg);
break; break;
case 'P':
postscript = 1;
break;
default: default:
usage(*argv); usage(*argv);
} }
@ -82,6 +88,6 @@ int main(int argc, char **argv)
if (dump) if (dump)
dump_tree(); dump_tree();
else else
make_pdf(); make_pdf(!postscript);
return 0; return 0;
} }

View File

@ -211,7 +211,7 @@ static void convert_tree(const struct node *node, FILE *out)
} }
void make_pdf(void) void make_pdf(int pdf)
{ {
FILE *out; FILE *out;
int res; int res;
@ -220,13 +220,12 @@ void make_pdf(void)
format = landscape; format = landscape;
else else
format = portrait; format = portrait;
#if 0 if (pdf)
out = popen( out = popen(
"gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=- -f -", "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=- "
"w"); "-f -", "w");
#else else
out = popen("cat", "w"); out = popen("cat", "w");
#endif
if (!out) { if (!out) {
perror("gs"); perror("gs");
exit(1); exit(1);

View File

@ -12,6 +12,6 @@
#ifndef PDF_H #ifndef PDF_H
#define PDF_H #define PDF_H
void make_pdf(void); void make_pdf(int pdf);
#endif /* !PDF_H */ #endif /* !PDF_H */