1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 13:16:21 +02:00

fixed stdout/stderr and exit code, removed old eeschema --plot

This commit is contained in:
Wolfgang Spraul 2011-01-02 17:58:26 +00:00
parent 0f4e2be34d
commit 7f9de6f8bd
4 changed files with 89 additions and 89 deletions

View File

@ -1,6 +1,6 @@
diff -ruN kicad.orig/common/confirm.cpp kicad/common/confirm.cpp diff -ruN kicad.orig/common/confirm.cpp kicad/common/confirm.cpp
--- kicad.orig/common/confirm.cpp 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/common/confirm.cpp 2010-10-19 08:48:07.000000000 +0000
+++ kicad/common/confirm.cpp 2010-12-28 13:58:14.765392001 +0000 +++ kicad/common/confirm.cpp 2011-01-02 13:04:39.339823004 +0000
@@ -66,6 +66,7 @@ @@ -66,6 +66,7 @@
* See not above as to why this doesn't work. */ * See not above as to why this doesn't work. */
} }
@ -36,7 +36,7 @@ diff -ruN kicad.orig/common/confirm.cpp kicad/common/confirm.cpp
diff -ruN kicad.orig/common/edaappl.cpp kicad/common/edaappl.cpp diff -ruN kicad.orig/common/edaappl.cpp kicad/common/edaappl.cpp
--- kicad.orig/common/edaappl.cpp 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/common/edaappl.cpp 2010-10-19 08:48:07.000000000 +0000
+++ kicad/common/edaappl.cpp 2010-12-28 13:58:28.045392001 +0000 +++ kicad/common/edaappl.cpp 2011-01-02 13:04:39.343823004 +0000
@@ -272,6 +272,7 @@ @@ -272,6 +272,7 @@
wxString EnvLang; wxString EnvLang;
@ -45,21 +45,30 @@ diff -ruN kicad.orig/common/edaappl.cpp kicad/common/edaappl.cpp
m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) + m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) +
wxGetUserId() ); wxGetUserId() );
diff -ruN kicad.orig/include/common.h kicad/include/common.h diff -ruN kicad.orig/include/appl_wxstruct.h kicad/include/appl_wxstruct.h
--- kicad.orig/include/common.h 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/include/appl_wxstruct.h 2010-10-19 08:48:07.000000000 +0000
+++ kicad/include/common.h 2010-12-28 13:58:57.861392001 +0000 +++ kicad/include/appl_wxstruct.h 2011-01-02 15:13:47.532837657 +0000
@@ -6,6 +6,8 @@ @@ -32,6 +32,8 @@
#ifndef __INCLUDE__COMMON_H__ /* Class representing the entire Application */
#define __INCLUDE__COMMON_H__ 1 /**********************************************/
+extern bool g_IsScripted; +extern bool g_IsScripted;
+ +
#include "wx/confbase.h" class WinEDA_App : public wxApp
#include "wx/fileconf.h" {
public:
@@ -95,6 +97,8 @@
void InitEDA_Appl( const wxString& aName,
id_app_type aId = APP_TYPE_UNKOWN );
+ virtual int OnRun() { return g_IsScripted ? 0 : wxApp::OnRun(); }
+
bool SetLanguage( bool first_time = FALSE );
/** Function AddMenuLanguageList
diff -ruN kicad.orig/include/wxPcbStruct.h kicad/include/wxPcbStruct.h diff -ruN kicad.orig/include/wxPcbStruct.h kicad/include/wxPcbStruct.h
--- kicad.orig/include/wxPcbStruct.h 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/include/wxPcbStruct.h 2010-10-19 08:48:07.000000000 +0000
+++ kicad/include/wxPcbStruct.h 2010-12-24 11:03:20.674781923 +0000 +++ kicad/include/wxPcbStruct.h 2011-01-02 13:04:39.399823002 +0000
@@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
class WinEDA_PcbFrame : public WinEDA_BasePcbFrame class WinEDA_PcbFrame : public WinEDA_BasePcbFrame
{ {

View File

@ -1,6 +1,6 @@
diff -ruN kicad.orig/eeschema/CMakeLists.txt kicad/eeschema/CMakeLists.txt diff -ruN kicad.orig/eeschema/CMakeLists.txt kicad/eeschema/CMakeLists.txt
--- kicad.orig/eeschema/CMakeLists.txt 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/eeschema/CMakeLists.txt 2010-10-19 08:48:07.000000000 +0000
+++ kicad/eeschema/CMakeLists.txt 2010-12-28 13:43:28.365392001 +0000 +++ kicad/eeschema/CMakeLists.txt 2011-01-02 13:06:41.627823067 +0000
@@ -83,6 +83,7 @@ @@ -83,6 +83,7 @@
eeredraw.cpp eeredraw.cpp
eeschema.cpp eeschema.cpp
@ -11,7 +11,7 @@ diff -ruN kicad.orig/eeschema/CMakeLists.txt kicad/eeschema/CMakeLists.txt
files-io.cpp files-io.cpp
diff -ruN kicad.orig/eeschema/dialog_build_BOM.h kicad/eeschema/dialog_build_BOM.h diff -ruN kicad.orig/eeschema/dialog_build_BOM.h kicad/eeschema/dialog_build_BOM.h
--- kicad.orig/eeschema/dialog_build_BOM.h 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/eeschema/dialog_build_BOM.h 2010-10-19 08:48:07.000000000 +0000
+++ kicad/eeschema/dialog_build_BOM.h 2010-12-29 14:53:53.210259002 +0000 +++ kicad/eeschema/dialog_build_BOM.h 2011-01-02 13:06:41.627823067 +0000
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE
@ -22,7 +22,7 @@ diff -ruN kicad.orig/eeschema/dialog_build_BOM.h kicad/eeschema/dialog_build_BOM
wxConfig* m_Config; wxConfig* m_Config;
diff -ruN kicad.orig/eeschema/dialog_erc.h kicad/eeschema/dialog_erc.h diff -ruN kicad.orig/eeschema/dialog_erc.h kicad/eeschema/dialog_erc.h
--- kicad.orig/eeschema/dialog_erc.h 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/eeschema/dialog_erc.h 2010-10-19 08:48:07.000000000 +0000
+++ kicad/eeschema/dialog_erc.h 2010-12-29 15:45:04.002259005 +0000 +++ kicad/eeschema/dialog_erc.h 2011-01-02 13:06:41.631823036 +0000
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
class DIALOG_ERC : public DIALOG_ERC_BASE class DIALOG_ERC : public DIALOG_ERC_BASE
@ -33,7 +33,7 @@ diff -ruN kicad.orig/eeschema/dialog_erc.h kicad/eeschema/dialog_erc.h
private: private:
diff -ruN kicad.orig/eeschema/dialog_SVG_print.cpp kicad/eeschema/dialog_SVG_print.cpp diff -ruN kicad.orig/eeschema/dialog_SVG_print.cpp kicad/eeschema/dialog_SVG_print.cpp
--- kicad.orig/eeschema/dialog_SVG_print.cpp 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/eeschema/dialog_SVG_print.cpp 2010-10-19 08:48:07.000000000 +0000
+++ kicad/eeschema/dialog_SVG_print.cpp 2010-12-31 14:59:18.871823000 +0000 +++ kicad/eeschema/dialog_SVG_print.cpp 2011-01-02 13:06:41.631823036 +0000
@@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
@ -63,8 +63,8 @@ diff -ruN kicad.orig/eeschema/dialog_SVG_print.cpp kicad/eeschema/dialog_SVG_pri
/* Prepare the data structures of print management and display the dialog /* Prepare the data structures of print management and display the dialog
* window for printing sheets. * window for printing sheets.
diff -ruN kicad.orig/eeschema/eeschema.cpp kicad/eeschema/eeschema.cpp diff -ruN kicad.orig/eeschema/eeschema.cpp kicad/eeschema/eeschema.cpp
--- kicad.orig/eeschema/eeschema.cpp 2010-12-28 15:30:43.309392002 +0000 --- kicad.orig/eeschema/eeschema.cpp 2010-10-19 08:48:07.000000000 +0000
+++ kicad/eeschema/eeschema.cpp 2010-12-28 15:38:23.073392001 +0000 +++ kicad/eeschema/eeschema.cpp 2011-01-02 16:55:25.188837657 +0000
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
@ -77,15 +77,15 @@ diff -ruN kicad.orig/eeschema/eeschema.cpp kicad/eeschema/eeschema.cpp
g_DebugLevel = 0; // Debug level */ g_DebugLevel = 0; // Debug level */
+ if ( g_EESchemaScripted.Run() ) + if ( argc >= 2 && argv[1][0] == '-' )
+ return false; + return g_EESchemaScripted.Run();
+ +
InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA ); InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA );
if( m_Checker && m_Checker->IsAnotherRunning() ) if( m_Checker && m_Checker->IsAnotherRunning() )
diff -ruN kicad.orig/eeschema/erc.cpp kicad/eeschema/erc.cpp diff -ruN kicad.orig/eeschema/erc.cpp kicad/eeschema/erc.cpp
--- kicad.orig/eeschema/erc.cpp 2010-12-31 18:11:47.751823001 +0000 --- kicad.orig/eeschema/erc.cpp 2011-01-02 17:35:54.236837659 +0000
+++ kicad/eeschema/erc.cpp 2010-12-29 15:43:01.970259008 +0000 +++ kicad/eeschema/erc.cpp 2011-01-02 13:06:41.631823036 +0000
@@ -557,6 +557,7 @@ @@ -557,6 +557,7 @@
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->m_AssociatedScreen->m_FileName;
fn.SetExt( wxT( "erc" ) ); fn.SetExt( wxT( "erc" ) );
@ -94,7 +94,7 @@ diff -ruN kicad.orig/eeschema/erc.cpp kicad/eeschema/erc.cpp
wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(), wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(),
_( "Electronic rule check file (.erc)|*.erc" ), _( "Electronic rule check file (.erc)|*.erc" ),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
@@ -570,6 +570,8 @@ @@ -570,6 +571,8 @@
ExecuteFile( this, wxGetApp().GetEditorName(), ExecuteFile( this, wxGetApp().GetEditorName(),
QuoteFullPath( fn ) ); QuoteFullPath( fn ) );
} }

