Merge branch 'kicad-cli-no-uuids' into 'master'
Draft: Add kicad-cli option to disable UUID generation See merge request kicad/code/kicad!1949
This commit is contained in:
commit
1b2d70aa64
|
@ -25,6 +25,7 @@ JOB_FP_UPGRADE::JOB_FP_UPGRADE( bool aIsCli ) :
|
|||
JOB( "fpupgrade", aIsCli ),
|
||||
m_libraryPath(),
|
||||
m_outputLibraryPath(),
|
||||
m_force( false )
|
||||
m_force( false ),
|
||||
m_no_uuid_gen( false )
|
||||
{
|
||||
}
|
|
@ -34,6 +34,7 @@ public:
|
|||
wxString m_outputLibraryPath;
|
||||
|
||||
bool m_force;
|
||||
bool m_no_uuid_gen;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -29,6 +29,7 @@
|
|||
#include <macros.h>
|
||||
|
||||
#define ARG_FORCE "--force"
|
||||
#define ARG_NO_UUID_GEN "--no-uuid-gen"
|
||||
|
||||
CLI::FP_UPGRADE_COMMAND::FP_UPGRADE_COMMAND() : PCB_EXPORT_BASE_COMMAND( "upgrade", true, true )
|
||||
{
|
||||
|
@ -39,6 +40,11 @@ CLI::FP_UPGRADE_COMMAND::FP_UPGRADE_COMMAND() : PCB_EXPORT_BASE_COMMAND( "upgrad
|
|||
.help( UTF8STDSTR(
|
||||
_( "Forces the footprint library to be resaved regardless of versioning" ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( ARG_NO_UUID_GEN )
|
||||
.help( UTF8STDSTR(
|
||||
_( "Do not automatically generate UUIDs if they are not present" ) ) )
|
||||
.flag();
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,6 +55,7 @@ int CLI::FP_UPGRADE_COMMAND::doPerform( KIWAY& aKiway )
|
|||
fpJob->m_libraryPath = m_argInput;
|
||||
fpJob->m_outputLibraryPath = m_argOutput;
|
||||
fpJob->m_force = m_argParser.get<bool>( ARG_FORCE );
|
||||
fpJob->m_no_uuid_gen = m_argParser.get<bool>( ARG_NO_UUID_GEN );
|
||||
|
||||
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, fpJob.get() );
|
||||
|
||||
|
|
|
@ -887,7 +887,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_DIMENSION_BASE* aDimension, int aNest
|
|||
|
||||
formatLayer( aDimension->GetLayer() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aDimension->m_Uuid );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aDimension->m_Uuid );
|
||||
}
|
||||
|
||||
m_out->Print( aNestLevel+1, "(pts (xy %s %s) (xy %s %s))\n",
|
||||
formatInternalUnits( aDimension->GetStart().x ).c_str(),
|
||||
|
@ -1047,7 +1049,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_SHAPE* aShape, int aNestLevel ) const
|
|||
if( aShape->GetNetCode() > 0 )
|
||||
m_out->Print( 0, " (net %d)", m_mapping->Translate( aShape->GetNetCode() ) );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aShape->m_Uuid, 0 );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aShape->m_Uuid, 0 );
|
||||
}
|
||||
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
@ -1093,7 +1097,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_REFERENCE_IMAGE* aBitmap, int aNestLe
|
|||
m_out->Print( 0, "\n" );
|
||||
m_out->Print( aNestLevel + 1, ")\n" ); // Closes data token.
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aBitmap->m_Uuid, 0 );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aBitmap->m_Uuid, 0 );
|
||||
}
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" ); // Closes image token.
|
||||
}
|
||||
|
@ -1111,7 +1117,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TARGET* aTarget, int aNestLevel ) con
|
|||
|
||||
formatLayer( aTarget->GetLayer() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTarget->m_Uuid, 0 );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTarget->m_Uuid, 0 );
|
||||
}
|
||||
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
@ -1161,7 +1169,7 @@ void PCB_IO_KICAD_SEXPR::format( const FOOTPRINT* aFootprint, int aNestLevel ) c
|
|||
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
if( !( m_ctl & CTL_OMIT_UUIDS ) )
|
||||
if( !( m_ctl & CTL_OMIT_UUIDS ) && !this->m_no_generate_uuid )
|
||||
KICAD_FORMAT::FormatUuid( m_out, aFootprint->m_Uuid );
|
||||
|
||||
if( !( m_ctl & CTL_OMIT_AT ) )
|
||||
|
@ -1840,7 +1848,9 @@ void PCB_IO_KICAD_SEXPR::format( const PAD* aPad, int aNestLevel ) const
|
|||
}
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aPad->m_Uuid );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aPad->m_Uuid );
|
||||
}
|
||||
m_out->Print( aNestLevel, ")\n" );
|
||||
}
|
||||
|
||||
|
@ -1895,7 +1905,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXT* aText, int aNestLevel ) const
|
|||
if( parentFP && !aText->IsVisible() )
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "hide", !aText->IsVisible() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid );
|
||||
}
|
||||
|
||||
aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
|
||||
|
||||
|
@ -1961,7 +1973,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) c
|
|||
formatLayer( aTextBox->GetLayer() );
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTextBox->m_Uuid );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTextBox->m_Uuid );
|
||||
}
|
||||
|
||||
// PCB_TEXTBOXes are never hidden, so always omit "hide" attribute
|
||||
aTextBox->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
|
||||
|
@ -2061,7 +2075,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_GROUP* aGroup, int aNestLevel ) const
|
|||
|
||||
m_out->Print( aNestLevel, "(group %s\n", m_out->Quotew( aGroup->GetName() ).c_str() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aGroup->m_Uuid );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aGroup->m_Uuid );
|
||||
}
|
||||
|
||||
if( aGroup->IsLocked() )
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "locked", aGroup->IsLocked() );
|
||||
|
@ -2087,7 +2103,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_GENERATOR* aGenerator, int aNestLevel
|
|||
{
|
||||
m_out->Print( aNestLevel, "(generated\n" );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aGenerator->m_Uuid );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aGenerator->m_Uuid );
|
||||
}
|
||||
|
||||
m_out->Print( aNestLevel + 1, "(type %s) (name %s)\n",
|
||||
TO_UTF8( aGenerator->GetGeneratorType() ),
|
||||
|
@ -2323,7 +2341,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TRACK* aTrack, int aNestLevel ) const
|
|||
|
||||
m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTrack->m_Uuid );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTrack->m_Uuid );
|
||||
}
|
||||
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
@ -2359,7 +2379,9 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone, int aNestLevel ) const
|
|||
formatLayer( aZone->GetFirstLayer() );
|
||||
}
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aZone->m_Uuid );
|
||||
if(!this->m_no_generate_uuid) {
|
||||
KICAD_FORMAT::FormatUuid( m_out, aZone->m_Uuid );
|
||||
}
|
||||
|
||||
if( !aZone->GetZoneName().empty() )
|
||||
m_out->Print( 0, " (name %s)", m_out->Quotew( aZone->GetZoneName() ).c_str() );
|
||||
|
|
|
@ -378,6 +378,8 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
inline void SetUUIDDisabled( bool aDisabled ) { m_no_generate_uuid = aDisabled; }
|
||||
|
||||
void SetOutputFormatter( OUTPUTFORMATTER* aFormatter ) { m_out = aFormatter; }
|
||||
|
||||
BOARD_ITEM* Parse( const wxString& aClipboardSourceInput );
|
||||
|
@ -463,6 +465,8 @@ protected:
|
|||
NETINFO_MAPPING* m_mapping; ///< mapping for net codes, so only not empty net codes
|
||||
///< are stored with consecutive integers as net codes
|
||||
|
||||
bool m_no_generate_uuid; ///< Flag: Do not generate UUIDs for footprints
|
||||
|
||||
std::function<bool( wxString aTitle, int aIcon, wxString aMsg, wxString aAction )> m_queryUserCallback;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <kiway_player.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <string_utf8_map.h>
|
||||
|
||||
#include <pcb_io/pcb_io_mgr.h>
|
||||
|
||||
#include <pcb_io/eagle/pcb_io_eagle.h>
|
||||
|
@ -217,6 +219,15 @@ bool PCB_IO_MGR::ConvertLibrary( STRING_UTF8_MAP* aOldFileProps, const wxString&
|
|||
for ( const wxString& fpName : fpNames )
|
||||
{
|
||||
std::unique_ptr<const FOOTPRINT> fp( oldFilePI->GetEnumeratedFootprint( aOldFilePath, fpName, aOldFileProps ) );
|
||||
// Set options
|
||||
PCB_IO_KICAD_SEXPR* kicad_sexpr_parser = dynamic_cast<PCB_IO_KICAD_SEXPR*>( kicadPI.get() );
|
||||
if(kicad_sexpr_parser != nullptr) {
|
||||
UTF8 value;
|
||||
bool exists = aOldFileProps->Value( "no_uuid_gen", &value );
|
||||
kicad_sexpr_parser->SetUUIDDisabled(
|
||||
exists && value == "true"
|
||||
);
|
||||
}
|
||||
kicadPI->FootprintSave( aNewFilePath, fp.get() );
|
||||
}
|
||||
|
||||
|
|
|
@ -1137,7 +1137,9 @@ int PCBNEW_JOBS_HANDLER::JobExportFpUpgrade( JOB* aJob )
|
|||
}
|
||||
else
|
||||
{
|
||||
if( !PCB_IO_MGR::ConvertLibrary( nullptr, upgradeJob->m_libraryPath, upgradeJob->m_outputLibraryPath ) )
|
||||
STRING_UTF8_MAP properties;
|
||||
properties.emplace("no_uuid_gen", upgradeJob->m_no_uuid_gen ? UTF8("true") : UTF8("false"));
|
||||
if( !PCB_IO_MGR::ConvertLibrary( &properties, upgradeJob->m_libraryPath, upgradeJob->m_outputLibraryPath ) )
|
||||
{
|
||||
m_reporter->Report( ( "Unable to convert library\n" ), RPT_SEVERITY_ERROR );
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
|
|
Loading…
Reference in New Issue