r5836 - in trunk: eda/boom gta02-core/bom

werner at docs.openmoko.org werner at docs.openmoko.org
Mon Feb 8 04:47:47 CET 2010


Author: werner
Date: 2010-02-08 04:47:47 +0100 (Mon, 08 Feb 2010)
New Revision: 5836

Modified:
   trunk/eda/boom/annotate
   trunk/eda/boom/misc.pl
   trunk/eda/boom/prettyord
   trunk/gta02-core/bom/Makefile
Log:
Follow "OldPn" references in descriptions.

- eda/boom/misc.pl: moved description lookup from "prettyord" and "annotate"
- eda/boom/misc.pl: added mechanism to translate pointers in descriptions back
  to component references within a lookup
- eda/boom/prettyord, eda/boom/annotate: new hackish option -s/from/to/ to add
  translations
- bom/Makefile: new target "show-fic" to show the list of items from FIC's
  inventory
- bom/Makefile: use -s for "show-fic" and annotation to handle "OldPn" records
- bom/Makefile: made regexps used to grep through the order list more robust



Modified: trunk/eda/boom/annotate
===================================================================
--- trunk/eda/boom/annotate	2010-02-07 17:46:18 UTC (rev 5835)
+++ trunk/eda/boom/annotate	2010-02-08 03:47:47 UTC (rev 5836)
@@ -4,9 +4,6 @@
 require "misc.pl";
 
 
-&parse;
-
-
 $H = 50;	# character height
 $W = $H*0.9;	# character width
 $L = $H+20;	# line skip
@@ -103,17 +100,6 @@
 }
 
 
-sub find_dsc
-{
-    local ($id) = @_;
-
-    for ($id, &eq($id)) {
-	return $dsc{$_} if defined $dsc{$_};
-    }
-    return ();
-}
-
-
 sub dsc_parts
 {
     local ($ref) = @_;
@@ -122,7 +108,8 @@
     while (@p) {
 	my @id = splice(@p, 0, 2);
 	my $id = "$id[0] $id[1]";
-	push(@f, &find_dsc($id));
+	my $dsc = &dsc_find($id);
+	push(@f, &dsc) if defined $dsc;
     }
     return @f;
 }
@@ -135,13 +122,29 @@
     for my $id (keys %order) {
 	my @p = @{ $order{$id} };
 	for (splice(@p, 3)) {
-	    push(@f, &find_dsc($id)) if $_ eq $ref;
+	    push(@f, &dsc_find($id)) if $_ eq $ref;
 	}
     }
     return @f;
 }
 
 
+sub usage
+{
+    print STDERR "usage: $0 [-s/from/to/ ...] ...\n";
+    exit(1);
+}
+
+
+while ($ARGV[0] =~ /^-s/) {
+    &usage unless &dsc_xlat_arg($');
+    shift @ARGV;
+}
+&usage if $ARGV[0] =~ /^-./;
+
+&parse;
+
+
 #
 # pass 1: find the orientation of all parts
 #

Modified: trunk/eda/boom/misc.pl
===================================================================
--- trunk/eda/boom/misc.pl	2010-02-07 17:46:18 UTC (rev 5835)
+++ trunk/eda/boom/misc.pl	2010-02-08 03:47:47 UTC (rev 5836)
@@ -23,4 +23,57 @@
 }
 
 
+#
+# When looking for a description, we also consider equivalent parts.
+#
+# Furthermore, some descriptions may just be pointers to other descriptions.
+# Users can add regular expressions that are used to extract references from
+# a description, which are then looked up as well.
+#
+
+sub __dsc_lookup
+{
+    local ($id) = @_;
+
+    for ($id, &eq($id)) {
+        return $dsc{$_} if defined $dsc{$_};
+    }
+    return undef;
+}
+
+
+sub dsc_find
+{
+    my $id = $_[0];
+    LOOKUP: while (1) {
+	my $dsc = &__dsc_lookup($id);
+	return undef unless defined $dsc;
+	for (my $i = 0; $i <= $#xlat_from; $i++) {
+# @@@ this is UUUUHHHGLLEEEEE !!! Why can't I just expand $to[$i] ?
+	    next
+	      unless ($id = $dsc) =~ s/^.*$xlat_from[$i].*$/$xlat_to[$i] $1/;
+	    next LOOKUP if defined &__dsc_lookup($id);
+	}
+	return $dsc;
+    }
+    return undef;
+}
+
+
+sub dsc_xlat
+{
+    local ($from, $to) = @_;
+    push(@xlat_from, $from);
+    push(@xlat_to, $to);
+}
+
+
+sub dsc_xlat_arg
+{
+    return undef unless $_[0] =~ /^(.)([^\1]*)\1([^\1]*)\1$/;
+    &dsc_xlat($2, $3);
+    return 1;
+}
+
+
 return 1;

