1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 06:29:22 +02:00

m1r4/dsv/bomshelf: support adding components to the BOM

Also removed a comment that is now in Makefile.
This commit is contained in:
Werner Almesberger 2012-03-06 17:47:50 -03:00
parent 19e2f84c75
commit dd3c0c205b

View File

@ -1,10 +1,4 @@
#!/usr/bin/perl
#
# Source:
# http://downloads.qi-hardware.com/hardware/milkymist_one/bom/rc3/milkymist_one_bom_rc3.ods
# - save as CVS
# - edit to remove embedded newlines
#
sub csv
{
@ -50,19 +44,34 @@ while (<F>) {
next if /^\s*#/;
next if /^\s*$/;
if (/^[Cc]:\s*/) {
undef $p if $clear;
$clear = 0;
if (defined $p) {
$cr{$p} = $';
for $c (&csv($')) {
warn "\"$c\" (supplement) used for $r{$c} ".
"and $p" if defined $r{$c};
$r{$c} = $p;
}
next;
}
die "unknown component reference $'" unless defined $r{$'};
$p = $r{$'};
next;
}
if (/^[Pp]:\s*/) {
$p = $';
$clear = 0;
next if defined $cr{$p};
@a = grep { $_ =~ /^$p/ } keys %cr;
die "key $p* is ambiguous" if scalar @a > 1;
if (!@a) {
@a = grep { $_ =~ /$p/ } keys %cr;
die "key *$p* is ambiguous" if scalar @a > 1;
die "key $p matches nothing" unless @a;
if (!@a) {
warn "adding $p as supplement";
next;
}
}
$p = $a[0];
next;
@ -70,10 +79,12 @@ while (<F>) {
if (/^[Aa]:\s*/) {
$a{$p} .= "," if defined $a{$p};
$a{$p} .= $';
$clear = 1;
next;
}
if (/^[Dd]:\s*/) {
$url{$p} = $';
$clear = 1;
next;
}
die "don't recognize \"$_\"";