GITHUB_PLUGIN now builds under the scripting DSO on linux.

Enhance IO_MGR::GuessPluginTypeFromLibPath() to support the GITHUB plugin.
Build boost with -fPIC on Linux unconditionally, in preparation for
DLL/DSO build of kicad.
Add python script to test back to back reads of GITHUB plugin.
This commit is contained in:
Dick Hollenbeck 2013-09-23 10:19:39 -05:00
parent 076c2c762a
commit ecca7434e1
5 changed files with 96 additions and 25 deletions

View File

@ -134,9 +134,12 @@ if( CMAKE_COMPILER_IS_GNUCXX )
else() else()
# We build DLL/DSOs from static libraries, so create position independent code # We build DLL/DSOs from static libraries, so create position independent code
# for all cases, since we do not have DLL/DSO specific static libraries. # for all cases, since we do not have DLL/DSO specific static libraries.
# This flag could be localized to any object file going into a DLL/DSO in the future. # Subdirectories via add_subdirectores() reference this variable, and it is either set or empty,
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" ) # empty for Windows.
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" ) set( PIC_FLAG -fPIC )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PIC_FLAG}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PIC_FLAG}" )
# Thou shalt not link vaporware and tell us it's a valid DSO: # Thou shalt not link vaporware and tell us it's a valid DSO:
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" ) set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )

View File

@ -97,8 +97,11 @@ if( BUILD_GITHUB_PLUGIN )
if( MINGW ) if( MINGW )
set( bootstrap "bootstart.bat mingw" ) set( bootstrap "bootstart.bat mingw" )
unset( PIC_STUFF )
else() else()
set( bootstrap bootstrap.sh ) set( bootstrap bootstrap.sh )
# pass to *both* C and C++ compilers
set( PIC_STUFF "cflags=${PIC_FLAG}" )
endif() endif()
ExternalProject_Add( boost ExternalProject_Add( boost
@ -116,13 +119,14 @@ if( BUILD_GITHUB_PLUGIN )
UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${BOOST_ROOT}" UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${BOOST_ROOT}"
BINARY_DIR "${PREFIX}/src/boost/" BINARY_DIR "${PREFIX}/src/boost/"
CONFIGURE_COMMAND ${bootstrap} CONFIGURE_COMMAND ./${bootstrap}
--with-libraries=${libs_csv} --with-libraries=${libs_csv}
BUILD_COMMAND b2 BUILD_COMMAND ./b2
variant=release variant=release
threading=multi threading=multi
toolset=gcc toolset=gcc
${PIC_STUFF}
#link=static #link=static
--prefix=<INSTALL_DIR> --prefix=<INSTALL_DIR>
install install

View File

@ -322,8 +322,13 @@ endif()
# _pcbnew DLL/DSO file creation # _pcbnew DLL/DSO file creation
### ###
unset( GITHUB_PLUGIN_LIBRARIES )
if( BUILD_GITHUB_PLUGIN )
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
endif()
if( ( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) AND NOT WIN32 AND NOT APPLE ) if( ( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) AND NOT WIN32 AND NOT APPLE )
set ( PCBNEW_EXTRA_LIBS "rt" ) list( APPEND PCBNEW_EXTRA_LIBS rt )
endif() endif()
@ -339,6 +344,7 @@ if( KICAD_SCRIPTING_MODULES )
pcbcommon pcbcommon
common common
pcad2kicadpcb pcad2kicadpcb
${GITHUB_PLUGIN_LIBRARIES}
polygon polygon
bitmaps bitmaps
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}

View File

@ -23,6 +23,7 @@
*/ */
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/uri.h>
#include <io_mgr.h> #include <io_mgr.h>
#include <legacy_plugin.h> #include <legacy_plugin.h>
@ -183,8 +184,8 @@ const wxString IO_MGR::GetFileExtension( PCB_FILE_T aFileType )
IO_MGR::PCB_FILE_T IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath ) IO_MGR::PCB_FILE_T IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath )
{ {
wxFileName fn = aLibPath; PCB_FILE_T ret = KICAD; // default guess, unless detected otherwise.
PCB_FILE_T ret; wxFileName fn( aLibPath );
if( fn.GetExt() == LegacyFootprintLibPathExtension ) if( fn.GetExt() == LegacyFootprintLibPathExtension )
{ {
@ -199,16 +200,25 @@ IO_MGR::PCB_FILE_T IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath
ret = EAGLE; ret = EAGLE;
} }
#if defined(BUILD_GITHUB_PLUGIN) // Test this one anyways, even thought its the default guess, to avoid
// There is no extension for a remote repo. We're thinking about this. // the wxURI instantiation below.
#endif // We default ret to KICAD above, because somebody might have
// mistakenly put a pretty library into a directory other than
// *.pretty/ with *.kicad_mod in there., and I don't want to return -1,
// since we only claimed to be guessing.
else if( fn.GetExt() == KiCadFootprintLibPathExtension )
{
ret = KICAD;
}
else else
{ {
// Although KICAD PLUGIN uses libpaths with fixed extension of // There is no extension for a remote repo, so test the server name.
// KiCadFootprintLibPathExtension, we don't make that assumption since wxURI uri( aLibPath );
// a default choice is needed.
ret = KICAD; if( uri.HasServer() && uri.GetServer() == wxT( "github.com" ) )
{
ret = GITHUB;
}
} }
return ret; return ret;

48
scripts/test_plugin.py Executable file
View File

@ -0,0 +1,48 @@
#!/usr/bin/python
# Convert a footprint library from one format to another, e.g. legacy to pretty.
# 1) Build target _pcbnew after enabling scripting in cmake.
# $ make _pcbnew
# 2) Changed dir to pcbnew
# $ cd pcbnew
# $ pwd
# build/pcbnew
# 3) Entered following command line, script takes to arguments: library_path [footprint_name]
# $ PYTHONPATH=. <path_to>/test_plugin.py https://github.com/liftoff-sr/pretty_footprints [100-LQFP]
from __future__ import print_function
from pcbnew import *
import sys
if len( sys.argv ) < 2 :
print( "usage: script <library_path> [<footprint_name>]" )
sys.exit(1)
src_libpath = sys.argv[1]
src_type = IO_MGR.GuessPluginTypeFromLibPath( src_libpath );
src_plugin = IO_MGR.PluginFind( src_type )
if len( sys.argv ) == 2:
list_of_footprints = src_plugin.FootprintEnumerate( src_libpath )
for fp in list_of_footprints:
print( fp )
elif len( sys.argv ) == 3:
# I had some concerns about back to back reads, this verifies it is no problem:
module = src_plugin.FootprintLoad( src_libpath, sys.argv[2] )
if not module:
print( "1st try: module", sys.argv[2], "not found" )
module = src_plugin.FootprintLoad( src_libpath, sys.argv[2] )
if not module:
print( "2nd try: module", sys.argv[2], "not found" )
print( module )