mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Allow substitution for job output paths
Fixes https://gitlab.com/kicad/code/kicad/-/issues/19357
This commit is contained in:
parent
a55915726f
commit
d9d927e80c
@ -24,6 +24,8 @@
|
||||
#include <vector>
|
||||
#include <jobs/job.h>
|
||||
|
||||
class PROJECT;
|
||||
|
||||
class KICOMMON_API JOBS_OUTPUT_HANDLER
|
||||
{
|
||||
public:
|
||||
@ -40,7 +42,8 @@ public:
|
||||
* @return true if the output process can proceed
|
||||
*/
|
||||
virtual bool OutputPrecheck() { return true; }
|
||||
virtual bool HandleOutputs( const wxString& baseTempPath,
|
||||
virtual bool HandleOutputs( const wxString& aBaseTempPath,
|
||||
PROJECT* aProject,
|
||||
const std::vector<JOB_OUTPUT>& aOutputsToHandle ) = 0;
|
||||
|
||||
virtual void FromJson( const nlohmann::json& j ) = 0;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/zipstrm.h>
|
||||
#include <gestfich.h>
|
||||
#include <common.h>
|
||||
|
||||
JOBS_OUTPUT_ARCHIVE::JOBS_OUTPUT_ARCHIVE() : JOBS_OUTPUT_HANDLER(),
|
||||
m_format( FORMAT::ZIP )
|
||||
@ -42,11 +43,14 @@ bool JOBS_OUTPUT_ARCHIVE::OutputPrecheck()
|
||||
|
||||
|
||||
bool JOBS_OUTPUT_ARCHIVE::HandleOutputs( const wxString& baseTempPath,
|
||||
PROJECT* aProject,
|
||||
const std::vector<JOB_OUTPUT>& aOutputsToHandle )
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
wxFFileOutputStream ostream( m_outputPath );
|
||||
wxString outputPath = ExpandEnvVarSubstitutions( m_outputPath, aProject );
|
||||
|
||||
wxFFileOutputStream ostream( outputPath );
|
||||
if( !ostream.IsOk() ) // issue to create the file. Perhaps not writable dir
|
||||
{
|
||||
//msg.Printf( _( "Failed to create file '%s'." ), aDestFile );
|
||||
|
@ -32,7 +32,9 @@ public:
|
||||
ZIP
|
||||
};
|
||||
|
||||
bool HandleOutputs( const wxString& baseTempPath, const std::vector<JOB_OUTPUT>& aOutputsToHandle ) override;
|
||||
bool HandleOutputs( const wxString& aBaseTempPath,
|
||||
PROJECT* aProject,
|
||||
const std::vector<JOB_OUTPUT>& aOutputsToHandle ) override;
|
||||
bool OutputPrecheck() override;
|
||||
|
||||
void FromJson( const nlohmann::json& j ) override;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <jobs/jobs_output_folder.h>
|
||||
#include <wx/filename.h>
|
||||
#include <gestfich.h>
|
||||
#include <common.h>
|
||||
|
||||
JOBS_OUTPUT_FOLDER::JOBS_OUTPUT_FOLDER() :
|
||||
JOBS_OUTPUT_HANDLER()
|
||||
@ -30,21 +31,24 @@ JOBS_OUTPUT_FOLDER::JOBS_OUTPUT_FOLDER() :
|
||||
|
||||
|
||||
bool JOBS_OUTPUT_FOLDER::HandleOutputs( const wxString& baseTempPath,
|
||||
PROJECT* aProject,
|
||||
const std::vector<JOB_OUTPUT>& aOutputsToHandle )
|
||||
{
|
||||
if( wxFileName::DirExists( m_outputPath ) )
|
||||
wxString outputPath = ExpandEnvVarSubstitutions( m_outputPath, aProject );
|
||||
|
||||
if( wxFileName::DirExists( outputPath ) )
|
||||
{
|
||||
wxFileName::Rmdir( m_outputPath, wxPATH_RMDIR_RECURSIVE );
|
||||
wxFileName::Rmdir( outputPath, wxPATH_RMDIR_RECURSIVE );
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
if( !wxFileName::Mkdir( m_outputPath, wxS_DIR_DEFAULT ) )
|
||||
if( !wxFileName::Mkdir( outputPath, wxS_DIR_DEFAULT ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
wxString errors;
|
||||
if( !CopyDirectory( baseTempPath, m_outputPath, errors ) )
|
||||
if( !CopyDirectory( baseTempPath, outputPath, errors ) )
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ class JOBS_OUTPUT_FOLDER : public JOBS_OUTPUT_HANDLER
|
||||
public:
|
||||
JOBS_OUTPUT_FOLDER();
|
||||
|
||||
bool HandleOutputs( const wxString& baseTempPath,
|
||||
bool HandleOutputs( const wxString& aBaseTempPath,
|
||||
PROJECT* aProject,
|
||||
const std::vector<JOB_OUTPUT>& aOutputsToHandle ) override;
|
||||
|
||||
bool OutputPrecheck() override;
|
||||
|
@ -74,11 +74,14 @@ int CLI::JOBSET_RUN_COMMAND::doPerform( KIWAY& aKiway )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
}
|
||||
|
||||
PROJECT* project = Pgm().GetSettingsManager().GetProject( projectFile );
|
||||
|
||||
JOBSET jobFile( jobsFilePath.ToStdString() );
|
||||
|
||||
jobFile.LoadFromFile();
|
||||
|
||||
JOBS_RUNNER jobsRunner( &aKiway, &jobFile, &CLI_REPORTER::GetInstance() );
|
||||
JOBS_RUNNER jobsRunner( &aKiway, &jobFile, project,
|
||||
&CLI_REPORTER::GetInstance() );
|
||||
|
||||
int return_code = CLI::EXIT_CODES::SUCCESS;
|
||||
|
||||
|
@ -363,7 +363,7 @@ public:
|
||||
wxFileName fn = project.GetProjectFullName();
|
||||
wxSetWorkingDirectory( fn.GetPath() );
|
||||
|
||||
JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile );
|
||||
JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile, &project );
|
||||
|
||||
WX_PROGRESS_REPORTER* progressReporter =
|
||||
new WX_PROGRESS_REPORTER( m_frame, _( "Running jobs" ), 1 );
|
||||
@ -846,7 +846,7 @@ void PANEL_JOBS::OnRunAllJobsClick( wxCommandEvent& event )
|
||||
wxFileName fn = project.GetProjectFullName();
|
||||
wxSetWorkingDirectory( fn.GetPath() );
|
||||
|
||||
JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile.get() );
|
||||
JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile.get(), &project );
|
||||
|
||||
WX_PROGRESS_REPORTER* progressReporter =
|
||||
new WX_PROGRESS_REPORTER( m_frame, _( "Running jobs" ), 1 );
|
||||
|
@ -30,11 +30,12 @@
|
||||
#include <wx/sstream.h>
|
||||
#include <wx/wfstream.h>
|
||||
|
||||
JOBS_RUNNER::JOBS_RUNNER( KIWAY* aKiway, JOBSET* aJobsFile,
|
||||
JOBS_RUNNER::JOBS_RUNNER( KIWAY* aKiway, JOBSET* aJobsFile, PROJECT* aProject,
|
||||
REPORTER* aReporter ) :
|
||||
m_kiway( aKiway ),
|
||||
m_jobsFile( aJobsFile ),
|
||||
m_reporter( aReporter )
|
||||
m_reporter( aReporter ),
|
||||
m_project( aProject )
|
||||
{
|
||||
if( !m_reporter )
|
||||
{
|
||||
@ -246,7 +247,7 @@ bool JOBS_RUNNER::RunJobsForOutput( JOBSET_OUTPUT* aOutput, bool aBail )
|
||||
|
||||
if( success )
|
||||
{
|
||||
success = aOutput->m_outputHandler->HandleOutputs( tempDirPath, outputs );
|
||||
success = aOutput->m_outputHandler->HandleOutputs( tempDirPath, m_project, outputs );
|
||||
}
|
||||
|
||||
aOutput->m_lastRunSuccess = success;
|
||||
|
@ -25,11 +25,13 @@ struct JOBSET_OUTPUT;
|
||||
struct JOBSET_JOB;
|
||||
class KIWAY;
|
||||
class REPORTER;
|
||||
class PROJECT;
|
||||
|
||||
class JOBS_RUNNER
|
||||
{
|
||||
public:
|
||||
JOBS_RUNNER( KIWAY* aKiway, JOBSET* aJobsFile, REPORTER* aReporter = nullptr );
|
||||
JOBS_RUNNER( KIWAY* aKiway, JOBSET* aJobsFile, PROJECT* aProject,
|
||||
REPORTER* aReporter = nullptr );
|
||||
|
||||
bool RunJobsAllOutputs( bool aBail = false );
|
||||
bool RunJobsForOutput( JOBSET_OUTPUT* aOutput, bool aBail = false );
|
||||
@ -38,7 +40,8 @@ private:
|
||||
int runSpecialExecute( JOBSET_JOB* aJob );
|
||||
|
||||
private:
|
||||
KIWAY* m_kiway;
|
||||
KIWAY* m_kiway;
|
||||
JOBSET* m_jobsFile;
|
||||
REPORTER* m_reporter;
|
||||
REPORTER* m_reporter;
|
||||
PROJECT* m_project;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user