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 ),
72 int result =
static_cast<int>( wxExecute( cmd, wxEXEC_SYNC, &
process ) );
78 wxFileName fn( aJob->
m_id );
79 fn.SetExt( wxT(
"log" ) );
85 if( !procOutput.IsOk() )
88 wxInputStream* inputStream =
process.GetInputStream();
91 inputStream->Read( procOutput );
111 if( source.IsEmpty() )
115 wxFileName sourceFn( source );
116 sourceFn.MakeAbsolute( projectPath );
120 if( !job->
m_dest.IsEmpty() )
121 destFn.AppendDir( job->
m_dest );
123 std::vector<wxString> exclusions;
126 exclusions.push_back( projectPath + destination.m_outputHandler->GetOutputPath() );
131 errors, copyCount, exclusions );
153 wxString
text( aText );
168 bool genOutputs =
true;
174 tmp.AssignDir( wxFileName::GetTempDir() );
175 tmp.AppendDir(
KIID().AsString() );
184 wxString tempDirPath = tmp.GetFullPath();
186 if( !wxFileName::Mkdir( tempDirPath, wxS_DIR_DEFAULT ) )
190 msg = wxString::Format( wxT(
"Failed to create temporary directory %s" ), tempDirPath );
205 msg = wxString::Format( wxT(
"Output precheck failed for output %s" ),
206 aDestination->
m_id );
216 msg += wxT(
"|--------------------------------\n" );
218 msg += wxString::Format(
"Performing jobs for output %s", aDestination->
m_id );
220 msg += wxT(
"|--------------------------------\n" );
222 msg += wxString::Format( wxT(
"|%-5s | %-50s\n" ), wxT(
"No." ), wxT(
"Description" ) );
226 for(
const JOBSET_JOB& job : jobsForDestination )
228 msg += wxString::Format( wxT(
"|%-5d | %-50s\n" ), jobNum, job.GetDescription() );
232 msg += wxT(
"|--------------------------------\n" );
239 std::vector<JOB_OUTPUT> outputs;
243 int successCount = 0;
245 for(
const JOBSET_JOB& job : jobsForDestination )
249 msg = wxT(
"|--------------------------------\n" );
251 msg += wxString::Format( wxT(
"| Running job %d, %s" ), jobNum, job.GetDescription() );
255 msg += wxT(
"|--------------------------------\n" );
262 job.m_job->SetTempOutputDirectory( tempDirPath );
281 if( job.m_job->GetType() ==
"special_execute" )
285 else if( job.m_job->GetType() ==
"special_copyfiles" )
297 wxString msg_fmt = wxT(
"\033[32;1m%s\033[0m\n" );
298 msg = wxString::Format( msg_fmt,
_(
"Job successful" ) );
304 wxString msg_fmt = wxT(
"\033[31;1m%s\033[0m\n" );
305 msg = wxString::Format( msg_fmt,
_(
"Job failed" ) );
310 msg += wxT(
"\n\n" );
338 msg = wxString::Format( wxT(
"\n\n\033[33;1m%d %s, %d %s\033[0m\n" ),
340 wxT(
"jobs succeeded" ),
342 wxT(
"job failed" ) );
REPORTER & Report(const wxString &aText, SEVERITY aSeverity) override
Report a string with a given severity.
JOBSET_OUTPUT_REPORTER(const wxString &aTempDirPath)
std::vector< JOBSET_DESTINATION > & GetDestinations()
std::vector< JOBSET_JOB > GetJobsForDestination(JOBSET_DESTINATION *aDestination)
virtual bool OutputPrecheck()
Checks if the output process can proceed before doing anything else This can include user prompts.
virtual bool HandleOutputs(const wxString &aBaseTempPath, PROJECT *aProject, const std::vector< JOB_OUTPUT > &aOutputsToHandle)=0
bool RunJobsAllDestinations(bool aBail=false)
bool RunJobsForDestination(JOBSET_DESTINATION *aDestination, bool aBail=false)
JOBS_RUNNER(KIWAY *aKiway, JOBSET *aJobsFile, PROJECT *aProject, REPORTER *aReporter=nullptr)
int runSpecialExecute(const JOBSET_JOB *aJob, PROJECT *aProject)
int runSpecialCopyFiles(const JOBSET_JOB *aJob, PROJECT *aProject)
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...
FACE_T
Known KIFACE implementations.
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr)
static REPORTER & GetInstance()
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)=0
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)
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
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