1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 09:39:42 +02:00

gencat/: new option -F to use fped footprints (WIP)

This commit is contained in:
Werner Almesberger 2012-07-12 00:58:12 -03:00
parent 9cf8adf878
commit e4481450ec
4 changed files with 70 additions and 4 deletions

View File

@ -11,7 +11,7 @@
PREFIX ?= /usr/local PREFIX ?= /usr/local
OBJS = gencat.o tree.o libs.o run.o comp.o pdf.o OBJS = gencat.o tree.o libs.o run.o comp.o fped.o pdf.o
SHELL = /bin/bash SHELL = /bin/bash
CFLAGS = -Wall -g CFLAGS = -Wall -g

61
gencat/fped.c Normal file
View File

@ -0,0 +1,61 @@
/*
* comp.c - Component libraries
*
* Copyright 2012 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#define _GNU_SOURCE /* for asprintf */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "run.h"
#include "libs.h"
static void fped_add_lib(struct lib *lib, const char *path)
{
FILE *file;
char buf[1024]; /* @@@ */
char *tmp, *nl;
asprintf(&tmp, "fped -k '%s' -", path);
file = popen(tmp, "r");
if (!file) {
perror(path);
exit(1);
}
while (fgets(buf, sizeof(buf), file)) {
if (strncmp(buf, "$MODULE ", 8))
continue;
nl = strchr(buf, '\n');
if (nl)
*nl = 0;
add_name(new_entry(lib, 1), buf+8);
}
pclose(file);
}
static void fped_ps_entry(FILE *file, const struct lib *lib,
const struct entry *e, int unit)
{
run_cmd("fped -P '%s' -1 '%s' '%s'",
e->file->path, e->names->s, "tmp.ps");
run_cmd("sed -i -e '/^ /s/\\<div\\>/sdiv/' tmp.ps");
cat(file, "tmp.ps");
}
struct lib fped_lib = {
.ext = ".fpd",
.add_lib = fped_add_lib,
.ps_entry = fped_ps_entry,
};

View File

@ -27,12 +27,13 @@ int quiet = 0;
static void usage(const char *name) static void usage(const char *name)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [-d|-D] [-p] [-P] [-q] [-L libdir ...] [-l lib ...] hierarchy\n" "usage: %s [-F] [-d|-D] [-p] [-P] [-q] [-L libdir ...] [-l lib ...] hierarchy\n"
" %*s [descriptions ...]\n\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"
" -D dump all the canonical component names (without aliases)\n" " -D dump all the canonical component names (without aliases)\n"
" -F use fped footprints instead of KiCad components\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 library\n"
" -p use portrait orientation; default: landscape\n" " -p use portrait orientation; default: landscape\n"
" -P generate Postscript instead of PDF (mainly for debugging)\n" " -P generate Postscript instead of PDF (mainly for debugging)\n"
" -q don't show progress\n" " -q don't show progress\n"
@ -49,7 +50,7 @@ int main(int argc, char **argv)
int opt_dump_tree = 0, opt_dump_comp = 0, postscript = 0, portrait = 0; int opt_dump_tree = 0, opt_dump_comp = 0, postscript = 0, portrait = 0;
char **arg; char **arg;
while ((c = getopt(argc, argv, "dDL:l:Ppq")) != EOF) while ((c = getopt(argc, argv, "dDFL:l:Ppq")) != EOF)
switch (c) { switch (c) {
case 'd': case 'd':
opt_dump_tree = 1; opt_dump_tree = 1;
@ -57,6 +58,9 @@ int main(int argc, char **argv)
case 'D': case 'D':
opt_dump_comp = 1; opt_dump_comp = 1;
break; break;
case 'F':
lib = &fped_lib;
break;
case 'L': case 'L':
add_libdir(lib, optarg); add_libdir(lib, optarg);
break; break;

View File

@ -41,6 +41,7 @@ struct lib {
extern struct lib comp_lib; extern struct lib comp_lib;
extern struct lib fped_lib;
const struct entry *lookup_sym(const struct lib *lib, const char *name); const struct entry *lookup_sym(const struct lib *lib, const char *name);