Implement output targeting of symlib/fplib upgrade per request
This commit is contained in:
parent
b9287968d6
commit
c0b5fe58c3
|
@ -30,11 +30,13 @@ public:
|
|||
JOB_FP_UPGRADE( bool aIsCli ) :
|
||||
JOB( "fpupgrade", aIsCli ),
|
||||
m_libraryPath(),
|
||||
m_outputLibraryPath(),
|
||||
m_force( false )
|
||||
{
|
||||
}
|
||||
|
||||
wxString m_libraryPath;
|
||||
wxString m_outputLibraryPath;
|
||||
|
||||
bool m_force;
|
||||
};
|
||||
|
|
|
@ -30,11 +30,13 @@ public:
|
|||
JOB_SYM_UPGRADE( bool aIsCli ) :
|
||||
JOB( "symupgrade", aIsCli ),
|
||||
m_libraryPath(),
|
||||
m_outputLibraryPath(),
|
||||
m_force( false )
|
||||
{
|
||||
}
|
||||
|
||||
wxString m_libraryPath;
|
||||
wxString m_outputLibraryPath;
|
||||
|
||||
bool m_force;
|
||||
};
|
||||
|
|
|
@ -37,6 +37,13 @@ void WX_FILENAME::SetFullName( const wxString& aFileNameAndExtension )
|
|||
}
|
||||
|
||||
|
||||
void WX_FILENAME::SetPath( const wxString& aPath )
|
||||
{
|
||||
m_fn.SetPath( aPath );
|
||||
m_path = aPath;
|
||||
}
|
||||
|
||||
|
||||
wxString WX_FILENAME::GetName() const
|
||||
{
|
||||
size_t dot = m_fullName.find_last_of( wxT( '.' ) );
|
||||
|
|
|
@ -338,6 +338,15 @@ int EESCHEMA_JOBS_HANDLER::JobExportSymLibUpgrade( JOB* aJob )
|
|||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
|
||||
{
|
||||
if( wxFile::Exists( upgradeJob->m_outputLibraryPath ) )
|
||||
{
|
||||
wxFprintf( stderr, _( "Output path must not conflict with existing path\n" ) );
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldSave = upgradeJob->m_force
|
||||
|| schLibrary.GetFileFormatVersionAtLoad() < SEXPR_SYMBOL_LIB_FILE_VERSION;
|
||||
|
||||
|
@ -347,6 +356,11 @@ int EESCHEMA_JOBS_HANDLER::JobExportSymLibUpgrade( JOB* aJob )
|
|||
|
||||
try
|
||||
{
|
||||
if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
|
||||
{
|
||||
schLibrary.SetFileName( upgradeJob->m_outputLibraryPath );
|
||||
}
|
||||
|
||||
schLibrary.SetModified();
|
||||
schLibrary.Save();
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
WX_FILENAME( const wxString& aPath, const wxString& aFilename );
|
||||
|
||||
void SetFullName( const wxString& aFileNameAndExtension );
|
||||
void SetPath( const wxString& aPath );
|
||||
|
||||
wxString GetName() const;
|
||||
wxString GetFullName() const;
|
||||
|
|
|
@ -45,6 +45,8 @@ int CLI::FP_UPGRADE_COMMAND::Perform( KIWAY& aKiway )
|
|||
std::unique_ptr<JOB_FP_UPGRADE> fpJob = std::make_unique<JOB_FP_UPGRADE>( true );
|
||||
|
||||
fpJob->m_libraryPath = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
|
||||
fpJob->m_outputLibraryPath = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
|
||||
fpJob->m_force = m_argParser.get<bool>( ARG_FORCE );
|
||||
|
||||
if( !wxDir::Exists( fpJob->m_libraryPath ) )
|
||||
{
|
||||
|
|
|
@ -45,6 +45,8 @@ int CLI::SYM_UPGRADE_COMMAND::Perform( KIWAY& aKiway )
|
|||
std::unique_ptr<JOB_SYM_UPGRADE> symJob = std::make_unique<JOB_SYM_UPGRADE>( true );
|
||||
|
||||
symJob->m_libraryPath = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
|
||||
symJob->m_outputLibraryPath = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
|
||||
symJob->m_force = m_argParser.get<bool>( ARG_FORCE );
|
||||
|
||||
if( !wxFile::Exists( symJob->m_libraryPath ) )
|
||||
{
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <board_design_settings.h>
|
||||
#include <pcbnew_settings.h>
|
||||
#include <wx/crt.h>
|
||||
#include <wx/dir.h>
|
||||
#include <pcb_plot_svg.h>
|
||||
#include <gendrill_Excellon_writer.h>
|
||||
#include <gendrill_gerber_writer.h>
|
||||
|
@ -480,6 +481,16 @@ int PCBNEW_JOBS_HANDLER::JobExportFpUpgrade( JOB* aJob )
|
|||
if( aJob->IsCli() )
|
||||
wxPrintf( _( "Loading board\n" ) );
|
||||
|
||||
if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
|
||||
{
|
||||
if( wxFile::Exists( upgradeJob->m_outputLibraryPath ) ||
|
||||
wxDir::Exists( upgradeJob->m_outputLibraryPath) )
|
||||
{
|
||||
wxFprintf( stderr, _( "Output path must not conflict with existing path\n" ) );
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
}
|
||||
|
||||
PCB_PLUGIN pcb_io( CTL_FOR_LIBRARY );
|
||||
FP_CACHE fpLib( &pcb_io, upgradeJob->m_libraryPath );
|
||||
|
||||
|
@ -509,6 +520,11 @@ int PCBNEW_JOBS_HANDLER::JobExportFpUpgrade( JOB* aJob )
|
|||
|
||||
try
|
||||
{
|
||||
if( !upgradeJob->m_outputLibraryPath.IsEmpty() )
|
||||
{
|
||||
fpLib.SetPath( upgradeJob->m_outputLibraryPath );
|
||||
}
|
||||
|
||||
fpLib.Save();
|
||||
}
|
||||
catch( ... )
|
||||
|
|
|
@ -232,6 +232,19 @@ bool FP_CACHE::IsPath( const wxString& aPath ) const
|
|||
}
|
||||
|
||||
|
||||
void FP_CACHE::SetPath( const wxString& aPath )
|
||||
{
|
||||
m_lib_raw_path = aPath;
|
||||
m_lib_path.SetPath( aPath );
|
||||
|
||||
|
||||
for( auto& footprint : GetFootprints() )
|
||||
{
|
||||
footprint.second->SetFilePath( aPath );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FP_CACHE::IsModified()
|
||||
{
|
||||
m_cache_dirty = m_cache_dirty || GetTimestamp( m_lib_path.GetFullPath() ) != m_cache_timestamp;
|
||||
|
|
|
@ -179,6 +179,7 @@ public:
|
|||
FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
|
||||
|
||||
const WX_FILENAME& GetFileName() const { return m_filename; }
|
||||
void SetFilePath( const wxString& aFilePath ) { m_filename.SetPath( aFilePath ); }
|
||||
const FOOTPRINT* GetFootprint() const { return m_footprint.get(); }
|
||||
};
|
||||
|
||||
|
@ -246,6 +247,8 @@ public:
|
|||
* @return true if \a aPath is the same as the cache path.
|
||||
*/
|
||||
bool IsPath( const wxString& aPath ) const;
|
||||
|
||||
void SetPath( const wxString& aPath );
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue