1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-23 08:15:31 +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 "param.h"
#include "subex.h"
#include "db.h"
static struct param *vars = NULL, **last_var = &vars;
static int select_parts = 0;
static void add_var(const char *arg)
@ -44,14 +46,26 @@ static void do_substitutions(void)
{
struct param *out;
const struct param *var;
const struct part **parts, **p;
out = substitute(substitutions, vars);
for (var = out; var; var = var->next) {
printf("%s", var->u.name);
dump_relop(stdout, var->op);
printf("%s\n", var->value.u.s);
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) {
printf("%s", var->u.name);
dump_relop(stdout, var->op);
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"
" -s substitutions\n"
" -q var=value ...\n"
" -Q var=value ...\n"
, name);
exit(1);
}
@ -90,7 +105,10 @@ int main(int argc, char **argv)
process = parse_substitutions;
else if (!strcmp(argv[i], "-q"))
process = add_var;
else
else if (!strcmp(argv[i], "-Q")) {
process = add_var;
select_parts = 1;
} else
usage(*argv);
} else {
process(argv[i]);