1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-23 05:31:53 +02:00

b2/boom.c: add parametric part selection (with option -Q)

This commit is contained in:
Werner Almesberger 2012-05-21 21:20:23 -03:00
parent bcf4696dd9
commit 256a096220

View File

@ -18,9 +18,11 @@
#include "lang.h" #include "lang.h"
#include "param.h" #include "param.h"
#include "subex.h" #include "subex.h"
#include "db.h"
static struct param *vars = NULL, **last_var = &vars; static struct param *vars = NULL, **last_var = &vars;
static int select_parts = 0;
static void add_var(const char *arg) static void add_var(const char *arg)
@ -44,14 +46,26 @@ static void do_substitutions(void)
{ {
struct param *out; struct param *out;
const struct param *var; const struct param *var;
const struct part **parts, **p;
out = substitute(substitutions, vars); out = substitute(substitutions, vars);
if (select_parts) {
parts = select_parametric(out, &hierarchy);
if (!parts) {
fprintf(stderr, "no matches\n");
} else {
for (p = parts; *p; p++)
printf("%s %s\n", (*p)->domain, (*p)->name);
free(parts);
}
} else {
for (var = out; var; var = var->next) { for (var = out; var; var = var->next) {
printf("%s", var->u.name); printf("%s", var->u.name);
dump_relop(stdout, var->op); dump_relop(stdout, var->op);
printf("%s\n", var->value.u.s); printf("%s\n", var->value.u.s);
} }
free_vars(out); free_vars(out);
}
} }
@ -66,6 +80,7 @@ static void usage(const char *name)
" -p providers\n" " -p providers\n"
" -s substitutions\n" " -s substitutions\n"
" -q var=value ...\n" " -q var=value ...\n"
" -Q var=value ...\n"
, name); , name);
exit(1); exit(1);
} }
@ -90,7 +105,10 @@ int main(int argc, char **argv)
process = parse_substitutions; process = parse_substitutions;
else if (!strcmp(argv[i], "-q")) else if (!strcmp(argv[i], "-q"))
process = add_var; process = add_var;
else else if (!strcmp(argv[i], "-Q")) {
process = add_var;
select_parts = 1;
} else
usage(*argv); usage(*argv);
} else { } else {
process(argv[i]); process(argv[i]);