mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Fix bugs in library existence checking, and add for symbol libs.
This commit is contained in:
parent
4a35468301
commit
2a1b93a254
@ -74,8 +74,10 @@ DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T
|
|||||||
DESIGN_BLOCK_IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath, int aCtl )
|
DESIGN_BLOCK_IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath, int aCtl )
|
||||||
{
|
{
|
||||||
if( IO_RELEASER<DESIGN_BLOCK_IO>( FindPlugin( KICAD_SEXP ) )->CanReadLibrary( aLibPath )
|
if( IO_RELEASER<DESIGN_BLOCK_IO>( FindPlugin( KICAD_SEXP ) )->CanReadLibrary( aLibPath )
|
||||||
&& aCtl != KICTL_NONKICAD_ONLY )
|
&& aCtl != KICTL_NONKICAD_ONLY )
|
||||||
|
{
|
||||||
return KICAD_SEXP;
|
return KICAD_SEXP;
|
||||||
|
}
|
||||||
|
|
||||||
return DESIGN_BLOCK_IO_MGR::FILE_TYPE_NONE;
|
return DESIGN_BLOCK_IO_MGR::FILE_TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1387,8 +1387,8 @@ int ERC_TESTER::TestLibSymbolIssues()
|
|||||||
|
|
||||||
wxCHECK2( libSymbolInSchematic, continue );
|
wxCHECK2( libSymbolInSchematic, continue );
|
||||||
|
|
||||||
wxString libName = symbol->GetLibId().GetLibNickname();
|
wxString libName = symbol->GetLibId().GetLibNickname();
|
||||||
LIB_TABLE_ROW* libTableRow = libTable->FindRow( libName, true );
|
const LIB_TABLE_ROW* libTableRow = libTable->FindRow( libName, true );
|
||||||
|
|
||||||
if( !libTableRow )
|
if( !libTableRow )
|
||||||
{
|
{
|
||||||
@ -1411,7 +1411,7 @@ int ERC_TESTER::TestLibSymbolIssues()
|
|||||||
{
|
{
|
||||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||||
ercItem->SetItems( symbol );
|
ercItem->SetItems( symbol );
|
||||||
msg.Printf( _( "The library '%s' is not enabled in the current configuration" ),
|
msg.Printf( _( "The symbol library '%s' is not enabled in the current configuration" ),
|
||||||
UnescapeString( libName ) );
|
UnescapeString( libName ) );
|
||||||
ercItem->SetErrorMessage( msg );
|
ercItem->SetErrorMessage( msg );
|
||||||
|
|
||||||
@ -1420,6 +1420,22 @@ int ERC_TESTER::TestLibSymbolIssues()
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if( !libTableRow->LibraryExists() )
|
||||||
|
{
|
||||||
|
if( m_settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
|
||||||
|
{
|
||||||
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||||
|
ercItem->SetItems( symbol );
|
||||||
|
msg.Printf( _( "The symbol library '%s' was not found at '%s'." ),
|
||||||
|
UnescapeString( libName ),
|
||||||
|
libTableRow->GetFullURI( true ) );
|
||||||
|
ercItem->SetErrorMessage( msg );
|
||||||
|
|
||||||
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
wxString symbolName = symbol->GetLibId().GetLibItemName();
|
wxString symbolName = symbol->GetLibId().GetLibItemName();
|
||||||
LIB_SYMBOL* libSymbol = SchGetLibSymbol( symbol->GetLibId(), libTable );
|
LIB_SYMBOL* libSymbol = SchGetLibSymbol( symbol->GetLibId(), libTable );
|
||||||
|
@ -1697,9 +1697,7 @@ void SCH_IO_KICAD_SEXPR::SaveLibrary( const wxString& aLibraryPath,
|
|||||||
wxString oldFileName = m_cache->GetFileName();
|
wxString oldFileName = m_cache->GetFileName();
|
||||||
|
|
||||||
if( !m_cache->IsFile( aLibraryPath ) )
|
if( !m_cache->IsFile( aLibraryPath ) )
|
||||||
{
|
|
||||||
m_cache->SetFileName( aLibraryPath );
|
m_cache->SetFileName( aLibraryPath );
|
||||||
}
|
|
||||||
|
|
||||||
// This is a forced save.
|
// This is a forced save.
|
||||||
m_cache->SetModified();
|
m_cache->SetModified();
|
||||||
@ -1708,6 +1706,18 @@ void SCH_IO_KICAD_SEXPR::SaveLibrary( const wxString& aLibraryPath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCH_IO_KICAD_SEXPR::CanReadLibrary( const wxString& aLibraryPath ) const
|
||||||
|
{
|
||||||
|
if( !SCH_IO::CanReadLibrary( aLibraryPath ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Above just checks for proper extension; now check that it actually exists
|
||||||
|
|
||||||
|
wxFileName fn( aLibraryPath );
|
||||||
|
return fn.IsOk() && fn.FileExists();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_IO_KICAD_SEXPR::IsLibraryWritable( const wxString& aLibraryPath )
|
bool SCH_IO_KICAD_SEXPR::IsLibraryWritable( const wxString& aLibraryPath )
|
||||||
{
|
{
|
||||||
wxFileName fn( aLibraryPath );
|
wxFileName fn( aLibraryPath );
|
||||||
@ -1785,7 +1795,6 @@ std::vector<LIB_SYMBOL*> SCH_IO_KICAD_SEXPR::ParseLibSymbols( std::string& aSymb
|
|||||||
|
|
||||||
void SCH_IO_KICAD_SEXPR::FormatLibSymbol( LIB_SYMBOL* symbol, OUTPUTFORMATTER & formatter )
|
void SCH_IO_KICAD_SEXPR::FormatLibSymbol( LIB_SYMBOL* symbol, OUTPUTFORMATTER & formatter )
|
||||||
{
|
{
|
||||||
|
|
||||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||||
SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( symbol, formatter );
|
SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( symbol, formatter );
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,8 @@ public:
|
|||||||
void SaveLibrary( const wxString& aLibraryPath,
|
void SaveLibrary( const wxString& aLibraryPath,
|
||||||
const std::map<std::string, UTF8>* aProperties = nullptr ) override;
|
const std::map<std::string, UTF8>* aProperties = nullptr ) override;
|
||||||
|
|
||||||
|
bool CanReadLibrary( const wxString& aLibraryPath ) const override;
|
||||||
|
|
||||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override;
|
bool IsLibraryWritable( const wxString& aLibraryPath ) override;
|
||||||
|
|
||||||
void GetAvailableSymbolFields( std::vector<wxString>& aNames ) override;
|
void GetAvailableSymbolFields( std::vector<wxString>& aNames ) override;
|
||||||
|
@ -115,6 +115,14 @@ public:
|
|||||||
plugin->GetDefaultSymbolFields( aNames );
|
plugin->GetDefaultSymbolFields( aNames );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LibraryExists() const override
|
||||||
|
{
|
||||||
|
if( plugin )
|
||||||
|
return plugin->CanReadLibrary( GetFullURI( true ) );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SCH_IO_MGR::SCH_FILE_T GetFileType() { return type; }
|
SCH_IO_MGR::SCH_FILE_T GetFileType() { return type; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -69,6 +69,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetType( const wxString& aType ) override;
|
void SetType( const wxString& aType ) override;
|
||||||
|
|
||||||
|
bool LibraryExists() const override
|
||||||
|
{
|
||||||
|
if( plugin )
|
||||||
|
return plugin->CanReadLibrary( GetFullURI( true ) );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T GetFileType() { return type; }
|
DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T GetFileType() { return type; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetType( const wxString& aType ) override;
|
void SetType( const wxString& aType ) override;
|
||||||
|
|
||||||
bool LibraryExists() const;
|
bool LibraryExists() const override;
|
||||||
|
|
||||||
PCB_IO_MGR::PCB_FILE_T GetFileType() { return type; }
|
PCB_IO_MGR::PCB_FILE_T GetFileType() { return type; }
|
||||||
|
|
||||||
|
@ -114,9 +114,6 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Checks if this IO object can read the specified library file/directory.
|
* Checks if this IO object can read the specified library file/directory.
|
||||||
* If not overridden, extension check is used.
|
* If not overridden, extension check is used.
|
||||||
*
|
|
||||||
* @note This is not a check that the file system object is readable by the user,
|
|
||||||
* but a check that this IO object can parse the given library.
|
|
||||||
*/
|
*/
|
||||||
virtual bool CanReadLibrary( const wxString& aFileName ) const;
|
virtual bool CanReadLibrary( const wxString& aFileName ) const;
|
||||||
|
|
||||||
|
@ -188,6 +188,8 @@ public:
|
|||||||
|
|
||||||
void SetVisible( bool aVisible = true ) { visible = aVisible; }
|
void SetVisible( bool aVisible = true ) { visible = aVisible; }
|
||||||
|
|
||||||
|
virtual bool LibraryExists() const = 0;
|
||||||
|
|
||||||
virtual bool Refresh() { return false; }
|
virtual bool Refresh() { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -837,10 +837,10 @@ bool DRC_TEST_PROVIDER_LIBRARY_PARITY::Run()
|
|||||||
if( !reportProgress( ii++, (int) board->Footprints().size(), progressDelta ) )
|
if( !reportProgress( ii++, (int) board->Footprints().size(), progressDelta ) )
|
||||||
return false; // DRC cancelled
|
return false; // DRC cancelled
|
||||||
|
|
||||||
LIB_ID fpID = footprint->GetFPID();
|
LIB_ID fpID = footprint->GetFPID();
|
||||||
wxString libName = fpID.GetLibNickname();
|
wxString libName = fpID.GetLibNickname();
|
||||||
wxString fpName = fpID.GetLibItemName();
|
wxString fpName = fpID.GetLibItemName();
|
||||||
const FP_LIB_TABLE_ROW* libTableRow = nullptr;
|
const LIB_TABLE_ROW* libTableRow = nullptr;
|
||||||
|
|
||||||
if( libName.IsEmpty() )
|
if( libName.IsEmpty() )
|
||||||
{
|
{
|
||||||
@ -862,7 +862,7 @@ bool DRC_TEST_PROVIDER_LIBRARY_PARITY::Run()
|
|||||||
{
|
{
|
||||||
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
|
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
|
||||||
msg.Printf( _( "The current configuration does not include the footprint library '%s'." ),
|
msg.Printf( _( "The current configuration does not include the footprint library '%s'." ),
|
||||||
libName );
|
UnescapeString( libName ) );
|
||||||
drcItem->SetErrorMessage( msg );
|
drcItem->SetErrorMessage( msg );
|
||||||
drcItem->SetItems( footprint );
|
drcItem->SetItems( footprint );
|
||||||
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
|
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
|
||||||
@ -876,7 +876,7 @@ bool DRC_TEST_PROVIDER_LIBRARY_PARITY::Run()
|
|||||||
{
|
{
|
||||||
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
|
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
|
||||||
msg.Printf( _( "The footprint library '%s' is not enabled in the current configuration." ),
|
msg.Printf( _( "The footprint library '%s' is not enabled in the current configuration." ),
|
||||||
libName );
|
UnescapeString( libName ) );
|
||||||
drcItem->SetErrorMessage( msg );
|
drcItem->SetErrorMessage( msg );
|
||||||
drcItem->SetItems( footprint );
|
drcItem->SetItems( footprint );
|
||||||
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
|
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
|
||||||
@ -889,8 +889,9 @@ bool DRC_TEST_PROVIDER_LIBRARY_PARITY::Run()
|
|||||||
if( !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ) )
|
if( !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ) )
|
||||||
{
|
{
|
||||||
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
|
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
|
||||||
msg.Printf( _( "The footprint library '%s' was not found." ),
|
msg.Printf( _( "The footprint library '%s' was not found at '%s'." ),
|
||||||
libName );
|
UnescapeString( libName ),
|
||||||
|
libTableRow->GetFullURI( true ) );
|
||||||
drcItem->SetErrorMessage( msg );
|
drcItem->SetErrorMessage( msg );
|
||||||
drcItem->SetItems( footprint );
|
drcItem->SetItems( footprint );
|
||||||
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
|
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
|
||||||
|
@ -126,7 +126,8 @@ public:
|
|||||||
* possible.
|
* possible.
|
||||||
*/
|
*/
|
||||||
virtual BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
|
virtual BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
|
||||||
const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr );
|
const std::map<std::string, UTF8>* aProperties = nullptr,
|
||||||
|
PROJECT* aProject = nullptr );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a container with the cached library footprints generated in the last call to
|
* Return a container with the cached library footprints generated in the last call to
|
||||||
@ -174,7 +175,8 @@ public:
|
|||||||
* @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
|
* @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
|
||||||
*/
|
*/
|
||||||
virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||||
bool aBestEfforts, const std::map<std::string, UTF8>* aProperties = nullptr );
|
bool aBestEfforts,
|
||||||
|
const std::map<std::string, UTF8>* aProperties = nullptr );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a timestamp representing all the files in the library (including the library
|
* Generate a timestamp representing all the files in the library (including the library
|
||||||
|
@ -83,15 +83,10 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxString GetType() const override
|
const wxString GetType() const override { return m_type; }
|
||||||
{
|
void SetType( const wxString& aType ) override { m_type = aType; }
|
||||||
return m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetType( const wxString& aType ) override
|
bool LibraryExists() const override { return true; }
|
||||||
{
|
|
||||||
m_type = aType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LIB_TABLE_ROW* do_clone() const override
|
LIB_TABLE_ROW* do_clone() const override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user