Don't strip extensions twice in BOM export

Exporting the Bill of Materials uses the netlist exporter.  Both of
these routines were stripping the extension, leading to projects like
"test.project.kicad_pro" having the project name stripped.  We separate
the BOM netlist export from generic plugin netlist export to allow the
correct behavior when exporting netlists and generating BOMs

Fixes https://gitlab.com/kicad/code/kicad/issues/10270

(cherry picked from commit bef762e652)
This commit is contained in:
Seth Hillbrand 2022-01-05 11:05:18 -08:00
parent 9ca41cc8ee
commit 30549a5e6a
3 changed files with 15 additions and 4 deletions

View File

@ -32,18 +32,19 @@
#include <bom_plugins.h> #include <bom_plugins.h>
#include <confirm.h> #include <confirm.h>
#include <dialog_bom_base.h> #include <dialog_bom_base.h>
#include <string_utils.h> #include <dialogs/html_message_box.h>
#include <eeschema_settings.h> #include <eeschema_settings.h>
#include <gestfich.h> #include <gestfich.h>
#include <dialogs/html_message_box.h>
#include <i18n_utility.h> // for _HKI definition used in dialog_bom_help_md.h #include <i18n_utility.h> // for _HKI definition used in dialog_bom_help_md.h
#include <invoke_sch_dialog.h> #include <invoke_sch_dialog.h>
#include <kiface_base.h> #include <kiface_base.h>
#include <netlist.h>
#include <netlist_exporter_xml.h> #include <netlist_exporter_xml.h>
#include <paths.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <reporter.h> #include <reporter.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <paths.h> #include <string_utils.h>
#include <wx/filedlg.h> #include <wx/filedlg.h>
#include <wx/log.h> #include <wx/log.h>
@ -341,7 +342,7 @@ void DIALOG_BOM::OnRunGenerator( wxCommandEvent& event )
#endif #endif
if( m_parent->ReadyToNetlist( _( "Generating BOM requires a fully annotated schematic." ) ) ) if( m_parent->ReadyToNetlist( _( "Generating BOM requires a fully annotated schematic." ) ) )
m_parent->WriteNetListFile( -1, fullfilename, GNL_OPT_BOM, &reporter ); m_parent->WriteNetListFile( NET_TYPE_BOM, fullfilename, GNL_OPT_BOM, &reporter );
m_Messages->SetValue( reportmsg ); m_Messages->SetValue( reportmsg );

View File

@ -34,6 +34,7 @@
/// netlist types /// netlist types
enum NETLIST_TYPE_ID { enum NETLIST_TYPE_ID {
NET_TYPE_UNINIT = 0, NET_TYPE_UNINIT = 0,
NET_TYPE_BOM, // Used by the BOM generator
NET_TYPE_PCBNEW, NET_TYPE_PCBNEW,
NET_TYPE_ORCADPCB2, NET_TYPE_ORCADPCB2,
NET_TYPE_CADSTAR, NET_TYPE_CADSTAR,

View File

@ -81,6 +81,15 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
helper = new NETLIST_EXPORTER_PSPICE( sch ); helper = new NETLIST_EXPORTER_PSPICE( sch );
break; break;
case NET_TYPE_BOM:
// When generating the BOM, we have a bare filename so don't strip
// the extension or you might string a '.' from the middle of the filename
fileName += wxT( "." GENERIC_INTERMEDIATE_NETLIST_EXT );
helper = new NETLIST_EXPORTER_XML( sch );
executeCommandLine = true;
break;
default: default:
{ {
wxFileName tmpFile = fileName; wxFileName tmpFile = fileName;