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:
parent
076c2c762a
commit
ecca7434e1
|
@ -134,9 +134,12 @@ if( CMAKE_COMPILER_IS_GNUCXX )
|
|||
else()
|
||||
# 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.
|
||||
# This flag could be localized to any object file going into a DLL/DSO in the future.
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
|
||||
# Subdirectories via add_subdirectores() reference this variable, and it is either set or empty,
|
||||
# empty for Windows.
|
||||
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:
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
|
||||
|
|
|
@ -97,8 +97,11 @@ if( BUILD_GITHUB_PLUGIN )
|
|||
|
||||
if( MINGW )
|
||||
set( bootstrap "bootstart.bat mingw" )
|
||||
unset( PIC_STUFF )
|
||||
else()
|
||||
set( bootstrap bootstrap.sh )
|
||||
# pass to *both* C and C++ compilers
|
||||
set( PIC_STUFF "cflags=${PIC_FLAG}" )
|
||||
endif()
|
||||
|
||||
ExternalProject_Add( boost
|
||||
|
@ -116,13 +119,14 @@ if( BUILD_GITHUB_PLUGIN )
|
|||
UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${BOOST_ROOT}"
|
||||
|
||||
BINARY_DIR "${PREFIX}/src/boost/"
|
||||
CONFIGURE_COMMAND ${bootstrap}
|
||||
CONFIGURE_COMMAND ./${bootstrap}
|
||||
--with-libraries=${libs_csv}
|
||||
|
||||
BUILD_COMMAND b2
|
||||
BUILD_COMMAND ./b2
|
||||
variant=release
|
||||
threading=multi
|
||||
toolset=gcc
|
||||
${PIC_STUFF}
|
||||
#link=static
|
||||
--prefix=<INSTALL_DIR>
|
||||
install
|
||||
|
|
|
@ -322,8 +322,13 @@ endif()
|
|||
# _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 )
|
||||
set ( PCBNEW_EXTRA_LIBS "rt" )
|
||||
list( APPEND PCBNEW_EXTRA_LIBS rt )
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -339,6 +344,7 @@ if( KICAD_SCRIPTING_MODULES )
|
|||
pcbcommon
|
||||
common
|
||||
pcad2kicadpcb
|
||||
${GITHUB_PLUGIN_LIBRARIES}
|
||||
polygon
|
||||
bitmaps
|
||||
${wxWidgets_LIBRARIES}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include <wx/filename.h>
|
||||
#include <wx/uri.h>
|
||||
|
||||
#include <io_mgr.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 )
|
||||
{
|
||||
wxFileName fn = aLibPath;
|
||||
PCB_FILE_T ret;
|
||||
PCB_FILE_T ret = KICAD; // default guess, unless detected otherwise.
|
||||
wxFileName fn( aLibPath );
|
||||
|
||||
if( fn.GetExt() == LegacyFootprintLibPathExtension )
|
||||
{
|
||||
|
@ -199,16 +200,25 @@ IO_MGR::PCB_FILE_T IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath
|
|||
ret = EAGLE;
|
||||
}
|
||||
|
||||
#if defined(BUILD_GITHUB_PLUGIN)
|
||||
// There is no extension for a remote repo. We're thinking about this.
|
||||
#endif
|
||||
|
||||
// Test this one anyways, even thought its the default guess, to avoid
|
||||
// the wxURI instantiation below.
|
||||
// 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
|
||||
{
|
||||
// Although KICAD PLUGIN uses libpaths with fixed extension of
|
||||
// KiCadFootprintLibPathExtension, we don't make that assumption since
|
||||
// a default choice is needed.
|
||||
ret = KICAD;
|
||||
// There is no extension for a remote repo, so test the server name.
|
||||
wxURI uri( aLibPath );
|
||||
|
||||
if( uri.HasServer() && uri.GetServer() == wxT( "github.com" ) )
|
||||
{
|
||||
ret = GITHUB;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -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 )
|
||||
|
||||
|
Loading…
Reference in New Issue