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 ),
74 int result =
static_cast<int>( wxExecute( cmd, wxEXEC_SYNC, &
process ) );
80 wxFileName fn( aJob->
m_id );
81 fn.SetExt( wxT(
"log" ) );
87 if( !procOutput.IsOk() )
90 wxInputStream* inputStream =
process.GetInputStream();
93 inputStream->Read( procOutput );
113 if( source.IsEmpty() )
117 wxFileName sourceFn( source );
118 sourceFn.MakeAbsolute( projectPath );
122 if( !job->
m_dest.IsEmpty() )
123 destFn.AppendDir( job->
m_dest );
125 std::vector<wxString> exclusions;
128 exclusions.push_back( projectPath + output.m_outputHandler->GetOutputPath() );
133 errors, copyCount, exclusions );
155 wxString
text( aText );
170 bool genOutputs =
true;
176 tmp.AssignDir( wxFileName::GetTempDir() );
177 tmp.AppendDir(
KIID().AsString() );
186 wxString tempDirPath = tmp.GetFullPath();
188 if( !wxFileName::Mkdir( tempDirPath, wxS_DIR_DEFAULT ) )
192 msg = wxString::Format( wxT(
"Failed to create temporary directory %s" ), tempDirPath );
207 msg = wxString::Format( wxT(
"Output precheck failed for output %s" ), aOutput->
m_id );
217 msg += wxT(
"|--------------------------------\n" );
219 msg += wxString::Format(
"Performing jobs for output %s", aOutput->
m_id );
221 msg += wxT(
"|--------------------------------\n" );
223 msg += wxString::Format( wxT(
"|%-5s | %-50s\n" ), wxT(
"No." ), wxT(
"Description" ) );
229 msg += wxString::Format( wxT(
"|%-5d | %-50s\n" ), jobNum, job.GetDescription() );
233 msg += wxT(
"|--------------------------------\n" );
240 std::vector<JOB_OUTPUT> outputs;
244 int successCount = 0;
250 msg = wxT(
"|--------------------------------\n" );
251 msg += wxString::Format( wxT(
"| Running job %d, %s" ), jobNum, job.GetDescription() );
253 msg += wxT(
"|--------------------------------\n" );
260 job.m_job->SetTempOutputDirectory( tempDirPath );
279 if( job.m_job->GetType() ==
"special_execute" )
283 else if( job.m_job->GetType() ==
"special_copyfiles" )
295 wxString msg_fmt = wxT(
"\033[32;1m%s\033[0m\n" );
296 msg = wxString::Format( msg_fmt,
_(
"Job successful" ) );
302 wxString msg_fmt = wxT(
"\033[31;1m%s\033[0m\n" );
303 msg = wxString::Format( msg_fmt,
_(
"Job failed" ) );
308 msg += wxT(
"\n\n" );
336 msg = wxString::Format( wxT(
"\n\n\033[33;1m%d %s, %d %s\033[0m\n" ),
338 wxT(
"jobs succeeded" ),
340 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_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 &aBaseTempPath, PROJECT *aProject, const std::vector< JOB_OUTPUT > &aOutputsToHandle)=0
bool RunJobsForOutput(JOBSET_OUTPUT *aOutput, bool aBail=false)
bool RunJobsAllOutputs(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.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
bool CopyFilesOrDirectory(const wxString &aSourcePath, const wxString &aDestDir, wxString &aErrors, int &fileCopiedCount, 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::shared_ptr< JOB > m_job
JOBS_OUTPUT_HANDLER * m_outputHandler
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
std::optional< bool > m_lastRunSuccess
std::unordered_map< wxString, REPORTER * > m_lastRunReporters