View File

@ -1,7 +1,7 @@
diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scripted.cpp diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scripted.cpp
--- kicad.orig/eeschema/eeschema_scripted.cpp 1970-01-01 00:00:00.000000000 +0000 --- kicad.orig/eeschema/eeschema_scripted.cpp 1970-01-01 00:00:00.000000000 +0000
+++ kicad/eeschema/eeschema_scripted.cpp 2010-12-31 18:03:37.871822958 +0000 +++ kicad/eeschema/eeschema_scripted.cpp 2011-01-02 17:25:27.428837658 +0000
@@ -0,0 +1,251 @@ @@ -0,0 +1,237 @@
+///////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////
+// Name: eeschema_scripted.cpp +// Name: eeschema_scripted.cpp
+// Copyright: Werner Almesberger, Wolfgang Spraul +// Copyright: Werner Almesberger, Wolfgang Spraul
@ -34,11 +34,10 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scri
+ +
+ { wxCMD_LINE_SWITCH, wxT("l"), wxT("list-sheets"), wxT("list schematics pages") }, + { wxCMD_LINE_SWITCH, wxT("l"), wxT("list-sheets"), wxT("list schematics pages") },
+ +
+ { wxCMD_LINE_OPTION, wxT("px"), wxT("plotx"), wxT("plots the board [ps|svg|dxf]"), + { wxCMD_LINE_OPTION, wxT("p"), wxT("plot"), wxT("plots the board [ps|svg|dxf]"),
+ wxCMD_LINE_VAL_STRING }, + wxCMD_LINE_VAL_STRING },
+ { wxCMD_LINE_SWITCH, wxT("plotx-bw"), wxT("plotx-bw"), wxT("plot: black & white (default: color)") }, + { wxCMD_LINE_SWITCH, wxT("plot-bw"), wxT("plot-bw"), wxT("plot: black & white (default: color)") },
+ { wxCMD_LINE_SWITCH, wxT("plotx-sheetref"), wxT("plotx-sheetref"), wxT("plot: print sheet reference (default: off)") }, + { wxCMD_LINE_SWITCH, wxT("plot-sheetref"), wxT("plot-sheetref"), wxT("plot: print sheet reference (default: off)") },
+ { wxCMD_LINE_SWITCH, wxT("p"), wxT("plot"), wxT("plots the schematics (deprecated, use --plotx=ps --plotx-bw)") },
+ +
+ { wxCMD_LINE_SWITCH, wxT("b"), wxT("bom"), wxT("generate bill of materials (.bom)") }, + { wxCMD_LINE_SWITCH, wxT("b"), wxT("bom"), wxT("generate bill of materials (.bom)") },
+ { wxCMD_LINE_SWITCH, wxT("e"), wxT("erc"), wxT("generate electric rules check (.erc) file") }, + { wxCMD_LINE_SWITCH, wxT("e"), wxT("erc"), wxT("generate electric rules check (.erc) file") },
@ -62,8 +61,6 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scri
+ int i; + int i;
+ +
+ WinEDA_App& app = wxGetApp(); + WinEDA_App& app = wxGetApp();
+ if (app.argc < 2 || app.argv[1][0] != '-')
+ return false;
+ g_IsScripted = true; + g_IsScripted = true;
+ wxLog::EnableLogging(false); // this should suppress some wx dialogs + wxLog::EnableLogging(false); // this should suppress some wx dialogs
+ app.InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA ); + app.InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA );
@ -72,23 +69,22 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scri
+ parser.SetDesc(g_cmdLineDesc); + parser.SetDesc(g_cmdLineDesc);
+ parser.SetCmdLine(app.argc, app.argv); + parser.SetCmdLine(app.argc, app.argv);
+ if (parser.Parse()) + if (parser.Parse())
+ return true; + return false;
+ +
+ i = parser.Found( _("list-sheets") ) + i = parser.Found( _("list-sheets") )
+ + parser.Found( _("plot") ) + + parser.Found( _("plot") )
+ + parser.Found( _("plotx") )
+ + parser.Found( _("bom") ) + + parser.Found( _("bom") )
+ + parser.Found( _("erc") ) + + parser.Found( _("erc") )
+ + parser.Found( _("netlist") ); + + parser.Found( _("netlist") );
+ if ( !i ) + if ( !i )
+ { + {
+ wxPrintf(wxT("One of --list-sheets --plot --plotx --bom --erc --netlist must be given.\n")); + wxFprintf( stderr, wxT("One of --list-sheets --plot --bom --erc --netlist must be given.\n"));
+ return true; + return false;
+ } + }
+ if ( i > 1 ) + if ( i > 1 )
+ { + {
+ wxPrintf(wxT("Only one of --list-sheets --plot --plotx --bom --erc --netlist may be given at a time.\n")); + wxFprintf( stderr, wxT("Only one of --list-sheets --plot --bom --erc --netlist may be given at a time.\n"));
+ return true; + return false;
+ } + }
+ +
+ // parse plotting parameters + // parse plotting parameters
@ -102,14 +98,7 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scri
+ bool PlotSheetRef; + bool PlotSheetRef;
+ +
+ PlotCmd = PLOT_NONE; + PlotCmd = PLOT_NONE;
+ if ( parser.Found( wxT("plot") ) ) // legacy parameter originally introduced by + if ( parser.Found( _("plot"), &str ) )
+ // Werner, still used in schhist and other places
+ {
+ PlotCmd = PLOT_PS;
+ PlotBW = true;
+ PlotSheetRef = false;
+ }
+ else if ( parser.Found( _("plotx"), &str ) )
+ { + {
+ if (!str.CmpNoCase( wxT("ps") ) ) + if (!str.CmpNoCase( wxT("ps") ) )
+ PlotCmd = PLOT_PS; + PlotCmd = PLOT_PS;
@ -119,12 +108,11 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scri
+ PlotCmd = PLOT_DXF; + PlotCmd = PLOT_DXF;
+ else + else
+ { + {
+ parser.Usage(); + wxFprintf( stderr, wxT("Unexpected plot format '%ls'.\n"), str.c_str());
+ wxPrintf(wxT("Unexpected plot format '%ls'.\n"), str.c_str()); + return false;
+ return true;
+ } + }
+ PlotBW = parser.Found( _("plotx-bw") ); + PlotBW = parser.Found( _("plot-bw") );
+ PlotSheetRef = parser.Found( _("plotx-sheetref") ); + PlotSheetRef = parser.Found( _("plot-sheetref") );
+ } + }
+ +
+ fn = parser.GetParam(); + fn = parser.GetParam();
@ -135,8 +123,8 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scri
+ } + }
+ if( !fn.FileExists()) + if( !fn.FileExists())
+ { + {
+ wxPrintf( wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() ); + wxFprintf( stderr, wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() );
+ return true; + return false;
+ } + }
+ wxSetWorkingDirectory( fn.GetPath() ); + wxSetWorkingDirectory( fn.GetPath() );
+ +
@ -145,14 +133,14 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scri
+ frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ), + frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ),
+ wxPoint( 0, 0 ), wxSize( 600, 400 ) ); + wxPoint( 0, 0 ), wxSize( 600, 400 ) );
+ ActiveScreen = frame->GetScreen(); + ActiveScreen = frame->GetScreen();
+#if 0 // enable this to see more of the GUI
+ app.SetTopWindow( frame ); + app.SetTopWindow( frame );
+#if 0 // enable this to see more of the GUI
+ frame->Show( true ); + frame->Show( true );
+#endif +#endif
+ if( !frame->LoadOneEEProject( fn.GetFullPath(), false ) ) + if( !frame->LoadOneEEProject( fn.GetFullPath(), false ) )
+ { + {
+ fprintf( stderr, "%ls: can't load\n", fn.GetFullPath().c_str() ); + wxFprintf( stderr, fn.GetFullPath() + _(": can't load\n") );
+ return true; + return false;
+ } + }
+ +
+ if ( parser.Found( wxT("list-sheets") ) ) // class_drawsheetpath.h + if ( parser.Found( wxT("list-sheets") ) ) // class_drawsheetpath.h
@ -249,13 +237,11 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scri
+ fn.SetExt( wxT( "net" ) ); + fn.SetExt( wxT( "net" ) );
+ frame->WriteNetListFile( NET_TYPE_PCBNEW /* aFormat */, fn.GetFullPath(), false /* aUse_netnames - only used for Spice */ ); + frame->WriteNetListFile( NET_TYPE_PCBNEW /* aFormat */, fn.GetFullPath(), false /* aUse_netnames - only used for Spice */ );
+ } + }
+
+ delete frame;
+ return true; + return true;
+} +}
diff -ruN kicad.orig/eeschema/eeschema_scripted.h kicad/eeschema/eeschema_scripted.h diff -ruN kicad.orig/eeschema/eeschema_scripted.h kicad/eeschema/eeschema_scripted.h
--- kicad.orig/eeschema/eeschema_scripted.h 1970-01-01 00:00:00.000000000 +0000 --- kicad.orig/eeschema/eeschema_scripted.h 1970-01-01 00:00:00.000000000 +0000
+++ kicad/eeschema/eeschema_scripted.h 2010-12-29 15:09:05.802259004 +0000 +++ kicad/eeschema/eeschema_scripted.h 2011-01-02 13:10:04.267823004 +0000
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
+///////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////
+// Name: eeschema_scripted.h +// Name: eeschema_scripted.h
@ -273,8 +259,8 @@ diff -ruN kicad.orig/eeschema/eeschema_scripted.h kicad/eeschema/eeschema_script
+extern EESCHEMA_SCRIPTED g_EESchemaScripted; +extern EESCHEMA_SCRIPTED g_EESchemaScripted;
diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
--- kicad.orig/pcbnew/pcbnew_scripted.cpp 1970-01-01 00:00:00.000000000 +0000 --- kicad.orig/pcbnew/pcbnew_scripted.cpp 1970-01-01 00:00:00.000000000 +0000
+++ kicad/pcbnew/pcbnew_scripted.cpp 2010-12-28 13:58:44.257392001 +0000 +++ kicad/pcbnew/pcbnew_scripted.cpp 2011-01-02 17:30:48.624837659 +0000
@@ -0,0 +1,552 @@ @@ -0,0 +1,546 @@
+///////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////
+// Name: pcbnew_scripted.cpp +// Name: pcbnew_scripted.cpp
+// Copyright: Wolfgang Spraul +// Copyright: Wolfgang Spraul
@ -355,8 +341,6 @@ diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
+ int i; + int i;
+ +
+ WinEDA_App& app = wxGetApp(); + WinEDA_App& app = wxGetApp();
+ if (app.argc < 2 || app.argv[1][0] != '-')
+ return false;
+ g_IsScripted = true; + g_IsScripted = true;
+ wxLog::EnableLogging(false); // this should suppress some wx dialogs + wxLog::EnableLogging(false); // this should suppress some wx dialogs
+ app.InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW ); + app.InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW );
@ -365,15 +349,14 @@ diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
+ parser.SetDesc(g_cmdLineDesc); + parser.SetDesc(g_cmdLineDesc);
+ parser.SetCmdLine(app.argc, app.argv); + parser.SetCmdLine(app.argc, app.argv);
+ if (parser.Parse()) + if (parser.Parse())
+ return true; + return false;
+ if ( parser.Found( wxT("ps-pads-drill-opt"), &str ) + if ( parser.Found( wxT("ps-pads-drill-opt"), &str )
+ && str.CmpNoCase( wxT("none") ) + && str.CmpNoCase( wxT("none") )
+ && str.CmpNoCase( wxT("small") ) + && str.CmpNoCase( wxT("small") )
+ && str.CmpNoCase( wxT("real") )) + && str.CmpNoCase( wxT("real") ))
+ { + {
+ parser.Usage(); + wxFprintf( stderr, wxT("Unexpected pads drill option '%ls'.\n"), str.c_str());
+ wxPrintf(wxT("Unexpected pads drill option '%ls'.\n"), str.c_str()); + return false;
+ return true;
+ } + }
+ i = parser.Found( _("drill") ) + i = parser.Found( _("drill") )
+ + parser.Found( _("list-layers") ) + + parser.Found( _("list-layers") )
@ -386,13 +369,13 @@ diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
+ + parser.Found( _("vrml") ); + + parser.Found( _("vrml") );
+ if ( !i ) + if ( !i )
+ { + {
+ wxPrintf(wxT("One of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml must be given.\n")); + wxFprintf( stderr, wxT("One of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml must be given.\n"));
+ return true; + return false;
+ } + }
+ if ( i > 1 ) + if ( i > 1 )
+ { + {
+ wxPrintf(wxT("Only one of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml may be given at a time.\n")); + wxFprintf( stderr, wxT("Only one of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml may be given at a time.\n"));
+ return true; + return false;
+ } + }
+ +
+ fn = parser.GetParam(); + fn = parser.GetParam();
@ -403,8 +386,8 @@ diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
+ } + }
+ if( !fn.FileExists()) + if( !fn.FileExists())
+ { + {
+ wxPrintf( wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() ); + wxFprintf( stderr, wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() );
+ exit(0); + return false;
+ } + }
+ wxSetWorkingDirectory( fn.GetPath() ); + wxSetWorkingDirectory( fn.GetPath() );
+ +
@ -415,9 +398,9 @@ diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
+ +
+ g_DrawBgColor = BLACK; + g_DrawBgColor = BLACK;
+ frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); + frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );
+ app.SetTopWindow( frame );
+ +
+#if 0 // enable this to see more of the GUI +#if 0 // enable this to see more of the GUI
+ app.SetTopWindow( frame );
+ frame->Show( true ); + frame->Show( true );
+ frame->Zoom_Automatique( true ); + frame->Zoom_Automatique( true );
+#endif +#endif
@ -479,9 +462,8 @@ diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
+ } + }
+ else + else
+ { + {
+ parser.Usage(); + wxFprintf( stderr, wxT("Unexpected plot type '%ls'.\n"), str.c_str());
+ wxPrintf(wxT("Unexpected plot type '%ls'.\n"), str.c_str()); + return false;
+ exit(0);
+ } + }
+ +
+ // --ps-pads-drill-opt + // --ps-pads-drill-opt
@ -495,9 +477,8 @@ diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
+ g_pcb_plot_options.DrillShapeOpt = PCB_Plot_Options::FULL_DRILL_SHAPE; + g_pcb_plot_options.DrillShapeOpt = PCB_Plot_Options::FULL_DRILL_SHAPE;
+ else + else
+ { + {
+ parser.Usage(); + wxFprintf( stderr, wxT("Unexpected Postscript pads drill option '%ls'.\n"), str.c_str());
+ wxPrintf(wxT("Unexpected Postscript pads drill option '%ls'.\n"), str.c_str()); + return false;
+ exit(0);
+ } + }
+ } + }
+ +
@ -824,12 +805,11 @@ diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp
+ wxMkdir( subDirFor3Dshapes ); + wxMkdir( subDirFor3Dshapes );
+ frame->ExportVRML_File( fn.GetFullPath(), 1.0 /* aScale */, true /* aExport3DFile */, subDirFor3Dshapes ); + frame->ExportVRML_File( fn.GetFullPath(), 1.0 /* aScale */, true /* aExport3DFile */, subDirFor3Dshapes );
+ } + }
+ delete frame;
+ return true; + return true;
+} +}
diff -ruN kicad.orig/pcbnew/pcbnew_scripted.h kicad/pcbnew/pcbnew_scripted.h diff -ruN kicad.orig/pcbnew/pcbnew_scripted.h kicad/pcbnew/pcbnew_scripted.h
--- kicad.orig/pcbnew/pcbnew_scripted.h 1970-01-01 00:00:00.000000000 +0000 --- kicad.orig/pcbnew/pcbnew_scripted.h 1970-01-01 00:00:00.000000000 +0000
+++ kicad/pcbnew/pcbnew_scripted.h 2010-12-22 18:47:58.774932729 +0000 +++ kicad/pcbnew/pcbnew_scripted.h 2011-01-02 13:10:04.267823004 +0000
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
+///////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////
+// Name: pcbnew_scripted.h +// Name: pcbnew_scripted.h

