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
|
||||
|
|
|
@ -295,7 +295,7 @@ if( KICAD_SCRIPTING )
|
|||
|
||||
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
|
||||
|
||||
|
||||
DEPENDS pcbcommon
|
||||
DEPENDS scripting/pcbnew.i
|
||||
DEPENDS scripting/board.i
|
||||
|
@ -310,7 +310,7 @@ if( KICAD_SCRIPTING )
|
|||
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docstrings
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/docstrings/docstrings.i # this makes docstrings.i available if it doesn't exist
|
||||
|
||||
|
||||
COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx scripting/pcbnew.i
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
@ -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}
|
||||
|
@ -351,10 +357,10 @@ if( KICAD_SCRIPTING_MODULES )
|
|||
# create .i files from XML doxygen parsing, docstrings.i will include all of them
|
||||
add_custom_target( qa
|
||||
COMMAND PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${PYTHON_EXECUTABLE} test.py
|
||||
|
||||
|
||||
COMMENT "running qa"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripting/qa
|
||||
)
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
|
@ -366,7 +372,7 @@ endif()
|
|||
find_package( Doxygen )
|
||||
if( DOXYGEN_FOUND )
|
||||
if( KICAD_SCRIPTING )
|
||||
|
||||
|
||||
# create XML files from doxygen parsing
|
||||
add_custom_target( doxygen-python-xml
|
||||
${CMAKE_COMMAND} -E remove_directory doxygen-python-xml
|
||||
|
@ -377,22 +383,22 @@ if( DOXYGEN_FOUND )
|
|||
)
|
||||
|
||||
# create .i files from XML doxygen parsing, docstrings.i will include all of them
|
||||
add_custom_target( xml-to-docstrings
|
||||
add_custom_target( xml-to-docstrings
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory docstrings
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory docstrings
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/extract_docstrings.py pcbnew.py doxygen-xml/xml docstrings
|
||||
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E remove pcbnew.py # force removal so it will be recreated later with the new docstrings
|
||||
COMMENT "building docstring files"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS pcbnew.py
|
||||
DEPENDS doxygen-python-xml
|
||||
)
|
||||
)
|
||||
|
||||
# create doxygen-python html
|
||||
add_custom_target( doxygen-python
|
||||
${CMAKE_COMMAND} -E remove_directory doxygen-python
|
||||
COMMAND PYTHON_SOURCES_TO_DOC=${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile_python
|
||||
COMMAND PYTHON_SOURCES_TO_DOC=${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile_python
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS Doxyfile_python
|
||||
DEPENDS xml-to-docstrings
|
||||
|
|
|
@ -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