From dd3c0c205b58484983a8402b127a8c8035f00638 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 6 Mar 2012 17:47:50 -0300 Subject: [PATCH] m1r4/dsv/bomshelf: support adding components to the BOM Also removed a comment that is now in Makefile. --- m1r4/dsv/bomshelf | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/m1r4/dsv/bomshelf b/m1r4/dsv/bomshelf index 40d13c6..1bbdefe 100755 --- a/m1r4/dsv/bomshelf +++ b/m1r4/dsv/bomshelf @@ -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 () { 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 () { 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 \"$_\"";