Commit ecca7434 authored by Dick Hollenbeck's avatar Dick Hollenbeck

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.
parent 076c2c76
...@@ -134,9 +134,12 @@ if( CMAKE_COMPILER_IS_GNUCXX ) ...@@ -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" )
......
...@@ -97,8 +97,11 @@ if( BUILD_GITHUB_PLUGIN ) ...@@ -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 ) ...@@ -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
......
...@@ -295,7 +295,7 @@ if( KICAD_SCRIPTING ) ...@@ -295,7 +295,7 @@ if( KICAD_SCRIPTING )
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
DEPENDS pcbcommon DEPENDS pcbcommon
DEPENDS scripting/pcbnew.i DEPENDS scripting/pcbnew.i
DEPENDS scripting/board.i DEPENDS scripting/board.i
...@@ -310,7 +310,7 @@ if( KICAD_SCRIPTING ) ...@@ -310,7 +310,7 @@ if( KICAD_SCRIPTING )
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docstrings 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 ${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 ${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 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} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
...@@ -322,8 +322,13 @@ endif() ...@@ -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 ) ...@@ -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}
...@@ -351,10 +357,10 @@ if( KICAD_SCRIPTING_MODULES ) ...@@ -351,10 +357,10 @@ if( KICAD_SCRIPTING_MODULES )
# create .i files from XML doxygen parsing, docstrings.i will include all of them # create .i files from XML doxygen parsing, docstrings.i will include all of them
add_custom_target( qa add_custom_target( qa
COMMAND PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${PYTHON_EXECUTABLE} test.py COMMAND PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${PYTHON_EXECUTABLE} test.py
COMMENT "running qa" COMMENT "running qa"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripting/qa WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripting/qa
) )
endif() endif()
...@@ -366,7 +372,7 @@ endif() ...@@ -366,7 +372,7 @@ endif()
find_package( Doxygen ) find_package( Doxygen )
if( DOXYGEN_FOUND ) if( DOXYGEN_FOUND )
if( KICAD_SCRIPTING ) if( KICAD_SCRIPTING )
# create XML files from doxygen parsing # create XML files from doxygen parsing
add_custom_target( doxygen-python-xml add_custom_target( doxygen-python-xml
${CMAKE_COMMAND} -E remove_directory doxygen-python-xml ${CMAKE_COMMAND} -E remove_directory doxygen-python-xml
...@@ -377,22 +383,22 @@ if( DOXYGEN_FOUND ) ...@@ -377,22 +383,22 @@ if( DOXYGEN_FOUND )
) )
# create .i files from XML doxygen parsing, docstrings.i will include all of them # 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 remove_directory docstrings
COMMAND ${CMAKE_COMMAND} -E make_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 ${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 COMMAND ${CMAKE_COMMAND} -E remove pcbnew.py # force removal so it will be recreated later with the new docstrings
COMMENT "building docstring files" COMMENT "building docstring files"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS pcbnew.py DEPENDS pcbnew.py
DEPENDS doxygen-python-xml DEPENDS doxygen-python-xml
) )
# create doxygen-python html # create doxygen-python html
add_custom_target( doxygen-python add_custom_target( doxygen-python
${CMAKE_COMMAND} -E remove_directory 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} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS Doxyfile_python DEPENDS Doxyfile_python
DEPENDS xml-to-docstrings DEPENDS xml-to-docstrings
......
...@@ -23,6 +23,7 @@ ...@@ -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 ) ...@@ -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,17 +200,26 @@ IO_MGR::PCB_FILE_T IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath ...@@ -199,17 +200,26 @@ 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
else // *.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 )
{ {
// Although KICAD PLUGIN uses libpaths with fixed extension of
// KiCadFootprintLibPathExtension, we don't make that assumption since
// a default choice is needed.
ret = KICAD; ret = KICAD;
} }
else
{
// 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; return ret;
} }
......
#!/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 )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment