1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-19 08:14:05 +02:00

eeshow/: make libraries "related" to the [main] schematics sheet

That way, we can use relative paths on the command line, ideally just
./eeshow foo.lib bar.lib com/plex/path/foo.sch
This commit is contained in:
Werner Almesberger 2016-08-02 16:38:21 -03:00
parent 24522c45e0
commit 49a6ebd797
7 changed files with 24 additions and 16 deletions

View File

@ -78,7 +78,7 @@ neo900.pdf: $(NAME) sch2pdf neo900-template.fig
$(NEO900_HW)/neo900.sch $(NEO900_HW)/neo900.sch
pdf: $(NAME) pdf: $(NAME)
./eeshow -r $(NEO900_HW)/neo900.lib $(KICAD_LIBS)/powered.lib \ ./eeshow -r neo900.lib kicad-libs/components/powered.lib \
$(NEO900_HW)/neo900.sch -- pdf -o neo900.pdf $(NEO900_HW)/neo900.sch -- pdf -o neo900.pdf
#----- Regression test based on Neo900 schematics ----------------------------- #----- Regression test based on Neo900 schematics -----------------------------

View File

@ -20,6 +20,7 @@
#include "util.h" #include "util.h"
#include "main.h" #include "main.h"
#include "cro.h" #include "cro.h"
#include "file.h"
#include "sch.h" #include "sch.h"
#include "lib.h" #include "lib.h"
#include "diff.h" #include "diff.h"
@ -111,6 +112,7 @@ static void *diff_init(int argc, char *const *argv)
char c; char c;
int arg; int arg;
struct sch_ctx new_sch; struct sch_ctx new_sch;
struct file sch_file;
struct lib new_lib; struct lib new_lib;
diff = alloc_type(struct diff); diff = alloc_type(struct diff);
@ -136,9 +138,11 @@ static void *diff_init(int argc, char *const *argv)
if (argc - optind < 1) if (argc - optind < 1)
usage(*argv); usage(*argv);
file_open(&sch_file, argv[argc - 1], NULL);
for (arg = optind; arg != argc - 1; arg++) for (arg = optind; arg != argc - 1; arg++)
lib_parse(&new_lib, argv[arg]); lib_parse(&new_lib, argv[arg], &sch_file);
sch_parse(&new_sch, argv[argc - 1], &new_lib); sch_parse(&new_sch, &sch_file, &new_lib);
file_close(&sch_file);
optind = 0; optind = 0;
gfx_init(&cro_img_ops, argc, argv); gfx_init(&cro_img_ops, argc, argv);

View File

@ -252,12 +252,12 @@ static bool lib_parse_line(const struct file *file,
} }
void lib_parse(struct lib *lib, const char *name) void lib_parse(struct lib *lib, const char *name, const struct file *related)
{ {
struct file file; struct file file;
lib->state = lib_skip; lib->state = lib_skip;
file_open(&file, name, NULL); file_open(&file, name, related);
file_read(&file, lib_parse_line, lib); file_read(&file, lib_parse_line, lib);
file_close(&file); file_close(&file);
} }

View File

@ -16,6 +16,8 @@
#include <stdbool.h> #include <stdbool.h>
#include "file.h"
enum lib_state { enum lib_state {
lib_skip, /* before a definition */ lib_skip, /* before a definition */
@ -117,7 +119,7 @@ const struct comp *lib_find(const struct lib *lib, const char *name);
bool lib_field_visible(const struct comp *comp, int n); bool lib_field_visible(const struct comp *comp, int n);
void lib_render(const struct comp *comp, unsigned unit, const int m[6]); void lib_render(const struct comp *comp, unsigned unit, const int m[6]);
void lib_parse(struct lib *lib, const char *name); void lib_parse(struct lib *lib, const char *name, const struct file *related);
void lib_init(struct lib *lib); void lib_init(struct lib *lib);
#endif /* !LIB_H */ #endif /* !LIB_H */

View File

@ -81,6 +81,7 @@ int main(int argc, char *const *argv)
{ {
struct lib lib; struct lib lib;
struct sch_ctx sch_ctx; struct sch_ctx sch_ctx;
struct file sch_file;
bool recurse = 0; bool recurse = 0;
const char *cat = NULL; const char *cat = NULL;
char c; char c;
@ -122,9 +123,12 @@ int main(int argc, char *const *argv)
if (dashdash - optind < 1) if (dashdash - optind < 1)
usage(*argv); usage(*argv);
sch_init(&sch_ctx, recurse);
file_open(&sch_file, argv[dashdash - 1], NULL);
lib_init(&lib); lib_init(&lib);
for (arg = optind; arg != dashdash - 1; arg++) for (arg = optind; arg != dashdash - 1; arg++)
lib_parse(&lib, argv[arg]); lib_parse(&lib, argv[arg], &sch_file);
if (dashdash == argc) { if (dashdash == argc) {
gfx_argc = 1; gfx_argc = 1;
@ -151,8 +155,9 @@ found:
optind = 0; /* reset getopt */ optind = 0; /* reset getopt */
sch_init(&sch_ctx, recurse); sch_parse(&sch_ctx, &sch_file, &lib);
sch_parse(&sch_ctx, argv[dashdash - 1], &lib); file_close(&sch_file);
gfx_init(*ops, gfx_argc, gfx_argv); gfx_init(*ops, gfx_argc, gfx_argv);
if (recurse) { if (recurse) {
const struct sheet *sheet; const struct sheet *sheet;

View File

@ -516,14 +516,10 @@ static bool parse_line(const struct file *file, void *user, const char *line)
} }
void sch_parse(struct sch_ctx *ctx, const char *name, const struct lib *lib) void sch_parse(struct sch_ctx *ctx, struct file *file, const struct lib *lib)
{ {
struct file file;
ctx->lib = lib; ctx->lib = lib;
file_open(&file, name, NULL); file_read(file, parse_line, ctx);
file_read(&file, parse_line, ctx);
file_close(&file);
} }

View File

@ -18,6 +18,7 @@
#include "dwg.h" #include "dwg.h"
#include "text.h" #include "text.h"
#include "file.h"
#include "lib.h" #include "lib.h"
@ -109,7 +110,7 @@ struct sch_ctx {
void decode_alignment(struct text *txt, char hor, char vert); void decode_alignment(struct text *txt, char hor, char vert);
void sch_render(const struct sheet *sheet); void sch_render(const struct sheet *sheet);
void sch_parse(struct sch_ctx *ctx, const char *name, const struct lib *lib); void sch_parse(struct sch_ctx *ctx, struct file *file, const struct lib *lib);
void sch_init(struct sch_ctx *ctx, bool recurse); void sch_init(struct sch_ctx *ctx, bool recurse);
#endif /* !SCH_H */ #endif /* !SCH_H */