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 );
139 bool genOutputs =
true;
145 tmp.AssignDir( wxFileName::GetTempDir() );
146 tmp.AppendDir(
KIID().AsString() );
151 wxString tempDirPath = tmp.GetFullPath();
153 if( !wxFileName::Mkdir( tempDirPath, wxS_DIR_DEFAULT ) )
155 msg = wxString::Format( wxT(
"Failed to create temporary directory %s" ), tempDirPath );
167 msg = wxString::Format( wxT(
"Destination precheck failed for destination %s" ),
168 aDestination->
m_id );
175 msg += wxT(
"|--------------------------------\n" );
177 msg += wxString::Format( wxT(
"Running jobs for destination %s" ), aDestination->
m_id );
179 msg += wxT(
"|--------------------------------\n" );
181 msg += wxString::Format( wxT(
"|%-5s | %-50s\n" ), wxT(
"No." ), wxT(
"Description" ) );
185 for(
const JOBSET_JOB& job : jobsForDestination )
187 msg += wxString::Format( wxT(
"|%-5d | %-50s\n" ), jobNum, job.GetDescription() );
191 msg += wxT(
"|--------------------------------\n" );
197 std::vector<JOB_OUTPUT> outputs;
201 int successCount = 0;
205 for(
const JOBSET_JOB& job : jobsForDestination )
207 msg = wxT(
"|--------------------------------\n" );
209 msg += wxString::Format( wxT(
"| Running job %d: %s" ), jobNum, job.GetDescription() );
212 msg += wxT(
"|--------------------------------\n" );
218 msg.Printf(
_(
"Running job %d: %s" ), jobNum, job.GetDescription() );
227 job.m_job->SetTempOutputDirectory( tempDirPath );
233 aDestination->
m_lastRunReporters[job.m_id] = std::make_shared<JOBSET_OUTPUT_REPORTER>( tempDirPath,
248 if( job.m_job->GetType() ==
"special_execute" )
252 else if( job.m_job->GetType() ==
"special_copyfiles" )
262 wxString msg_fmt = wxT(
"\033[32;1m%s\033[0m\n" );
263 msg = wxString::Format( msg_fmt,
_(
"Job successful" ) );
269 wxString msg_fmt = wxT(
"\033[31;1m%s\033[0m\n" );
270 msg = wxString::Format( msg_fmt,
_(
"Job failed" ) );
275 msg += wxT(
"\n\n" );
302 msg = wxString::Format( wxT(
"\n\n\033[33;1m%d %s, %d %s\033[0m\n" ),
304 wxT(
"jobs succeeded" ),
306 wxT(
"job failed" ) );
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.
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.
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, std::shared_ptr< JOBSET_OUTPUT_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