mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 01:14:04 +02:00
b2/boom.c: add parametric part selection (with option -Q)
This commit is contained in:
parent
bcf4696dd9
commit
256a096220
20
b2/boom.c
20
b2/boom.c
@ -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,8 +46,19 @@ static void do_substitutions(void)
|
||||
{
|
||||
struct param *out;
|
||||
const struct param *var;
|
||||
const struct part **parts, **p;
|
||||
|
||||
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) {
|
||||
printf("%s", var->u.name);
|
||||
dump_relop(stdout, var->op);
|
||||
@ -53,6 +66,7 @@ static void do_substitutions(void)
|
||||
}
|
||||
free_vars(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void usage(const char *name)
|
||||
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user