Modified: trunk/eda/boom/prettyord
===================================================================
--- trunk/eda/boom/prettyord	2010-02-07 17:46:18 UTC (rev 5835)
+++ trunk/eda/boom/prettyord	2010-02-08 03:47:47 UTC (rev 5836)
@@ -3,6 +3,20 @@
 require "parser.pl";
 require "misc.pl";
 
+
+sub usage
+{
+    print STDERR "usage: $0 [-s/from/to/ ...] ...\n";
+    exit(1);
+}
+
+
+while ($ARGV[0] =~ /^-s/) {
+    &usage unless &dsc_xlat_arg($');
+    shift @ARGV;
+}
+&usage if $ARGV[0] =~ /^-./;
+
 &parse;
 
 $out[0][0] = "Pos";
@@ -17,13 +31,7 @@
     push(@{ $out[1] }, $order{$_}[0]);
     @f = split(/\s+/, $_);
     push(@{ $out[2] }, $f[1]);
-    my $dsc = $dsc{$_};
-    if (!defined $dsc) {
-	for (&eq($_)) {
-	    $dsc = $dsc{$_};
-	    last if defined $dsc;
-	}
-    }
+    my $dsc = &dsc_find($_);
     print STDERR "$_: no description\n" unless defined $dsc;
     push(@{ $out[3] }, defined $dsc ? $dsc : "???");
     push(@{ $out[4] }, $order{$_}[1]);

Modified: trunk/gta02-core/bom/Makefile
===================================================================
--- trunk/gta02-core/bom/Makefile	2010-02-07 17:46:18 UTC (rev 5835)
+++ trunk/gta02-core/bom/Makefile	2010-02-08 03:47:47 UTC (rev 5836)
@@ -11,7 +11,8 @@
 CHR=darfon.chr ralec.chr avx.chr acx.chr misc.chr
 SCH=audio bt cpu-power cpu gps io lcm memory modem pmu sd-sim usb wlan
 
-.PHONY:		all optimist pessimist spotless show-dup show-missing show-dk
+.PHONY:		all optimist pessimist spotless
+.PHONY:		show-dup show-missing show-dk show-fic
 .PHONY:		ann sch gen generate gv xpdf upload
 
 all:		gta02-core.ord
@@ -67,16 +68,22 @@
 		$(BOOM) ./pardup.pl gta02-core.par
 
 show-missing:	$(EQU) fic/fic.dsc
-		(echo '#ORD'; grep MISSING gta02-core.ord ; ) | \
+		(echo '#ORD'; grep '^MISSING ' gta02-core.ord ; ) | \
 		  $(BOOM) prettyord - $(EQU) fic/fic.dsc | \
 		  sed 's/^...  \(.\{,78\}\).*/\1/'
 
 show-dk:
-		(echo '#ORD'; grep DIGI-KEY gta02-core.ord ; ) | \
+		(echo '#ORD'; grep '^DIGI-KEY ' gta02-core.ord ; ) | \
 		  $(BOOM) prettyord - digi-key.dsc | \
 		  sed 's/^...  //' | \
 		  awk '{ s += $$(NF); print; } END { print "USD", s }'
 
+show-fic:	$(EQU) fic/fic.dsc
+		(echo '#ORD'; grep '^FIC ' gta02-core.ord ; ) | \
+		  $(BOOM) prettyord '-s/OldPn (\S+)/FIC/' \
+		  - $(EQU) fic/fic.dsc | \
+		  sed 's/^...  \(.\{,78\}\).*/\1/'
+
 #ANN = pmu
 ANN = audio
 ann:		../$(ANN).sch fic/fic.dsc gta02-core.par $(EQU)
@@ -86,7 +93,8 @@
 $(SCH:%=%-bom.sch): \
 		$(SCH:%=../%.sch) fic/fic.dsc gta02-core.$(ANNOTATE) $(EQU)
 		for n in $(SCH); do \
-		    $(BOOM) annotate ../$$n.sch fic/fic.dsc \
+		    $(BOOM) annotate '-s/OldPn (\S+)/FIC/' \
+		      ../$$n.sch fic/fic.dsc \
 		      gta02-core.$(ANNOTATE) $(EQU) >$$n-bom.sch \
 		      || { rm -f $$n-bom.sch; exit 1; }; \
 		done




More information about the commitlog mailing list