diff options
Diffstat (limited to 'src/usr/targeting/common/xmltohb/xmltohb.pl')
-rwxr-xr-x | src/usr/targeting/common/xmltohb/xmltohb.pl | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/usr/targeting/common/xmltohb/xmltohb.pl b/src/usr/targeting/common/xmltohb/xmltohb.pl index 70340cbfb..994d3e855 100755 --- a/src/usr/targeting/common/xmltohb/xmltohb.pl +++ b/src/usr/targeting/common/xmltohb/xmltohb.pl @@ -249,6 +249,12 @@ if( !($cfgSrcOutputDir =~ "none") ) writeTargetErrlHFile($attributes,$targetErrlHFile); close $targetErrlHFile; + open(ATTR_INFO_CSV_FILE,">$cfgSrcOutputDir"."targAttrInfo.csv") + or fatal ("Attribute info csv file: \"$cfgSrcOutputDir" + . "targAttrInfo.csv\" could not be opened."); + my $attrInfoCsvFile = *ATTR_INFO_CSV_FILE; + writeAttrInfoCsvFile($attributes,$attrInfoCsvFile); + close $attrInfoCsvFile; } if( !($cfgImgOutputDir =~ "none") ) @@ -2138,6 +2144,85 @@ sub writeAttrErrlHFile { } # sub writeAttrErrlHFile ###### +#Create a .csv file to parse attribute overrides/syncs +##### +sub writeAttrInfoCsvFile { + my($attributes,$outFile) = @_; + + # Print the file header + print $outFile "# targAttrInfo.cvs\n"; + print $outFile "# This file is generated by perl script xmltohb.pl\n"; + print $outFile "# It lists information about TARG attributes and is used to\n"; + print $outFile "# process FAPI Attribute text files (overrides/syncs)\n"; + print $outFile "# Format:\n"; + print $outFile "# <FAPI-ATTR-ID-STR>,<LAYER-ATTR-ID-STR>,<ATTR-ID-VAL>,<ATTR-TYPE>\n"; + + my $attributeIdEnum = getAttributeIdEnumeration($attributes); + + # loop through every attribute + foreach my $attribute (@{$attributes->{attribute}}) + { + # Only (initially) support attributes with simple integer types + if ((exists $attribute->{simpleType}) && + ((exists $attribute->{simpleType}->{uint8_t}) || + (exists $attribute->{simpleType}->{uint16_t}) || + (exists $attribute->{simpleType}->{uint32_t}) || + (exists $attribute->{simpleType}->{uint64_t}))) + { + my $fapiId = "NO-FAPI-ID"; + + if (exists $attribute->{hwpfToHbAttrMap}[0]) + { + $fapiId = $attribute->{hwpfToHbAttrMap}[0]->{id}; + } + + foreach my $enum (@{$attributeIdEnum->{enumerator}}) + { + if ($enum->{name} eq $attribute->{id}) + { + print $outFile "$fapiId,"; + print $outFile "ATTR_$attribute->{id}"; + print $outFile ",$enum->{value},"; + + if (exists $attribute->{simpleType}->{uint8_t}) + { + print $outFile "u8"; + } + elsif (exists $attribute->{simpleType}->{uint16_t}) + { + print $outFile "u16"; + } + elsif (exists $attribute->{simpleType}->{uint32_t}) + { + print $outFile "u32"; + } + elsif (exists $attribute->{simpleType}->{uint64_t}) + { + print $outFile "u64"; + } + + if (exists $attribute->{simpleType}->{array}) + { + # Remove leading whitespace + my $dimText = $attribute->{simpleType}->{array}; + $dimText =~ s/^\s+//; + + # Split on commas or whitespace + my @vals = split(/\s*,\s*|\s+/, $dimText); + + foreach my $val (@vals) + { + print $outFile "[$val]"; + } + } + print $outFile "\n"; + } + } + } + } +} # sub writeAttrInfoCsvFile + +###### #Create a .C file to put target into the errlog ##### sub writeTargetErrlCFile { |