Fix %O which is broken in eeschema BOM, did not include project directory in path. Add %P which is project dir.

This commit is contained in:
Dick Hollenbeck 2015-05-26 17:13:33 +02:00 committed by Maciej Suminski
parent 60bcbba585
commit a411e4bd34
4 changed files with 17 additions and 7 deletions

View File

@ -383,8 +383,7 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event )
// Calculate the xml netlist filename // Calculate the xml netlist filename
fn = g_RootSheet->GetScreen()->GetFileName(); fn = g_RootSheet->GetScreen()->GetFileName();
if( fn.GetPath().IsEmpty() ) fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
fn.ClearExt(); fn.ClearExt();
wxString fullfilename = fn.GetFullPath(); wxString fullfilename = fn.GetFullPath();

View File

@ -49,7 +49,8 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList
bool res = true; bool res = true;
bool executeCommandLine = false; bool executeCommandLine = false;
wxString fileName = aFullFileName; wxString fileName = aFullFileName;
NETLIST_EXPORTER *helper; NETLIST_EXPORTER *helper;
switch( aFormat ) switch( aFormat )
@ -93,13 +94,16 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList
if( m_netListerCommand.IsEmpty() ) if( m_netListerCommand.IsEmpty() )
return res; return res;
wxString prj_dir = Prj().GetProjectPath();
// build full command line from user's format string, e.g.: // 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" // "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: // 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" // "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, wxString commandLine = NETLIST_EXPORTER::MakeCommandLine( m_netListerCommand,
fileName, fileName, aFullFileName,
aFullFileName ); prj_dir.SubString( 0, prj_dir.Len() - 2 ) // strip trailing '/'
);
ProcessExecute( commandLine, wxEXEC_SYNC ); ProcessExecute( commandLine, wxEXEC_SYNC );
} }

View File

@ -46,12 +46,13 @@
#include <netlist_exporter.h> #include <netlist_exporter.h>
wxString NETLIST_EXPORTER::MakeCommandLine( const wxString& aFormatString, 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; wxString ret = aFormatString;
wxFileName in = aTempfile; wxFileName in = aTempfile;
wxFileName out = aFinalFile; wxFileName out = aFinalFile;
ret.Replace( wxT( "%P" ), aProjectPath.GetData(), true );
ret.Replace( wxT( "%B" ), out.GetName().GetData(), true ); ret.Replace( wxT( "%B" ), out.GetName().GetData(), true );
ret.Replace( wxT( "%I" ), in.GetFullPath().GetData(), true ); ret.Replace( wxT( "%I" ), in.GetFullPath().GetData(), true );
ret.Replace( wxT( "%O" ), out.GetFullPath().GetData(), true ); ret.Replace( wxT( "%O" ), out.GetFullPath().GetData(), true );
@ -59,6 +60,7 @@ wxString NETLIST_EXPORTER::MakeCommandLine( const wxString& aFormatString,
return ret; return ret;
} }
void NETLIST_EXPORTER::sprintPinNetName( wxString& aResult, void NETLIST_EXPORTER::sprintPinNetName( wxString& aResult,
const wxString& aNetNameFormat, NETLIST_OBJECT* aPin, const wxString& aNetNameFormat, NETLIST_OBJECT* aPin,
bool aUseNetcodeAsNetName ) bool aUseNetcodeAsNetName )

View File

@ -192,6 +192,8 @@ public:
* external program. * external program.
* @param aFinalFile is the name of an output file that * @param aFinalFile is the name of an output file that
* the user expects. * the user expects.
* @param aProjectDirectory is used for %P replacement, it should omit
* the trailing '/'.
* *
* <p> Supported formatting sequences and their meaning: * <p> Supported formatting sequences and their meaning:
* <ul> * <ul>
@ -201,10 +203,13 @@ public:
* input file. * input file.
* <li> %O => complete filename and path of the user chosen * <li> %O => complete filename and path of the user chosen
* output file. * output file.
* <li> %P => project directory, without name and without trailing '/'
* </ul> * </ul>
*/ */
static wxString MakeCommandLine( const wxString& aFormatString, static wxString MakeCommandLine( const wxString& aFormatString,
const wxString& aTempfile, const wxString& aFinalFile ); const wxString& aTempfile, const wxString& aFinalFile,
const wxString& aProjectDirectory
);
}; };
#endif #endif