From e626136e29c7ce8ca8347345ab8d7758709ddc26 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 9 Oct 2017 20:57:41 +0200 Subject: [PATCH] Eeschema: boom generator: ugly fix on Windows to allow xsltproc.exe working from the command line created from bom dialog. (On windows, xsltproc.exe does not accept '\' in output filename, only '/' like on Unix, so this separator is converted when possible) Minor code cleanup --- eeschema/dialogs/dialog_bom.cpp | 22 ++++++------- eeschema/dialogs/dialog_bom_base.cpp | 14 ++++----- eeschema/dialogs/dialog_bom_base.fbp | 16 +++++----- eeschema/dialogs/dialog_bom_base.h | 4 +-- .../netlist_exporters/netlist_exporter.cpp | 31 +++++++++++++------ eeschema/netlist_exporters/netlist_exporter.h | 8 ++--- 6 files changed, 54 insertions(+), 41 deletions(-) diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index d9dc817ac0..1de3e8d422 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras@wanadoo.fr - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -233,8 +233,8 @@ DIALOG_BOM::DIALOG_BOM( SCH_EDIT_FRAME* parent ) : m_config = Kiface().KifaceSettings(); installPluginsList(); -#ifdef __WINDOWS__ - m_checkBoxShowConsole->Show( true ); +#ifndef __WINDOWS__ + m_checkBoxShowConsole->Show( false ); #endif // Now all widgets have the size fixed, call FinishDialogSettings @@ -545,20 +545,20 @@ wxString DIALOG_BOM::choosePlugin() wxFileName fn( fullFileName ); wxString ext = fn.GetExt(); - if( ext == wxT("xsl" ) ) - cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars( fullFileName ) ); - else if( ext == wxT("exe" ) || ext.IsEmpty() ) - cmdLine.Printf(wxT("\"%s\" < \"%%I\" > \"%%O\""), GetChars( fullFileName ) ); + if( ext == "xsl" ) + cmdLine.Printf( "xsltproc -o \"%%O\" \"%s\" \"%%I\"", GetChars( fullFileName ) ); + else if( ext == "exe" || ext.IsEmpty() ) + cmdLine.Printf( "\"%s\" < \"%%I\" > \"%%O\"", GetChars( fullFileName ) ); else if( ext == wxT("py" ) || ext.IsEmpty() ) - cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars( fullFileName ) ); - else if( ext == wxT("pyw" ) || ext.IsEmpty() ) + cmdLine.Printf( "python \"%s\" \"%%I\" \"%%O\"", GetChars( fullFileName ) ); + else if( ext == "pyw" || ext.IsEmpty() ) #ifdef __WINDOWS__ cmdLine.Printf(wxT("pythonw \"%s\" \"%%I\" \"%%O\""), GetChars( fullFileName ) ); #else - cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars( fullFileName ) ); + cmdLine.Printf( "python \"%s\" \"%%I\" \"%%O\"", GetChars( fullFileName ) ); #endif else - cmdLine.Printf(wxT("\"%s\""), GetChars( fullFileName ) ); + cmdLine.Printf( "\"%s\"", GetChars( fullFileName ) ); return cmdLine; } diff --git a/eeschema/dialogs/dialog_bom_base.cpp b/eeschema/dialogs/dialog_bom_base.cpp index d53d16263a..baf7b0a373 100644 --- a/eeschema/dialogs/dialog_bom_base.cpp +++ b/eeschema/dialogs/dialog_bom_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Mar 22 2016) +// C++ code generated with wxFormBuilder (version Jul 2 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -24,7 +24,7 @@ END_EVENT_TABLE() DIALOG_BOM_BASE::DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + this->SetSizeHints( wxSize( 500,-1 ), wxDefaultSize ); wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); @@ -96,20 +96,20 @@ DIALOG_BOM_BASE::DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id, const wxStrin bbottomSizer->Add( m_textCtrlCommand, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_checkBoxShowConsole = new wxCheckBox( this, wxID_ANY, _("Show console window"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxShowConsole->Hide(); - m_checkBoxShowConsole->SetToolTip( _("By default, command line runs with hidden console window and output is redirected to \"Plugin info\" field. Set this option to show the window of the running command.") ); + m_checkBoxShowConsole->SetValue(true); + m_checkBoxShowConsole->SetToolTip( _("By default, command line runs with hidden console window and output is redirected to \"Plugin info\" field.\nSet this option to show the window of the running command.") ); - bbottomSizer->Add( m_checkBoxShowConsole, 0, wxBOTTOM|wxLEFT, 5 ); + bbottomSizer->Add( m_checkBoxShowConsole, 0, wxALL, 5 ); bMainSizer->Add( bbottomSizer, 0, wxEXPAND, 5 ); m_staticTextInfo = new wxStaticText( this, wxID_ANY, _("Plugin Info:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextInfo->Wrap( -1 ); - bMainSizer->Add( m_staticTextInfo, 0, wxRIGHT|wxLEFT, 5 ); + bMainSizer->Add( m_staticTextInfo, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_Messages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); - bMainSizer->Add( m_Messages, 1, wxALL|wxEXPAND, 5 ); + bMainSizer->Add( m_Messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); this->SetSizer( bMainSizer ); diff --git a/eeschema/dialogs/dialog_bom_base.fbp b/eeschema/dialogs/dialog_bom_base.fbp index 4a7064be63..3faa15f18f 100644 --- a/eeschema/dialogs/dialog_bom_base.fbp +++ b/eeschema/dialogs/dialog_bom_base.fbp @@ -41,10 +41,10 @@ 0 wxID_ANY - + 500,-1 DIALOG_BOM_BASE - 409,393 + 500,397 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Bill of Material @@ -1265,7 +1265,7 @@ 5 - wxBOTTOM|wxLEFT + wxALL 0 1 @@ -1281,7 +1281,7 @@ 1 0 - 0 + 1 1 1 @@ -1294,7 +1294,7 @@ 1 0 - 1 + 0 wxID_ANY Show console window @@ -1317,7 +1317,7 @@ 0 - By default, command line runs with hidden console window and output is redirected to "Plugin info" field. Set this option to show the window of the running command. + By default, command line runs with hidden console window and output is redirected to "Plugin info" field. Set this option to show the window of the running command. wxFILTER_NONE wxDefaultValidator @@ -1355,7 +1355,7 @@ 5 - wxRIGHT|wxLEFT + wxTOP|wxRIGHT|wxLEFT 0 1 @@ -1438,7 +1438,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 1 1 diff --git a/eeschema/dialogs/dialog_bom_base.h b/eeschema/dialogs/dialog_bom_base.h index 9c35265f59..563b74b327 100644 --- a/eeschema/dialogs/dialog_bom_base.h +++ b/eeschema/dialogs/dialog_bom_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Mar 22 2016) +// C++ code generated with wxFormBuilder (version Jul 2 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -94,7 +94,7 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM public: - DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bill of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 409,393 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bill of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,397 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_BOM_BASE(); }; diff --git a/eeschema/netlist_exporters/netlist_exporter.cpp b/eeschema/netlist_exporters/netlist_exporter.cpp index 50f1b1a37c..3f438fe0bc 100644 --- a/eeschema/netlist_exporters/netlist_exporter.cpp +++ b/eeschema/netlist_exporters/netlist_exporter.cpp @@ -48,7 +48,7 @@ wxString NETLIST_EXPORTER::MakeCommandLine( const wxString& aFormatString, - const wxString& aTempfile, const wxString& aFinalFile, const wxString& aProjectPath ) + const wxString& aNetlistFile, const wxString& aFinalFile, const wxString& aProjectPath ) { // Expand format symbols in the command line: // %B => base filename of selected output file, minus path and extension. @@ -56,14 +56,27 @@ wxString NETLIST_EXPORTER::MakeCommandLine( const wxString& aFormatString, // %I => full filename of the input file (the intermediate net file). // %O => complete filename and path (but without extension) of the user chosen output file. - wxString ret = aFormatString; - wxFileName in = aTempfile; - wxFileName out = aFinalFile; + wxString ret = aFormatString; + wxFileName in = aNetlistFile; + 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 ); + ret.Replace( "%P", aProjectPath, true ); + ret.Replace( "%B", out.GetName(), true ); + ret.Replace( "%I", in.GetFullPath(), true ); + +#ifdef __WINDOWS__ + // A ugly hack to run xsltproc that has a serious bug on Window since along time: + // the filename given after -o option (output filename) cannot use '\' in filename + // so replace if by '/' if possible (I mean if the filename does not start by "\\" + // that is a filename on a Windows server) + + wxString str_out = out.GetFullPath(); + + if( !str_out.StartsWith( "\\\\" ) ) + str_out.Replace( "\\", "/" ); +#endif + + ret.Replace( "%O", str_out, true ); return ret; } @@ -84,7 +97,7 @@ void NETLIST_EXPORTER::sprintPinNetName( wxString& aResult, { if( aUseNetcodeAsNetName ) { - aResult.Printf( wxT("%d"), netcode ); + aResult.Printf( "%d", netcode ); } else { diff --git a/eeschema/netlist_exporters/netlist_exporter.h b/eeschema/netlist_exporters/netlist_exporter.h index 233df3ec3d..795cae57c5 100644 --- a/eeschema/netlist_exporters/netlist_exporter.h +++ b/eeschema/netlist_exporters/netlist_exporter.h @@ -209,9 +209,9 @@ public: *
  • formatting sequences, see below. * * - * @param aTempfile is the name of an input file to the - * external program. - * @param aFinalFile is the name of an output file that + * @param aNetlistFile is the name of the input file for the + * external program, that is a intermediate netlist file in xml format. + * @param aFinalFile is the name of the output file that * the user expects. * @param aProjectDirectory is used for %P replacement, it should omit * the trailing '/'. @@ -228,7 +228,7 @@ public: * */ static wxString MakeCommandLine( const wxString& aFormatString, - const wxString& aTempfile, const wxString& aFinalFile, + const wxString& aNetlistFile, const wxString& aFinalFile, const wxString& aProjectDirectory ); };