31#include <wx/process.h>
32#include <wx/txtstrm.h>
33#include <wx/sstream.h>
34#include <wx/wfstream.h>
40 m_jobsFile( aJobsFile ),
41 m_reporter( aReporter ),
42 m_progressReporter( aProgressReporter ),
68 int result =
static_cast<int>( wxExecute( cmd, wxEXEC_SYNC, &
process ) );
74 wxFileName fn( aJob->
m_id );
75 fn.SetExt( wxT(
"log" ) );
81 if( !procOutput.IsOk() )
84 wxInputStream* inputStream =
process.GetInputStream();
87 inputStream->Read( procOutput );
105 if( source.IsEmpty() )
109 wxFileName sourceFn( source );
110 sourceFn.MakeAbsolute( projectPath );
114 if( !job->
m_dest.IsEmpty() )
115 destFn.AppendDir( job->
m_dest );
117 std::vector<wxString> exclusions;
120 exclusions.push_back( projectPath + destination.m_outputHandler->GetOutputPath() );
125 errors, copyCount, exclusions );
149 wxString
text( aText );
175 bool genOutputs =
true;
181 tmp.AssignDir( wxFileName::GetTempDir() );
182 tmp.AppendDir(
KIID().AsString() );
191 wxString tempDirPath = tmp.GetFullPath();
193 if( !wxFileName::Mkdir( tempDirPath, wxS_DIR_DEFAULT ) )
195 msg = wxString::Format( wxT(
"Failed to create temporary directory %s" ), tempDirPath );
207 msg = wxString::Format( wxT(
"Destination precheck failed for destination %s" ),
208 aDestination->
m_id );
215 msg += wxT(
"|--------------------------------\n" );
217 msg += wxString::Format( wxT(
"Running jobs for destination %s" ), aDestination->
m_id );
219 msg += wxT(
"|--------------------------------\n" );
221 msg += wxString::Format( wxT(
"|%-5s | %-50s\n" ), wxT(
"No." ), wxT(
"Description" ) );
225 for(
const JOBSET_JOB& job : jobsForDestination )
227 msg += wxString::Format( wxT(
"|%-5d | %-50s\n" ), jobNum, job.GetDescription() );
231 msg += wxT(
"|--------------------------------\n" );
237 std::vector<JOB_OUTPUT> outputs;
241 int successCount = 0;
245 for(
const JOBSET_JOB& job : jobsForDestination )
247 msg = wxT(
"|--------------------------------\n" );
249 msg += wxString::Format( wxT(
"| Running job %d: %s" ), jobNum, job.GetDescription() );
252 msg += wxT(
"|--------------------------------\n" );
258 msg.Printf(
_(
"Running job %d: %s" ), jobNum, job.GetDescription() );
267 job.m_job->SetTempOutputDirectory( tempDirPath );
287 if( job.m_job->GetType() ==
"special_execute" )
291 else if( job.m_job->GetType() ==
"special_copyfiles" )
301 wxString msg_fmt = wxT(
"\033[32;1m%s\033[0m\n" );
302 msg = wxString::Format( msg_fmt,
_(
"Job successful" ) );
308 wxString msg_fmt = wxT(
"\033[31;1m%s\033[0m\n" );
309 msg = wxString::Format( msg_fmt,
_(
"Job failed" ) );
314 msg += wxT(
"\n\n" );
341 msg = wxString::Format( wxT(
"\n\n\033[33;1m%d %s, %d %s\033[0m\n" ),
343 wxT(
"jobs succeeded" ),
345 wxT(
"job failed" ) );
REPORTER & Report(const wxString &aText, SEVERITY aSeverity) override
Report a string with a given severity.
PROGRESS_REPORTER * m_progressReporter
JOBSET_OUTPUT_REPORTER(const wxString &aTempDirPath, PROGRESS_REPORTER *aProgressReporter)
std::vector< JOBSET_DESTINATION > & GetDestinations()
std::vector< JOBSET_JOB > GetJobsForDestination(JOBSET_DESTINATION *aDestination)
void AdvanceJob(const wxString &aMessage)
bool RunJobsAllDestinations(bool aBail=false)
JOBS_PROGRESS_REPORTER * m_progressReporter
bool RunJobsForDestination(JOBSET_DESTINATION *aDestination, bool aBail=false)
int runSpecialExecute(const JOBSET_JOB *aJob, PROJECT *aProject)
int runSpecialCopyFiles(const JOBSET_JOB *aJob, PROJECT *aProject)
JOBS_RUNNER(KIWAY *aKiway, JOBSET *aJobsFile, PROJECT *aProject, REPORTER &aReporter, JOBS_PROGRESS_REPORTER *aProgressReporter)
static KIWAY::FACE_T GetKifaceType(const wxString &aName)
bool m_generateErrorOnNoCopy
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
wxString GetFullOutputPath(PROJECT *aProject) const
Returns the full output path for the job, taking into account the configured output path,...
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
FACE_T
Known KIFACE implementations.
static REPORTER & GetInstance()
bool KeepRefreshing(bool aWait=false) override
Update the UI dialog.
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
Container for project specific data.
virtual const wxString GetProjectPath() const
Return the full path of the project.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
A wrapper for reporting to a wxString object.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
bool CopyFilesOrDirectory(const wxString &aSourcePath, const wxString &aDestDir, wxString &aErrors, int &aFileCopiedCount, const std::vector< wxString > &aExclusions)
#define OUTPUT_TMP_PATH_VAR_NAME
static const int ERR_ARGS
static const int ERR_RC_VIOLATIONS
Rules check violation count was greater than 0.
static const int ERR_INVALID_OUTPUT_CONFLICT
static const int ERR_UNKNOWN
static PGM_BASE * process
std::unordered_map< wxString, REPORTER * > m_lastRunReporters
std::shared_ptr< JOBS_OUTPUT_HANDLER > m_outputHandler
std::optional< bool > m_lastRunSuccess
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
std::shared_ptr< JOB > m_job