diff --git a/src/epics/util/feCodeGen.pl b/src/epics/util/feCodeGen.pl index 066e63108a04cdc3012c068c16597da6cdff7f47..b00aeeb65f8d82f7846c9716cf7a4d9f731ec9c9 100755 --- a/src/epics/util/feCodeGen.pl +++ b/src/epics/util/feCodeGen.pl @@ -727,16 +727,50 @@ for($ii=0;$ii<$nonSubCnt;$ii++) } } -#// - Remove all parts which will not require further processing in the code for the part -#// total. \n +#// - Remove all parts which will not require further processing in the code for the part +#// total, also do a part check for blocks with different capitalization that are going to +#// emit c code that will be lowercased (causing collisions) $ftotal = $partCnt; - for($kk=0;$kk<$partCnt;$kk++) - { - if(($partType[$kk] eq "INPUT") || ($partType[$kk] eq "OUTPUT") || ($partType[$kk] eq "BUSC") || ($partType[$kk] eq "BUSS") || ($partType[$kk] eq "EpicsIn") || ($partType[$kk] eq "TERM") || ($partType[$kk] eq "FROM") || ($partType[$kk] eq "GOTO") || ($partType[$kk] eq "GROUND") || ($partType[$kk] eq "CONSTANT") || ($partType[$kk] eq "Adc") || ($partType[$kk] eq "Gps") || ($partType[$kk] eq "StateWord") || ($partType[$kk] eq "ModelRate") || ($partType[$kk] eq "EXC")) - { - $ftotal --; - } - } + +my %seen; #Hash that keeps track of the names we have seen before +my %noCode = map {$_ => 1} qw(INPUT OUTPUT BUSC BUSS FROM GOTO); #Hash of non-generating parts +my @duplicates = (); + +for($kk=0;$kk<$partCnt;$kk++) +{ + if(($partType[$kk] eq "INPUT") || ($partType[$kk] eq "OUTPUT") || ($partType[$kk] eq "BUSC") + || ($partType[$kk] eq "BUSS") || ($partType[$kk] eq "EpicsIn") || ($partType[$kk] eq "TERM") + || ($partType[$kk] eq "FROM") || ($partType[$kk] eq "GOTO") || ($partType[$kk] eq "GROUND") + || ($partType[$kk] eq "CONSTANT") || ($partType[$kk] eq "Adc") || ($partType[$kk] eq "Gps") + || ($partType[$kk] eq "StateWord") || ($partType[$kk] eq "ModelRate") || ($partType[$kk] eq "EXC")) + { + $ftotal --; + } + + # Check to see if we have a part with the same lower case name, + # and neither parts are of a no code generating type + if ( exists $seen{ lc $xpartName[$kk] } + and not exists $noCode{$partType[$kk]} + and not exists $noCode{ $seen{ lc $xpartName[$kk] }[1] } ) + { + push(@duplicates, "\tFirst (part, type) is: ($xpartName[$kk], $partType[$kk]),". + " other part is ($seen{ lc $xpartName[$kk]}[0], $seen{ lc $xpartName[$kk]}[1])\n"); + } + else + { + my @val = ($xpartName[$kk], $partType[$kk]); + $seen{ lc $xpartName[$kk] } = \@val; + } +} + +if ( scalar(@duplicates) > 0) #If we found 1 or more issues +{ + my $whole_error = "ERROR - Some part(s) failed the duplicate name check. " . + "Two parts, that generate code, with the same name (but different capitalization) were found.\n" . + "This can cause an issue with code generation, please rename one of the parts, from each pair.\n"; + $whole_error = $whole_error . join('', @duplicates); + die $whole_error . "\n"; +} print "Total parts to process $ftotal\n";