Commit 5d0dee13 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

Adam Vašíček patches for WIN32 compilation of kicad scripting

parent 4f01bedf
......@@ -129,6 +129,14 @@ if(USE_WX_OVERLAY OR APPLE)
add_definitions(-DUSE_WX_OVERLAY)
endif(USE_WX_OVERLAY OR APPLE)
if(KICAD_SCRIPTING)
add_definitions(-DKICAD_SCRIPTING)
endif(KICAD_SCRIPTING)
if(KICAD_SCRIPTING_MODULES)
add_definitions(-DKICAD_SCRIPTING_MODULES)
endif(KICAD_SCRIPTING_MODULES)
if(USE_WX_GRAPHICS_CONTEXT)
add_definitions(-DUSE_WX_GRAPHICS_CONTEXT)
......
......@@ -539,7 +539,15 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
tmp << wxT( "OFF\n" );
#endif
tmp << wxT( " USE_BOOST_POLYGON_LIBRARY" );
tmp << wxT( " USE_BOOST_POLYGON_LIBRARY\n" );
tmp << wxT( " KICAD_SCRIPTING=" );
#ifdef KICAD_SCRIPTING
tmp << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
#endif
wxTheClipboard->SetData( new wxTextDataObject( tmp ) );
wxTheClipboard->Close();
......
......@@ -8,8 +8,9 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
INCLUDE(${SWIG_USE_FILE})
FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
add_definitions(-DPCBNEW -DKICAD_SCRIPTING)
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKICAD_SCRIPTING -DKICAD_SCRIPTING_MODULES")
endif(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
###
# Includes
......@@ -259,7 +260,7 @@ if (KICAD_SCRIPTING)
pcbnew_wrap.cxx
${PCBNEW_SCRIPTING_PYTHON_HELPERS}
)
endif()
endif(KICAD_SCRIPTING)
##
# Scripting build
......@@ -270,7 +271,7 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
set(SWIG_FLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/../.. -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}/../include -I${CMAKE_CURRENT_SOURCE_DIR}/../scripting )
if (DEBUG)
set(SWIG_FLAGS ${SWIG_FLAGS} -DDEBUG)
endif()
endif(DEBUG)
# collect CFLAGS , and pass them to swig later
get_directory_property( DirDefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS )
......@@ -281,12 +282,13 @@ if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
# check if we have IO_MGR and KICAD_PLUGIN available
if ( USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE )
SET(SWIG_FLAGS ${SWIG_FLAGS} -DBUILD_WITH_PLUGIN)
endif()
endif(USE_NEW_PCBNEW_LOAD OR USE_NEW_PCBNEW_SAVE)
if ( USE_PCBNEW_NANOMETRES )
SET(SWIG_FLAGS ${SWIG_FLAGS} -DUSE_PCBNEW_NANOMETRES)
endif()
endif( USE_PCBNEW_NANOMETRES )
endif()
endif(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
if (KICAD_SCRIPTING)
......@@ -337,9 +339,9 @@ if (KICAD_SCRIPTING_MODULES)
endif (KICAD_SCRIPTING_MODULES)
if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
if ((KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) AND NOT WIN32)
set ( PCBNEW_EXTRA_LIBS "rt" )
endif (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
endif ((KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) AND NOT WIN32)
###
......@@ -459,9 +461,13 @@ if (KICAD_SCRIPTING_MODULES)
install(FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py
DESTINATION ${PYTHON_DEST})
if (WIN32)
install(FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.dso
DESTINATION ${PYTHON_DEST})
else(WIN32)
install(FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so
DESTINATION ${PYTHON_DEST})
endif(WIN32)
endif(KICAD_SCRIPTING_MODULES)
......
......@@ -45,10 +45,23 @@ def LoadPlugins():
import os
import sys
plugins_dir = os.environ['HOME']+'/.kicad_plugins/'
# Use environment variable KICAD_PATH to derive path to plugins as a temporary solution
kicad_path = os.environ.get('KICAD_PATH')
plugin_directories=[]
sys.path.append(plugins_dir)
if kicad_path and os.path.isdir(kicad_path):
plugin_directories.append(os.path.join(kicad_path, 'scripting', 'plugins'))
if sys.platform.startswith('linux'):
plugin_directories.append(os.environ['HOME']+'/.kicad_plugins/')
plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/plugins/')
# scan all possible directories for plugins, and load them
for plugins_dir in plugin_directories:
sys.path.append(plugins_dir)
if not os.path.isdir(plugins_dir):
continue
for module in os.listdir(plugins_dir):
if os.path.isdir(plugins_dir+module):
__import__(module, locals(), globals())
......
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