Limit auto-declaration of record types to regRecDevDrv only

Allowing this while expanding DBD files for IOCs can insert other
device supports before of the Base "Soft Channel" ones, making the
other type the default. Adds a note that DBD file order matters.

Fixes lp: #1908305
This commit is contained in:
Andrew Johnson
2021-02-21 17:13:44 -06:00
parent e881cb15c4
commit bee00658ae
3 changed files with 9 additions and 2 deletions

View File

@@ -1,2 +1,2 @@
include "xxxRecord.dbd"
device(xxx,CONSTANT,devXxxSoft,"SoftChannel")
device(xxx,CONSTANT,devXxxSoft,"Soft Channel")

View File

@@ -29,6 +29,7 @@ use DBD::Function;
use DBD::Variable;
our $debug=0;
our $allowAutoDeclarations=0;
sub ParseDBD {
(my $dbd, $_) = @_;
@@ -102,8 +103,11 @@ sub ParseDBD {
unquote($1, $2, $3, $4);
my $rtyp = $dbd->recordtype($record_type);
if (!defined $rtyp) {
my $msg = "Device '$choice' defined for unknown record type '$record_type'.";
dieContext($msg, "DBD files must be added in the correct order.")
unless $allowAutoDeclarations;
warn "$msg\nRecord type '$record_type' declared.\n";
$rtyp = DBD::Recordtype->new($record_type);
warn "Device using unknown record type '$record_type', declaration created\n";
$dbd->add($rtyp);
}
$rtyp->add_device(DBD::Device->new($link_type, $dset, $choice));

View File

@@ -31,6 +31,9 @@ my @path = map { split /[:;]/ } @opt_I; # FIXME: Broken on Win32?
my ($file, $subname, $bldTop) = @ARGV;
# Permit auto-declaration of record types for building runtime-loadable modules
$DBD::Parser::allowAutoDeclarations = 1;
my $dbd = DBD->new();
ParseDBD($dbd, Readfile($file, "", \@path));