From a411e4bd34ddcd719936f25ce4e044429aed2a15 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Tue, 26 May 2015 17:13:33 +0200 Subject: [PATCH] Fix %O which is broken in eeschema BOM, did not include project directory in path. Add %P which is project dir. --- eeschema/dialogs/dialog_bom.cpp | 3 +-- eeschema/netform.cpp | 10 +++++++--- eeschema/netlist_exporters/netlist_exporter.cpp | 4 +++- eeschema/netlist_exporters/netlist_exporter.h | 7 ++++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 2de179f9a5..e143ab172b 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -383,8 +383,7 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event ) // Calculate the xml netlist filename fn = g_RootSheet->GetScreen()->GetFileName(); - if( fn.GetPath().IsEmpty() ) - fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) ); + fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) ); fn.ClearExt(); wxString fullfilename = fn.GetFullPath(); diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index ab8e584fd7..87420046cb 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -49,7 +49,8 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList bool res = true; bool executeCommandLine = false; - wxString fileName = aFullFileName; + wxString fileName = aFullFileName; + NETLIST_EXPORTER *helper; switch( aFormat ) @@ -93,13 +94,16 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList if( m_netListerCommand.IsEmpty() ) return res; + wxString prj_dir = Prj().GetProjectPath(); + // build full command line from user's format string, e.g.: // "xsltproc -o %O /usr/local/lib/kicad/plugins/netlist_form_pads-pcb.xsl %I" // becomes, after the user selects /tmp/s1.net as the output file from the file dialog: // "xsltproc -o /tmp/s1.net /usr/local/lib/kicad/plugins/netlist_form_pads-pcb.xsl /tmp/s1.xml" wxString commandLine = NETLIST_EXPORTER::MakeCommandLine( m_netListerCommand, - fileName, - aFullFileName ); + fileName, aFullFileName, + prj_dir.SubString( 0, prj_dir.Len() - 2 ) // strip trailing '/' + ); ProcessExecute( commandLine, wxEXEC_SYNC ); } diff --git a/eeschema/netlist_exporters/netlist_exporter.cpp b/eeschema/netlist_exporters/netlist_exporter.cpp index d4bd57dfeb..041f8a0e14 100644 --- a/eeschema/netlist_exporters/netlist_exporter.cpp +++ b/eeschema/netlist_exporters/netlist_exporter.cpp @@ -46,12 +46,13 @@ #include wxString NETLIST_EXPORTER::MakeCommandLine( const wxString& aFormatString, - const wxString& aTempfile, const wxString& aFinalFile ) + const wxString& aTempfile, const wxString& aFinalFile, const wxString& aProjectPath ) { wxString ret = aFormatString; wxFileName in = aTempfile; wxFileName out = aFinalFile; + ret.Replace( wxT( "%P" ), aProjectPath.GetData(), true ); ret.Replace( wxT( "%B" ), out.GetName().GetData(), true ); ret.Replace( wxT( "%I" ), in.GetFullPath().GetData(), true ); ret.Replace( wxT( "%O" ), out.GetFullPath().GetData(), true ); @@ -59,6 +60,7 @@ wxString NETLIST_EXPORTER::MakeCommandLine( const wxString& aFormatString, return ret; } + void NETLIST_EXPORTER::sprintPinNetName( wxString& aResult, const wxString& aNetNameFormat, NETLIST_OBJECT* aPin, bool aUseNetcodeAsNetName ) diff --git a/eeschema/netlist_exporters/netlist_exporter.h b/eeschema/netlist_exporters/netlist_exporter.h index 24e82f804e..81848d6061 100644 --- a/eeschema/netlist_exporters/netlist_exporter.h +++ b/eeschema/netlist_exporters/netlist_exporter.h @@ -192,6 +192,8 @@ public: * external program. * @param aFinalFile is the name of an output file that * the user expects. + * @param aProjectDirectory is used for %P replacement, it should omit + * the trailing '/'. * *

Supported formatting sequences and their meaning: *

*/ static wxString MakeCommandLine( const wxString& aFormatString, - const wxString& aTempfile, const wxString& aFinalFile ); + const wxString& aTempfile, const wxString& aFinalFile, + const wxString& aProjectDirectory + ); }; #endif