mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-29 20:15:54 +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:
parent
24522c45e0
commit
49a6ebd797
@ -78,7 +78,7 @@ neo900.pdf: $(NAME) sch2pdf neo900-template.fig
|
||||
$(NEO900_HW)/neo900.sch
|
||||
|
||||
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
|
||||
|
||||
#----- Regression test based on Neo900 schematics -----------------------------
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "util.h"
|
||||
#include "main.h"
|
||||
#include "cro.h"
|
||||
#include "file.h"
|
||||
#include "sch.h"
|
||||
#include "lib.h"
|
||||
#include "diff.h"
|
||||
@ -111,6 +112,7 @@ static void *diff_init(int argc, char *const *argv)
|
||||
char c;
|
||||
int arg;
|
||||
struct sch_ctx new_sch;
|
||||
struct file sch_file;
|
||||
struct lib new_lib;
|
||||
|
||||
diff = alloc_type(struct diff);
|
||||
@ -136,9 +138,11 @@ static void *diff_init(int argc, char *const *argv)
|
||||
if (argc - optind < 1)
|
||||
usage(*argv);
|
||||
|
||||
file_open(&sch_file, argv[argc - 1], NULL);
|
||||
for (arg = optind; arg != argc - 1; arg++)
|
||||
lib_parse(&new_lib, argv[arg]);
|
||||
sch_parse(&new_sch, argv[argc - 1], &new_lib);
|
||||
lib_parse(&new_lib, argv[arg], &sch_file);
|
||||
sch_parse(&new_sch, &sch_file, &new_lib);
|
||||
file_close(&sch_file);
|
||||
|
||||
optind = 0;
|
||||
gfx_init(&cro_img_ops, argc, argv);
|
||||
|
@ -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;
|
||||
|
||||
lib->state = lib_skip;
|
||||
file_open(&file, name, NULL);
|
||||
file_open(&file, name, related);
|
||||
file_read(&file, lib_parse_line, lib);
|
||||
file_close(&file);
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "file.h"
|
||||
|
||||
|
||||
enum lib_state {
|
||||
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);
|
||||
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);
|
||||
|
||||
#endif /* !LIB_H */
|
||||
|
@ -81,6 +81,7 @@ int main(int argc, char *const *argv)
|
||||
{
|
||||
struct lib lib;
|
||||
struct sch_ctx sch_ctx;
|
||||
struct file sch_file;
|
||||
bool recurse = 0;
|
||||
const char *cat = NULL;
|
||||
char c;
|
||||
@ -122,9 +123,12 @@ int main(int argc, char *const *argv)
|
||||
if (dashdash - optind < 1)
|
||||
usage(*argv);
|
||||
|
||||
sch_init(&sch_ctx, recurse);
|
||||
file_open(&sch_file, argv[dashdash - 1], NULL);
|
||||
|
||||
lib_init(&lib);
|
||||
for (arg = optind; arg != dashdash - 1; arg++)
|
||||
lib_parse(&lib, argv[arg]);
|
||||
lib_parse(&lib, argv[arg], &sch_file);
|
||||
|
||||
if (dashdash == argc) {
|
||||
gfx_argc = 1;
|
||||
@ -151,8 +155,9 @@ found:
|
||||
|
||||
optind = 0; /* reset getopt */
|
||||
|
||||
sch_init(&sch_ctx, recurse);
|
||||
sch_parse(&sch_ctx, argv[dashdash - 1], &lib);
|
||||
sch_parse(&sch_ctx, &sch_file, &lib);
|
||||
file_close(&sch_file);
|
||||
|
||||
gfx_init(*ops, gfx_argc, gfx_argv);
|
||||
if (recurse) {
|
||||
const struct sheet *sheet;
|
||||
|
@ -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;
|
||||
file_open(&file, name, NULL);
|
||||
file_read(&file, parse_line, ctx);
|
||||
file_close(&file);
|
||||
file_read(file, parse_line, ctx);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "dwg.h"
|
||||
#include "text.h"
|
||||
#include "file.h"
|
||||
#include "lib.h"
|
||||
|
||||
|
||||
@ -109,7 +110,7 @@ struct sch_ctx {
|
||||
void decode_alignment(struct text *txt, char hor, char vert);
|
||||
|
||||
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);
|
||||
|
||||
#endif /* !SCH_H */
|
||||
|
Loading…
Reference in New Issue
Block a user