2009-11-04 20:46:53 +00:00
|
|
|
/*****************************************************/
|
|
|
|
/* libarch.cpp */
|
|
|
|
/* Module for generation of component archive files. */
|
|
|
|
/*****************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "netlist.h"
|
|
|
|
#include "protos.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*
|
2009-09-18 14:56:05 +00:00
|
|
|
* Creates a library that contains all components used in the schematic.
|
|
|
|
*
|
2008-12-10 16:49:53 +00:00
|
|
|
* return true if success
|
|
|
|
*/
|
2009-09-18 14:56:05 +00:00
|
|
|
bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
wxString msg;
|
|
|
|
LIB_COMPONENT* Entry;
|
|
|
|
CMP_LIBRARY* libCache;
|
2008-12-10 16:49:53 +00:00
|
|
|
|
2008-12-12 21:30:07 +00:00
|
|
|
EDA_ScreenList ScreenList;
|
2008-12-10 16:49:53 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
libCache = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, ArchFullFileName );
|
|
|
|
libCache->SetCache();
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* examine all screens (not sheets) used and build the list of components
|
2009-09-18 14:56:05 +00:00
|
|
|
* found in lib complex hierarchies are not a problem because we just want
|
|
|
|
* to know used components in libraries
|
2008-12-10 18:00:15 +00:00
|
|
|
*/
|
2009-09-18 14:56:05 +00:00
|
|
|
for( SCH_SCREEN* screen = ScreenList.GetFirst(); screen != NULL;
|
|
|
|
screen = ScreenList.GetNext() )
|
2008-12-10 16:49:53 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
for( SCH_ITEM* SchItem = screen->EEDrawList; SchItem;
|
|
|
|
SchItem = SchItem->Next() )
|
2008-12-10 16:49:53 +00:00
|
|
|
{
|
|
|
|
if( SchItem->Type() != TYPE_SCH_COMPONENT )
|
|
|
|
continue;
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) SchItem;
|
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2008-12-10 16:49:53 +00:00
|
|
|
if( Entry ) // if NULL : component not found
|
2009-09-18 14:56:05 +00:00
|
|
|
libCache->AddComponent( Entry );
|
2008-09-18 17:10:54 +00:00
|
|
|
}
|
2008-12-10 16:49:53 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
if( !libCache->Save( ArchFullFileName ) )
|
2008-12-10 16:49:53 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
msg.Printf( _( "An error occurred attempting to save component \
|
2009-10-16 17:18:23 +00:00
|
|
|
library <%s>." ), GetChars( ArchFullFileName ) );
|
2008-12-10 16:49:53 +00:00
|
|
|
DisplayError( frame, msg );
|
2009-09-18 14:56:05 +00:00
|
|
|
return false;
|
2008-12-10 16:49:53 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
return true;
|
2008-12-10 16:49:53 +00:00
|
|
|
}
|