From fb9e5b94ca2d089fe9fcdde9b79a55b98cae7ea2 Mon Sep 17 00:00:00 2001 From: Marco Serantoni Date: Sat, 15 Feb 2014 11:01:27 +0100 Subject: [PATCH] [MacOSX] support for plugins in the bundle --- pcbnew/CMakeLists.txt | 10 +++++++++- pcbnew/pcbnew.cpp | 8 ++++---- scripting/kicadplugins.i | 7 +++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index c1cf74bd32..6845afbdc1 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -607,6 +607,13 @@ if( KICAD_SCRIPTING ) DEPENDS FixSwigImportsScripting _pcbnew_py_copy COMMENT "Copying wxPython into pcbnew.app Framework" ) + + add_custom_target( pcbnew_copy_plugins ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/pcbnew/scripting/plugins ${PROJECT_SOURCE_DIR}/pcbnew/pcbnew.app/Contents/PlugIns/scripting/plugins + DEPENDS pcbnew_copy_wxpython_scripting + COMMENT "Copying plugins into bundle" + ) + # fix bundle after copying wxpython, fixing and copying add_dependencies( osx_fix_bundles pcbnew_copy_wxpython_scripting ) endif() @@ -636,10 +643,11 @@ if( KICAD_SCRIPTING_MODULES ) ) add_custom_target( pcbnew_copy_wxpython_module ALL - COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBWXPYTHON_ROOT}/wxPython ${CMAKE_SOURCE_DIR}/pcbnew/pcbnew.app/Contents/Frameworks/wxPython + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBWXPYTHON_ROOT}/wxPython ${PROJECT_SOURCE_DIR}/pcbnew/pcbnew.app/Contents/Frameworks/wxPython DEPENDS FixSwigImportsModuleScripting _pcbnew_so_copy COMMENT "Copying wxPython into pcbnew.app Frameworks" ) + # Tell that we have to run osx_fix_bundles fix after building _pcbnew and migrating wxPython add_dependencies( osx_fix_bundles pcbnew_copy_wxpython_module ) add_dependencies( osx_fix_bundles _pcbnew ) diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index d070e1825f..a7b4db9f4c 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -170,11 +170,11 @@ bool EDA_APP::OnInit() // Prepend in PYTHONPATH the content of the bundle libraries ! wxSetEnv("PYTHONPATH",((wxGetenv("PYTHONPATH") != NULL ) ? (wxString(wxGetenv("PYTHONPATH")) + ":") : wxString("")) + - "/Library/Application Support/kicad/scripting" + ":" + - bundledir.GetPath() + "/PlugIns" + ":" + - wxString( wxGetenv("HOME") ) + "/Library/Application Support/kicad/scripting" + bundledir.GetPath() + - "/Frameworks/wxPython/lib/python2.6/site-packages/wx-3.0-osx_cocoa" + "/Frameworks/wxPython/lib/python2.6/site-packages/wx-3.0-osx_cocoa" + ":" + + "/Library/Application Support/kicad/" + ":" + + bundledir.GetPath() + "/PlugIns" + ":" + + wxString( wxGetenv("HOME") ) + "/Library/Application Support/kicad/" ); #endif #endif diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i index 32679ed69e..7a79f31588 100644 --- a/scripting/kicadplugins.i +++ b/scripting/kicadplugins.i @@ -80,11 +80,14 @@ def LoadPlugins( plugpath ): if kicad_path and os.path.isdir(kicad_path): plugin_directories.append(os.path.join(kicad_path, 'scripting', 'plugins')) - if sys.platform.startswith('linux') or sys.platform.startswith('darwin'): + if sys.platform.startswith('linux'): plugin_directories.append(os.environ['HOME']+'/.kicad_plugins/') plugin_directories.append(os.environ['HOME']+'/.kicad/scripting/plugins/') - + if sys.platform.startswith('darwin'): + for singlepath in sys.path: + if os.path.isdir( os.path.join( singlepath, 'scripting', 'plugins') ): + plugin_directories.append( os.path.join( singlepath, 'scripting', 'plugins') ) for plugins_dir in plugin_directories: sys.path.append(plugins_dir)