View File

@ -1,6 +1,6 @@
diff -ruN kicad.orig/pcbnew/build_BOM_from_board.cpp kicad/pcbnew/build_BOM_from_board.cpp diff -ruN kicad.orig/pcbnew/build_BOM_from_board.cpp kicad/pcbnew/build_BOM_from_board.cpp
--- kicad.orig/pcbnew/build_BOM_from_board.cpp 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/pcbnew/build_BOM_from_board.cpp 2010-10-19 08:48:07.000000000 +0000
+++ kicad/pcbnew/build_BOM_from_board.cpp 2010-12-28 13:59:39.089392001 +0000 +++ kicad/pcbnew/build_BOM_from_board.cpp 2011-01-02 16:02:51.792837658 +0000
@@ -64,6 +64,7 @@ @@ -64,6 +64,7 @@
fn = GetScreen()->m_FileName; fn = GetScreen()->m_FileName;
fn.SetExt( CsvFileExtension ); fn.SetExt( CsvFileExtension );
@ -19,7 +19,7 @@ diff -ruN kicad.orig/pcbnew/build_BOM_from_board.cpp kicad/pcbnew/build_BOM_from
diff -ruN kicad.orig/pcbnew/CMakeLists.txt kicad/pcbnew/CMakeLists.txt diff -ruN kicad.orig/pcbnew/CMakeLists.txt kicad/pcbnew/CMakeLists.txt
--- kicad.orig/pcbnew/CMakeLists.txt 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/pcbnew/CMakeLists.txt 2010-10-19 08:48:07.000000000 +0000
+++ kicad/pcbnew/CMakeLists.txt 2010-12-22 02:19:48.597291239 +0000 +++ kicad/pcbnew/CMakeLists.txt 2011-01-02 13:04:39.451823002 +0000
@@ -142,6 +142,7 @@ @@ -142,6 +142,7 @@
onrightclick.cpp onrightclick.cpp
pcbnew.cpp pcbnew.cpp
@ -30,7 +30,7 @@ diff -ruN kicad.orig/pcbnew/CMakeLists.txt kicad/pcbnew/CMakeLists.txt
plothpgl.cpp plothpgl.cpp
diff -ruN kicad.orig/pcbnew/dialog_gendrill.h kicad/pcbnew/dialog_gendrill.h diff -ruN kicad.orig/pcbnew/dialog_gendrill.h kicad/pcbnew/dialog_gendrill.h
--- kicad.orig/pcbnew/dialog_gendrill.h 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/pcbnew/dialog_gendrill.h 2010-10-19 08:48:07.000000000 +0000
+++ kicad/pcbnew/dialog_gendrill.h 2010-12-22 18:23:00.054932711 +0000 +++ kicad/pcbnew/dialog_gendrill.h 2011-01-02 13:04:39.459823002 +0000
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
class DIALOG_GENDRILL: public DIALOG_GENDRILL_BASE class DIALOG_GENDRILL: public DIALOG_GENDRILL_BASE
@ -41,7 +41,7 @@ diff -ruN kicad.orig/pcbnew/dialog_gendrill.h kicad/pcbnew/dialog_gendrill.h
WinEDA_PcbFrame* m_Parent; WinEDA_PcbFrame* m_Parent;
diff -ruN kicad.orig/pcbnew/drc_stuff.h kicad/pcbnew/drc_stuff.h diff -ruN kicad.orig/pcbnew/drc_stuff.h kicad/pcbnew/drc_stuff.h
--- kicad.orig/pcbnew/drc_stuff.h 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/pcbnew/drc_stuff.h 2010-10-19 08:48:07.000000000 +0000
+++ kicad/pcbnew/drc_stuff.h 2010-12-24 10:01:41.438781921 +0000 +++ kicad/pcbnew/drc_stuff.h 2011-01-02 13:04:39.507823003 +0000
@@ -136,6 +136,7 @@ @@ -136,6 +136,7 @@
class DRC class DRC
{ {
@ -52,7 +52,7 @@ diff -ruN kicad.orig/pcbnew/drc_stuff.h kicad/pcbnew/drc_stuff.h
diff -ruN kicad.orig/pcbnew/gendrill.cpp kicad/pcbnew/gendrill.cpp diff -ruN kicad.orig/pcbnew/gendrill.cpp kicad/pcbnew/gendrill.cpp
--- kicad.orig/pcbnew/gendrill.cpp 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/pcbnew/gendrill.cpp 2010-10-19 08:48:07.000000000 +0000
+++ kicad/pcbnew/gendrill.cpp 2010-12-28 13:59:29.321392003 +0000 +++ kicad/pcbnew/gendrill.cpp 2011-01-02 13:04:39.515823004 +0000
@@ -307,6 +307,43 @@ @@ -307,6 +307,43 @@
fn.SetName( fn.GetName() + layer_extend ); fn.SetName( fn.GetName() + layer_extend );
fn.SetExt( DrillFileExtension ); fn.SetExt( DrillFileExtension );
@ -107,7 +107,7 @@ diff -ruN kicad.orig/pcbnew/gendrill.cpp kicad/pcbnew/gendrill.cpp
break; break;
diff -ruN kicad.orig/pcbnew/pcbnew.cpp kicad/pcbnew/pcbnew.cpp diff -ruN kicad.orig/pcbnew/pcbnew.cpp kicad/pcbnew/pcbnew.cpp
--- kicad.orig/pcbnew/pcbnew.cpp 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/pcbnew/pcbnew.cpp 2010-10-19 08:48:07.000000000 +0000
+++ kicad/pcbnew/pcbnew.cpp 2010-12-28 09:18:32.577470003 +0000 +++ kicad/pcbnew/pcbnew.cpp 2011-01-02 17:27:41.612837657 +0000
@@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
#include "build_version.h" #include "build_version.h"
@ -120,15 +120,26 @@ diff -ruN kicad.orig/pcbnew/pcbnew.cpp kicad/pcbnew/pcbnew.cpp
wxFileName fn; wxFileName fn;
WinEDA_PcbFrame* frame = NULL; WinEDA_PcbFrame* frame = NULL;
+ if( Pcbnew_Scripted() ) + if ( argc >= 2 && argv[1][0] == '-' )
+ return false; + return Pcbnew_Scripted();
+ +
InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW ); InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW );
if( m_Checker && m_Checker->IsAnotherRunning() ) if( m_Checker && m_Checker->IsAnotherRunning() )
diff -ruN kicad.orig/pcbnew/pcbnew.h kicad/pcbnew/pcbnew.h
--- kicad.orig/pcbnew/pcbnew.h 2010-10-19 08:48:07.000000000 +0000
+++ kicad/pcbnew/pcbnew.h 2011-01-02 16:02:38.324837657 +0000
@@ -59,6 +59,7 @@
extern const wxString g_FootprintLibFileWildcard; // Wildcard for footprint libraries filesnames
+extern bool g_IsScripted;
extern bool g_Track_45_Only_Allowed;
extern bool g_Alternate_Track_Posture;
diff -ruN kicad.orig/pcbnew/xchgmod.cpp kicad/pcbnew/xchgmod.cpp diff -ruN kicad.orig/pcbnew/xchgmod.cpp kicad/pcbnew/xchgmod.cpp
--- kicad.orig/pcbnew/xchgmod.cpp 2010-10-19 08:48:07.000000000 +0000 --- kicad.orig/pcbnew/xchgmod.cpp 2010-10-19 08:48:07.000000000 +0000
+++ kicad/pcbnew/xchgmod.cpp 2010-12-28 13:59:06.985392003 +0000 +++ kicad/pcbnew/xchgmod.cpp 2011-01-02 13:04:39.551823004 +0000
@@ -577,6 +577,7 @@ @@ -577,6 +577,7 @@
wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) +
NetCmpExtBuffer; NetCmpExtBuffer;