[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: Makefile.am
User: pcjc2
Date: 07/04/17 12:19:02
Modified: . Tag: noscreen Makefile.am refdes_renum
Log:
Sync with trunk
Revision Changes Path
No revision
No revision
1.13.4.3 +2 -2 eda/geda/gaf/utils/scripts/Makefile.am
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Makefile.am
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/utils/scripts/Makefile.am,v
retrieving revision 1.13.4.2
retrieving revision 1.13.4.3
diff -u -b -r1.13.4.2 -r1.13.4.3
--- Makefile.am 23 Feb 2007 23:32:15 -0000 1.13.4.2
+++ Makefile.am 17 Apr 2007 16:19:01 -0000 1.13.4.3
@@ -1,9 +1,9 @@
-## $Id: Makefile.am,v 1.13.4.2 2007/02/23 23:32:15 pcjc2 Exp $
+## $Id: Makefile.am,v 1.13.4.3 2007/04/17 16:19:01 pcjc2 Exp $
##
## Process this file with automake to produce Makefile.in
bin_SCRIPTS = sarlacc_sym gschupdate gsymupdate gschemdoc refdes_renum \
- tragesym pads_backannotate garchive gsymfix.pl \
+ tragesym pads_backannotate pcb_backannotate garchive gsymfix.pl \
gnet_hier_verilog.sh
EXTRA_DIST = convert_sym.awk gpstoimage mk_char_tab.pl \
1.2.6.2 +290 -79 eda/geda/gaf/utils/scripts/refdes_renum
(In the diff below, changes in quantity of whitespace are not shown.)
Index: refdes_renum
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/utils/scripts/refdes_renum,v
retrieving revision 1.2.6.1
retrieving revision 1.2.6.2
diff -u -b -r1.2.6.1 -r1.2.6.2
--- refdes_renum 11 Feb 2007 23:59:10 -0000 1.2.6.1
+++ refdes_renum 17 Apr 2007 16:19:01 -0000 1.2.6.2
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# $Id: refdes_renum,v 1.2.6.1 2007/02/11 23:59:10 pcjc2 Exp $
+# $Id: refdes_renum,v 1.2.6.2 2007/04/17 16:19:01 pcjc2 Exp $
#
# Copyright (C) 2003 Dan McMahill
#
@@ -36,90 +36,250 @@
# don't allow -he to be interpreted as --help
$Getopt::Long::autoabbrev=0;
-my $clear; # reset all refdes
-
+# my $clear; # reset all refdes
&GetOptions(("help" => \&usage,
"nocopy" => \$nocopy,
- "pgskip:i" => \$pgskip,
+ "pgskip:100" => \$pgskip,
"verbose" => \$verbose,
"version" => \&version,
"clear" => \$clear,
+ "gentle" => \$gentle,
+ "force" => \$force,
));
usage() if $Getopt::Long::error;
-# set the default increment for sheets
-unless( $pgskip ) { $pgskip = 100; }
-usage() unless @ARGV;
+# By default pgskip is empty. But if the user gives
+# the --pgskip option with no value, then assign pgskip
+# to 100.
+if (defined($pgskip) && ($pgskip == 0)) {
+ $pgskip = 100;
+}
+# This makes --gentle the default behavior. To
+# force refdes renumbering, use --force.
+$gentle = 1;
+if ( defined($force) || defined($clear) ) {
+ undef($gentle);
+}
-# make sure the input schematic exists and we can read it
+# Print usage string in event user didn't call out any args
+usage() unless @ARGV;
+
+# Make sure the input schematic exists and we can read it.
+# Also count number of files to open.
$i=0;
while(@ARGV) {
$fname[$i]=shift(@ARGV);
- die "Schematic file $fname[$i] does not exist or can not be read"
+ die_sdb(1, "Schematic file $fname[$i] does not exist or can not be read")
unless -r $fname[$i];
$i++;
}
+$filecnt = $i; # number of files to open
+if($verbose) {print "Found $filecnt files to process\n";}
+
+# To refdes an entire design, we normally just loop through all files
+# and process each one in order. However if --gentle option is set,
+# we need to make two passes through all files. First to create a hash
+# of the highest refdeses used, and second to update unnumbered
+# refdeses. The hash is used to know where to start the refdes numbering.
+#
+# It gets more complicated. If --pgskip is not set, then we only need
+# to find the highest refdes overall. But if --pgskip is set, then
+# we need to know the highest refdes on each *page*. This is accomplished
+# on the first scan by creating the variable $highdev{$i, $pre} when --pgskip
+# is defined, but using the variable $highdev{$pre} when it is not.
+#
+if (defined($gentle)) { # First scan through design to build hash
+ for($i=0; $i < $filecnt; $i++) { # $i is the file index.
+ print "Scanning input file #".($i+1).": $fname[$i]\n";
+ open(NETLIST,"$fname[$i]") or die_sdb(1, "Can't open $fname[$i]: $!\n");
+
+ while($line = <NETLIST>) { # Iterate over lines found in .sch file.
+ unless( $line =~ /^refdes/) {
+ next;
+ }
+ # Found refdes line. Eat the newline.
+ $line =~ s/\n//;
-$filecnt = $i;
+ # Now extract component prefix and suffix.
+ if($verbose) {print ("Matching $line ....\n");}
+ $line =~ /refdes=([a-zA-Z_]+)(\d+|\??)/i;
+ my $pre = $1;
+ my $suf = $2 ? $2 : "?";
+ if($verbose) {print "Refdes line \"$line\" has pre=$pre suf=$suf\n";}
+
+ # Now put highest refdes found into $highdev hash.
+ if (defined($pgskip)) {
+ if ($suf eq "?") {
+ # Part has no pre-existing refdes.
+ # Skip to next part.
+ next;
+ } elsif (!defined($highdev{$i, $pre})) {
+ # refdes is not cached, but refdes exists on part.
+ # Create new cache entry
+ if ($suf < $pgskip) {
+ # if pgskip=100, on pg 1, and suf = 23, set highdev=123.
+ $highdev{$i, $pre} = ($i+1)*$pgskip + $suf;
+ } elsif ( ( ($i+1)*$pgskip < $suf) &&
+ ( ($i+2)*$pgskip > $suf) ) {
+ # if pgskip=100, we're on pg 2, and suf = 204, set highdev=204.
+ $highdev{$i, $pre} = $suf;
+ } else {
+ # I don't know what to do!
+ die_sdb(3, "Encountered refdes incompatable with --pgskip setting. Refdes=$pre$suf.\n");
+ }
-for($i=0; $i < $filecnt; $i++) {
- print "Processing input file #",$i+1,": $fname[$i]\n";
- open(NETLIST,"$fname[$i]") or die "Can't open $fname[$i]: $!\n";
+ } elsif ($highdev{$i, $pre} < $suf) {
+ # part has refdes and refdes is higher than cached
+ # value. Store this new value as highest value.
+ $highdev{$i, $pre} = $suf;
+ } elsif ($highdev{$i, $pre} >= $suf) {
+ # part has refdes, but refdes is lower than cached
+ # high value. Leave it alone.
+ next;
+ } else {
+ # Should never get here
+ die_sdb(4, "Invalid refdes with --pgskip set! Exiting....\n");
+ }
+
+ if($verbose) {
+ print "On page ".($i+1).", caching highest refdes $pre$highdev{$i, $pre}\n";
+ }
+ } else {
+ if ($suf eq "?") {
+ # Part has no pre-existing refdes.
+ next;
+ } elsif (!defined($highdev{$pre}) ) {
+ # refdes is not cached, and refdes exists on part. Create new
+ # cache entry
+ $highdev{$pre} = $suf;
+ } elsif ($highdev{$pre} < $suf) {
+ # part has refdes and refdes is higher than cached
+ # value. Store this new value as highest value.
+ $highdev{$pre} = $suf;
+ } elsif ($highdev{$pre} >= $suf) {
+ # part has refdes, but refdes is lower than cached
+ # high value. Leave it alone.
+ next;
+ } else {
+ # Should never get here
+ die_sdb(4, "Invalid refdes! Exiting....\n");
+ }
+ if($verbose) {
+ print "Caching highest refdes $pre$highdev{$pre}\n";
+ }
+ }
+
+ } # while($line = <NETLIST>)
+ close(NETLIST);
+ } # for($i=0; $i < $filecnt; $i++)
+} # if (defined($gentle))
+
+
+# OK, now we can read through the netlist file again, assign refdeses,
+# and write the output file.
+for($i=0; $i < $filecnt; $i++) { # $i is the file index.
+ print "Now processing input file #".($i+1).": $fname[$i]\n";
+ open(NETLIST,"$fname[$i]") or die_sdb(1, "Can't open $fname[$i]: $!\n");
# open output netlist
$outfname="$fname[$i].renum";
- open(OUTNET,">$outfname") or die "Can't open $outfname: $!\n";
+ open(OUTNET,">$outfname") or die_sdb(2, "Can't open $outfname: $!\n");
+ # Iterate over lines found in .sch file.
while($line = <NETLIST>) {
unless( $line =~ /^refdes/) {
print OUTNET $line;
next;
}
- # eat the newline
+
+ # Found refdes line. Eat the newline.
$line =~ s/\n//;
- # for lines like "refdes=CR37" pick out the "CR" part.
- # There's probably a more concise way, but the perl book
- # is at work right now.
- $pre = $line;
- $pre =~ s/^refdes=//;
- $pre =~ s/([0-9\?])*$//;
- my $suf = $1;
- print "Refdes line \"$line\" has pre=\"$pre\"m suf=$suf\n" if($verbose);
+ # Now extract component prefix and suffix.
+ if($verbose) {print ("Processing $line ....\n");}
+ $line =~ /refdes=([a-zA-Z_]+)(\d+|\??)/i;
+ my $pre = $1;
+ my $suf = $2 ? $2 : "?";
+ if($verbose) {print "Refdes line \"$line\" has pre=$pre suf=$suf\n";}
+
+ # Now finally update refdes
if ($clear) {
+ # Just overwrite all refdeses upon clear
+ if($verbose) {print ("Clearing refdes=$pre$suf\n");}
print OUTNET "refdes=$pre?\n";
+ } elsif (defined($pgskip) && defined($gentle)) {
+ # If highdev exists, then start devcnt there, otherwise, start
+ # devcnt at correct value for each page.
+ if (!defined($devcnt{$i, $pre}) && defined($highdev{$i, $pre})) {
+ $devcnt{$i, $pre} = $highdev{$i, $pre};
+ } elsif (!defined($devcnt{$i, $pre}) && !defined($highdev{$i, $pre})) {
+ $devcnt{$i, $pre} = ($i+1)*$pgskip ;
+ }
+
+ if ($suf eq "?") {
+ $devcnt{$i, $pre}++;
+ if ($devcnt{$i, $pre} >= ($i+2)*$pgskip) {
+ print STDERR "ERROR: You are numbering more than $pgskip elements with\n";
+ print STDERR "prefix $pre on this sheet. You will need to either\n";
+ print STDERR "reduce this number or specify a larger step with the\n";
+ print STDERR "--pgskip argument.\n";
+ die_sdb(3, "");
+ }
+ print "Renumbering $line to $pre$devcnt{$i, $pre}\n" if($verbose);
+ print OUTNET "refdes=$pre$devcnt{$i, $pre}\n";
} else {
- # if we're skipping numbers, then start at 100 for page 1
- # and we'll jump to 200 for page 2, etc.
- if( ! $devcnt{$pre} ) { $devcnt{$pre} = $pgskip ? ($i+1)*$pgskip : 0; }
+ print "Leaving line=$line alone\n" if($verbose);
+ print OUTNET "refdes=$pre$suf\n";
+ }
+
+ } elsif (defined($pgskip) && !defined($gentle)) {
+ if (!defined($devcnt{$i, $pre})) {
+ $devcnt{$i, $pre} = ($i+1)*$pgskip ;
+ }
+ $devcnt{$i, $pre}++;
+ if ($devcnt{$i, $pre} >= ($i+2)*$pgskip) {
+ print STDERR "ERROR: You are numbering more than $pgskip elements with\n";
+ print STDERR "prefix $pre on this sheet. You will need to either\n";
+ print STDERR "reduce this number or specify a larger step with the\n";
+ print STDERR "--pgskip argument.\n";
+ die_sdb(3, "");
+ }
+ print "Renumbering $line to $pre$devcnt{$i, $pre}\n" if($verbose);
+ print OUTNET "refdes=$pre$devcnt{$i, $pre}\n";
+
+ } elsif (!defined($pgskip) && defined($gentle)) {
+ if (!defined($devcnt{$pre}) && defined($highdev{$pre})) {
+ $devcnt{$pre} = $highdev{$pre};
+ } elsif (!defined($devcnt{$pre}) && !defined($highdev{$pre})) {
+ $devcnt{$pre} = 0;
+ }
+ if ($suf eq "?") {
$devcnt{$pre}++;
print "Renumbering $line to $pre$devcnt{$pre}\n" if($verbose);
print OUTNET "refdes=$pre$devcnt{$pre}\n";
+ } else {
+ print "Leaving line=$line alone\n" if($verbose);
+ print OUTNET "refdes=$pre$suf\n";
+ }
+ } elsif (!defined($pgskip) && !defined($gentle)) {
+ if (!defined($devcnt{$pre})) {
+ $devcnt{$pre} = 0 ;
}
+ $devcnt{$pre}++;
+ print "Renumbering $line to $pre$devcnt{$pre}\n" if($verbose);
+ print OUTNET "refdes=$pre$devcnt{$pre}\n";
+
+ } else {
+ die_sdb(4, "Invalid state when trying to update refdes! Exiting.....\n");
}
+ } # while($line = <NETLIST>)
close(NETLIST);
close(OUTNET);
- # round each element up to the next 100 to help identify what
- # schematic page a component is on by the refdes.
- if( $pgskip ) {
- foreach $dev (keys %devcnt) {
- my $new_cnt = ($i + 2)*$pgskip;
- if( $new_cnt < $devcnt{$dev} ) {
- print STDERR "ERROR: You have more than $pgskip elements with\n";
- print STDERR "prefix $dev on this sheet. You will need to either\n";
- print STDERR "reduce this number or specify a larger step with the\n";
- print STDERR "--pgskip argument.\n";
- exit( 1 );
- }
- $devcnt{$dev} = $new_cnt;
- print "Incremented \"$dev\" counter to $devcnt{$dev}\n" if($verbose);
- }
- }
# make this an option to not overwrite the original
if( $nocopy ) {
@@ -130,7 +290,7 @@
}
}
-exit;
+exit(0);
#######################################################################
@@ -171,17 +331,34 @@
print " with 201, etc Specifying a value gives the step between pages.\n";
print " For example --pgskip 10 will start with 11, 21, 31, etc.\n";
print "\n";
+ print " --gentle This flag tells refdes_renum to leave any refdeses\n";
+ print " alone if they already have numbers. Use this option to number\n";
+ print " new components in a schematic which has already been numbered.\n";
+ print " Note that --gentle is set by default!\n";
+ print "\n";
+ print " --force Set this flag to renumber all refdeses, whether they are already\n";
+ print " numbered or not.\n";
+ print "\n";
print " --verbose Enables verbose output.\n";
print "\n";
print " --version Shows the version of this program.\n";
print "\n\n";
- print "Example:\n\n";
+ print "Return codes:\n\n";
+ print "\t$pname returns the following codes to the shell upon completion:\n";
+ print "\n";
+ print " 0 Program ran successfully.\n";
+ print " 1 Error opening or reading input file.\n";
+ print " 2 Error opening or writing output file.\n";
+ print " 3 Too many components for --pgskip setting.\n";
+ print " 4 Internal error (program bug encountered).\n";
+ print "\n";
+ print "Usage examples:\n\n";
print "\t$pname mysch.sch\n";
print "\t$pname --pgskip pg1.sch pg2.sch pg3.sch\n";
print "\n\n";
print "$pname was written by Dan McMahill <dmcmahill\@netbsd.org>\n";
print "\n\n";
- exit;
+ exit(0);
}
#---------------------------------
@@ -191,7 +368,7 @@
#---------------------------------
sub version {
- open(PROG,"$0") or die "Could not open \"$0\" to find version\n\n";
+ open(PROG,"$0") or die_sdb(4, "Could not open \"$0\" to find version\n\n");
my $pname = $0;
$pname =~ s/.*\///g;
@@ -201,11 +378,23 @@
$version = $words[3];
$date = $words[4];
print "$pname ($0): Version $version, $date\n";
- exit;
+ exit(0);
}
}
- print "Could not determine version of \"$0\"\n\n";
- exit;
+ die_sdb(4, "Could not determine version of \"$0\"\n\n");
+}
+
+#-------------------------------------------
+# die_sdb(rc, string)
+#
+# Local version of die. Sets return code
+# for shell, then calls die(string)
+#--------------------------------------------
+sub die_sdb {
+ my $rc = $_[0];
+ my $string = $_[1];
+ $! = $rc;
+ die($string);
}
# ----------------------------------------------
@@ -213,6 +402,28 @@
# Change Log
#
# $Log: refdes_renum,v $
+# Revision 1.2.6.2 2007/04/17 16:19:01 pcjc2
+# Sync with trunk
+#
+# Revision 1.7 2007/04/15 23:20:31 sdb
+# Made --gentle the default behavior of refdes_renum.
+#
+# Revision 1.7 2007/04/15 SDB
+# Made --gentle default behavior. Now user must use --force
+# to get old behavior, which renumbers all refdeses whether
+# already numbered or not.
+#
+# Revision 1.6 2007/04/15 00:42:22 sdb
+# Added --gentle flag to refdes_renum, which won't renumber refdeses
+# which already have a number.
+#
+# Revision 1.5 4.9.2007 sdb.
+# Added --gentle flag, and include logic to handle case
+# where user mixes --gentle with --pgskip.
+#
+# Revision 1.4 2007/02/24 18:43:17 pcjc2
+# Merge changes to date from noscreen branch.
+#
# Revision 1.2.6.1 2007/02/11 23:59:10 pcjc2
# Sync with trunc
#
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs