28#include <wx/process.h>
29#include <wx/txtstrm.h>
30#include <wx/sstream.h>
31#include <wx/wfstream.h>
36 m_jobsFile( aJobsFile ),
37 m_reporter( aReporter )
67 int result =
static_cast<int>( wxExecute( specialJob->
m_command, wxEXEC_SYNC, &
process ) );
74 wxInputStream* inputStream =
process.GetInputStream();
77 inputStream->Read( procOutput );
98 tmp.AssignDir( wxFileName::GetTempDir() );
99 tmp.AppendDir(
KIID().AsString() );
103 wxString tempDirPath = tmp.GetFullPath();
104 if( !wxFileName::Mkdir( tempDirPath, wxS_DIR_DEFAULT ) )
108 msg = wxString::Format( wxT(
"Failed to create temporary directory %s" ), tempDirPath );
123 msg = wxString::Format( wxT(
"Output precheck failed for output %s" ), aOutput->
m_id );
132 msg += wxT(
"|--------------------------------\n" );
134 msg += wxString::Format(
"Performing jobs" );
136 msg += wxT(
"|--------------------------------\n" );
138 msg += wxString::Format( wxT(
"|%-5s | %-50s\n" ), wxT(
"No." ), wxT(
"Description" ) );
143 msg += wxString::Format( wxT(
"|%-5d | %-50s\n" ), jobNum,
144 job.m_job->GetDescription() );
147 msg += wxT(
"|--------------------------------\n" );
154 std::vector<JOB_OUTPUT> outputs;
158 int successCount = 0;
163 msg = wxT(
"|--------------------------------\n" );
164 msg += wxString::Format( wxT(
"| Running job %d, %s" ), jobNum, job.m_job->GetDescription() );
166 msg += wxT(
"|--------------------------------\n" );
173 job.m_job->SetTempOutputDirectory( tempDirPath );
183 if( job.m_job->GetType() ==
"special_execute" )
187 result =
static_cast<int>( wxExecute( specialJob->
m_command ) );
204 wxString msg_fmt = wxT(
"\033[32;1m%s\033[0m\n" );
205 msg = wxString::Format( msg_fmt,
_(
"Job successful" ) );
211 wxString msg_fmt = wxT(
"\033[31;1m%s\033[0m\n" );
212 msg = wxString::Format( msg_fmt,
_(
"Job failed" ) );
217 msg += wxT(
"\n\n" );
243 msg = wxString::Format( wxT(
"\n\n\033[33;1m%d %s, %d %s\033[0m\n" ),
245 wxT(
"jobs succeeded" ),
247 wxT(
"job failed" ) );
std::vector< JOBSET_JOB > GetJobsForOutput(JOBSET_OUTPUT *aOutput)
std::vector< JOBSET_OUTPUT > & GetOutputs()
virtual bool OutputPrecheck()
Checks if the output process can proceed before doing anything else This can include user prompts.
virtual bool HandleOutputs(const wxString &baseTempPath, const std::vector< JOB_OUTPUT > &aOutputsToHandle)=0
bool RunJobsForOutput(JOBSET_OUTPUT *aOutput, bool aBail=false)
int runSpecialExecute(JOBSET_JOB *aJob)
bool RunJobsAllOutputs(bool aBail=false)
JOBS_RUNNER(KIWAY *aKiway, JOBSET *aJobsFile, REPORTER *aReporter=nullptr)
static KIWAY::FACE_T GetKifaceType(const wxString &aName)
wxString GetFullOutputPath() const
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob)
FACE_T
Known KIFACE implementations.
static REPORTER & GetInstance()
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
static PGM_BASE * process
std::shared_ptr< JOB > m_job
JOBS_OUTPUT_HANDLER * m_outputHandler
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
std::optional< bool > m_lastRunSuccess