From e51810cb65d35afbbc3c55bade1b6aae780b4ebb Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 27 Jan 2012 19:56:06 +0100 Subject: [PATCH] Restore INSTALL.txt, erroneously removed. Pcbnew: minor code change in netlist functions. --- INSTALL.txt | 215 ++++++++++++++++++++++++++ pcbnew/netlist.cpp | 81 +++++++--- pcbnew/netlist_reader.h | 26 +++- pcbnew/netlist_reader_firstformat.cpp | 2 +- pcbnew/netlist_reader_kicad.cpp | 2 +- 5 files changed, 296 insertions(+), 30 deletions(-) create mode 100644 INSTALL.txt diff --git a/INSTALL.txt b/INSTALL.txt new file mode 100644 index 0000000000..d77f83ebf6 --- /dev/null +++ b/INSTALL.txt @@ -0,0 +1,215 @@ +KiCad installation +================== + +The parts of KiCad +------------------ +KiCad consists of 3 packages: + +kicad - KiCad programs and core files. +kicad-doc - Documentation and interactive help (optional package). +kicad-library - KiCad schematic, pcb & 3D-model libraries (optional package). + + +Installation from binary packages +--------------------------------- + + KiCad binary packages exist for Linux and Windows (XP, 2000). + + Data files (schematic, boards, libraries) are compatible with all platforms. + +*.zip - KiCad packages for Windows. +*.tbz2 - KiCad for Linux. + + +Installation from binary packages for Windows +--------------------------------------------- + + KiCad can be installed in 'C:\kicad', 'D:\kicad', 'C:\Program files\kicad', +'D:\Program files\kicad'. + + For example, for an installation in the folder 'C:\kicad', unzip KiCad +packages: + + kicad-{version}.zip + kicad-doc-{version}.zip + kicad-library-{version}.zip + +to the folder 'C:\kicad'. + + The main program is the project manager (kicad.exe) and from it you can run +the other programs (schematic editor - eeschema, pcb editor - pcbnew, +utilities: cvpcb and gerbview). + + You can create a shortcut to 'C:\kicad\bin\kicad.exe'. + + +Installation from binary packages for Linux +------------------------------------------- + + KiCad can be installed in '/usr' or '/usr/local'. + + You must have "root" access for installation. + + cd / + tar -xjf kicad-{version}.tbz2 + tar -xjf kicad-doc-{version}.tbz2 + tar -xjf kicad-library-{version}.tbz2 + + The main program is '/usr/bin/kicad'. + + +Windows KiCad tree +------------------ + +kicad/bin - Binaries (executable files). +kicad/doc - Various documentation. +kicad/doc/help - Interactive help. +kicad/share/demos - Sample schematics and printed boards. +kicad/share/internat - Interface localization files. +kicad/share/library - Libraries for schematic. +kicad/share/modules - Module libraries for printed boards. +kicad/share/modules/packages3d - 3D component models (.wrl and .wings format). + + Files '*.mod' are libraries, and files '*.brd' are printed boards you can +view with pcbnew. + Files *.brd show the existing modules (and 3D shapes) in libraries. + + +Linux KiCad tree +---------------- +KiCad can use the Windows tree or the below tree. +When Kicad is coming from Linux distribution, the tree is: + +/usr/bin - Binaries (executable files). +/usr/share/doc/kicad/ - Various documentation. +/usr/share/doc/kicad/help - Interactive help. +/usr/share/kicad/demos - Sample schematics and printed boards. +/usr/share/kicad/internat - Dictionaries for interface localization. +/usr/share/kicad/library - Interface localization files. +/usr/share/kicad/modules - Module libraries for printed boards. +/usr/share/kicad/modules/packages3d - 3D component models (.wrl and .wings format). + +if KiCad does not found its files in usr/share, the search is made in +/usr/local/kicad +and kicad uses the same tree as the Windows KiCad tree above + +*** When KiCad comes from .tgz archive from http://iut-tice.ujf-grenoble.fr/cao/, +it must me installed in /usr/local and uses the Windows tree ***. + + + Files '*.mod' are the libraries, and files '*.brd' are printed boards you can +view with pcbnew. + Files *.brd show the existing modules (and 3D shapes) in libraries. + +Warning: +Do not change the KiCad tree, or the location of binary files, +else KiCad will not be able to find its required files (configuration, +libraries, etc.). + +Mac OS X KiCad tree +------------------- + +System wide files + +/Library/Application Support/kicad/demos +/Library/Application Support/kicad/internat +/Library/Application Support/kicad/library +/Library/Application Support/kicad/modules +/Library/Application Support/kicad/modules/packages3d + +User files can be the same as the system wide files but only inside the users home directory. + +$HOME/Library/Application Support/kicad + +Warning: +These paths are hardcoded into KiCad, if you put them somewhere else KiCad will not find them when a new +project is created. + +Installation from source code +----------------------------- + + Some dependencies must be satisfied for the correct installation of KiCad: +under Linux: +wxWidgets >= 2.8.11 http://www.wxwidgets.org/ +under Windows:MacOSX +wxWidgets >= 2.9.3 http://www.wxwidgets.org/ +CMake >= 2.6.4 http://www.cmake.org/ +Boost C++ Libraries (files used by kicad are provided in kicad sources) http://www.boost.org/ +OpenGL + Linux: Mesa 3D Graphics Library http://www.mesa3d.org/ + Windows: built-in +Zlib Compression Library http://www.zlib.net/ + + In source-tree-build are mostly unwanted, so make a subdir called "build" and +change to it. + + Call cmake with the path to KiCad. E.g., when your build-folder is "build" +within source-tree, type "cmake ../". + + Now your system get checked if it is able compiling KiCad and cmake generates +the Makefiles. + + After calling cmake just type "make" and build begins. + + It is easy to build only a specific binary such as pcbnew alone: + make pcbnew + + After "make" type "make install" and install begins. + + You may install to a temporary-root with + make install DESTDIR= + + If you want to uninstall KiCad again type "make uninstall" from within the +build directory. + + +Important parameters to cmake +----------------------------- + +-DCMAKE_BUILD_TYPE= + may current one of "Debug" and "Release". + +-DCMAKE_INSTALL_PREFIX= +Default to "/usr/local". + +-DwxWidgets_ROOT_DIR= +Required for Windows platform. + +-DwxWidgets_USE_DEBUG=ON +Can be used only with -DCMAKE_BUILD_TYPE=Debug + +-DwxWidgets_USE_STATIC=ON +For building statically linked executables. Can be used only if wxWidgets +configured and builded with "--enable-monolithic --disable-shared" parameters. + +-DwxWidgets_USE_STATIC=OFF +For building dinamically linked executables. Can be used only if wxWidgets +configured and builded with "--disable-monolithic --enable-shared" parameters. + +-DwxUSE_UNICODE=ON +Require on locale utf8 for build the KiCad with cyrillic fonts support. + +-DKICAD_GOST=ON +Build the KiCad with russian GOST support. + +-DKICAD_KEEPCASE=ON +Build the KiCad with no component name conversion to uppercase (if you want your +ADuC.../Si.../bq... components named as just so). + +-DCMAKE_CXX_FLAGS= +Extra flags for the c++ compiler for your system required. + +-DCMAKE_VERBOSE_MAKEFILE=ON +When more output is wanted use this cmake parameter or call "make VERBOSE=1". + + +Extra CFLAGS and linker flags +----------------------------- + + If you require extra flags for compiler and linker you may give them via +environment variables + "CXXFLAGS" (c++ compiler) + "LDFLAGS" (for linker) + "CFLAGS" (for c-compiler, not needed in kdesvn build) + +eg., it may usefull on 64bit systems "-m64" to CXXFLAGS and LDFLAGS. diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index d7ccdb184b..bad6148344 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -50,7 +50,6 @@ */ -#include #include #include @@ -69,6 +68,7 @@ #include +#include /** * Function OpenNetlistFile @@ -168,7 +168,12 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename, netList_Reader.m_UseCmpFile = useCmpfile; netList_Reader.SetFilesnames( aNetlistFullFilename, aCmpFullFileName ); - netList_Reader.ReadNetList( netfile ); + bool success = netList_Reader.ReadNetList( netfile ); + if( !success ) + { + wxMessageBox( _("Netlist read error (unrecognized format)") ); + return false; + } // Delete footprints not found in netlist: if( aDeleteExtraFootprints ) @@ -202,29 +207,65 @@ bool PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFullFilename, bool NETLIST_READER::ReadNetList( FILE* aFile ) { // Try to determine the netlist type: - bool new_fmt = true; - std::string header( "(export" ); - for( unsigned ii = 0; ii < header.size(); ii++ ) + // Beginning of the first line of known formats, without spaces + #define HEADERS_COUNT 3 + #define HEADER_ORCADPCB "({EESchemaNetlist" + #define HEADER_PCB1 "#EESchemaNetlist" + #define HEADER_KICAD_NETFMT "(export" + const std::string headers[HEADERS_COUNT] = { - int data; - do - { - data = fgetc( aFile ); - } while ( ( data == ' ' ) &&( EOF != data ) ) ; + HEADER_ORCADPCB, HEADER_PCB1, HEADER_KICAD_NETFMT + }; - if( (int)header[ii] == data ) - continue; - new_fmt = false; - break; + int format = -1; + for ( int jj = 0; jj < HEADERS_COUNT; jj++ ) + { + int imax = headers[jj].size(); + int ii = 0; + for( ; ii < imax; ii++ ) + { + int data; + // Read header, and skip blanks to avoid errors if an header changes + do + { + data = fgetc( aFile ); + } while ( ( data == ' ' ) &&( EOF != data ) ) ; + + if( (int)headers[jj][ii] == data ) + continue; + break; + } + if( ii == imax ) // header found + { + format = jj; + break; + } + rewind( aFile ); } rewind( aFile ); + bool success = false; + switch( format ) + { + case 0: + m_typeNetlist = NETLIST_TYPE_ORCADPCB2; + success = ReadOldFmtdNetList( aFile ); + break; - bool success; - if( new_fmt ) - success = ReadKicadNetList( aFile ); - else - success = ReadOldFmtdNetList( aFile ); + case 1: + m_typeNetlist = NETLIST_TYPE_PCB1; + success = ReadOldFmtdNetList( aFile ); + break; + + case 2: + m_typeNetlist = NETLIST_TYPE_KICAD; + success = ReadKicadNetList( aFile ); + break; + + default: // Unrecognized format: + break; + + } return success; } @@ -497,7 +538,7 @@ void PCB_EDIT_FRAME::Test_Duplicate_Missing_And_Extra_Footprints( // Build the list of references of the net list modules. NETLIST_READER netList_Reader( this ); netList_Reader.SetFilesnames( aNetlistFullFilename, wxEmptyString ); - netList_Reader.BuildModuleListOnly( true ); + netList_Reader.BuildModuleListOnlySetOpt( true ); if( ! netList_Reader.ReadNetList( netfile ) ) return; // error diff --git a/pcbnew/netlist_reader.h b/pcbnew/netlist_reader.h index 782a084c34..e394fa733f 100644 --- a/pcbnew/netlist_reader.h +++ b/pcbnew/netlist_reader.h @@ -68,6 +68,14 @@ public: MODULE_INFO( const wxString& libname, ~MODULE_INFO() { }; }; +enum typenetlist +{ + NETLIST_TYPE_UNSPECIFIED = 0, + NETLIST_TYPE_ORCADPCB2, // the basic format used by pcbnew + NETLIST_TYPE_PCB1, // the format used by pcbnew, basic format + more info + NETLIST_TYPE_KICAD +}; + /* * Helper class, to read a netlist. @@ -85,8 +93,9 @@ private: std::vector m_newModulesList; // The list of new footprints, // found in netlist, but not on board // (must be loaded from libraries) - bool m_BuildModuleListOnly; // if true read netlist, populates m_modulesInNetlist + bool m_buildModuleListOnly; // if true read netlist, populates m_modulesInNetlist // but do not read and change nets and modules on board + enum typenetlist m_typeNetlist; // type opt the netlist currently read public: bool m_UseCmpFile; // true to use .cmp files as component/footprint file link @@ -103,7 +112,8 @@ public: NETLIST_READER( PCB_EDIT_FRAME* aFrame, wxTextCtrl* aMessageWindow = NUL m_UseTimeStamp = false; m_ChangeFootprints = false; m_UseCmpFile = true; - m_BuildModuleListOnly = false; + m_buildModuleListOnly = false; + m_typeNetlist = NETLIST_TYPE_UNSPECIFIED; } ~NETLIST_READER() @@ -132,7 +142,7 @@ public: NETLIST_READER( PCB_EDIT_FRAME* aFrame, wxTextCtrl* aMessageWindow = NUL } /** - * Function BuildModuleListOnly + * Function BuildModuleListOnlySetOpt * Set to true or false the Build Module List Only option * When this option is false, a full netlist read is made, * and modules are added/modified @@ -140,19 +150,19 @@ public: NETLIST_READER( PCB_EDIT_FRAME* aFrame, wxTextCtrl* aMessageWindow = NUL * and only the list of modules found in netlist is built * @param aOpt = the value of option */ - void BuildModuleListOnly( bool aOpt ) + void BuildModuleListOnlySetOpt( bool aOpt ) { - m_BuildModuleListOnly = aOpt; + m_buildModuleListOnly = aOpt; } /** - * Function BuildModuleListOnly + * Function BuildModuleListOnlyOpt * Get the Build Module List Only option state * @return the state of option (true/false) */ - bool BuildModuleListOnly() + bool BuildModuleListOnlyOpt() { - return m_BuildModuleListOnly; + return m_buildModuleListOnly; } /** diff --git a/pcbnew/netlist_reader_firstformat.cpp b/pcbnew/netlist_reader_firstformat.cpp index 468ff3b436..c5e1324df3 100644 --- a/pcbnew/netlist_reader_firstformat.cpp +++ b/pcbnew/netlist_reader_firstformat.cpp @@ -118,7 +118,7 @@ bool NETLIST_READER::ReadOldFmtdNetList( FILE* aFile ) } } - if( BuildModuleListOnly() ) + if( BuildModuleListOnlyOpt() ) return true; // at this point, the module list is read and built. // Load new footprints diff --git a/pcbnew/netlist_reader_kicad.cpp b/pcbnew/netlist_reader_kicad.cpp index c2a0f37f9a..cfd605e0d7 100644 --- a/pcbnew/netlist_reader_kicad.cpp +++ b/pcbnew/netlist_reader_kicad.cpp @@ -147,7 +147,7 @@ void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) netlist_reader->AddModuleInfo( mod_info ); } } - if( netlist_reader->BuildModuleListOnly() ) + if( netlist_reader->BuildModuleListOnlyOpt() ) return; // at this point, the module list is read and built. // Load new footprints netlist_reader->InitializeModules();