From 5d0dee1364a7b7bc6f692e2f4fc898da9f24e987 Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Sun, 22 Jul 2012 14:15:38 +0200 Subject: [PATCH] =?UTF-8?q?Adam=20Va=C5=A1=C3=AD=C4=8Dek=20patches=20for?= =?UTF-8?q?=20WIN32=20compilation=20of=20kicad=20scripting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 8 ++++++++ common/basicframe.cpp | 10 +++++++++- pcbnew/CMakeLists.txt | 30 ++++++++++++++++++------------ scripting/kicadplugins.i | 27 ++++++++++++++++++++------- 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 952cdd9d95..fca69e0902 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/common/basicframe.cpp b/common/basicframe.cpp index e9330c1959..d045a5cbb1 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -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(); diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index a180852ca7..7f8fc73183 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -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}) - - install(FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so - 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) diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i index b3b14d5743..300faad1a1 100644 --- a/scripting/kicadplugins.i +++ b/scripting/kicadplugins.i @@ -45,17 +45,30 @@ 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/') - for module in os.listdir(plugins_dir): - if os.path.isdir(plugins_dir+module): - __import__(module, locals(), globals()) + # scan all possible directories for plugins, and load them - if module == '__init__.py' or module[-3:] != '.py': + for plugins_dir in plugin_directories: + sys.path.append(plugins_dir) + if not os.path.isdir(plugins_dir): continue - __import__(module[:-3], locals(), globals()) + for module in os.listdir(plugins_dir): + if os.path.isdir(plugins_dir+module): + __import__(module, locals(), globals()) + + if module == '__init__.py' or module[-3:] != '.py': + continue + __import__(module[:-3], locals(), globals()) # KiCadPlugin base class will register any plugin into the right place