Cleanup the 3d plugins paths a little bit

This commit is contained in:
Marek Roszko 2021-01-23 10:46:48 -05:00
parent 8622565480
commit 14327f3708
3 changed files with 68 additions and 30 deletions

View File

@ -34,8 +34,9 @@
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/string.h> #include <wx/string.h>
#include "common.h" #include <common.h>
#include "pgm_base.h" #include <paths.h>
#include <pgm_base.h>
#include "3d_plugin_dir.h" #include "3d_plugin_dir.h"
#include "3d_plugin_manager.h" #include "3d_plugin_manager.h"
#include "plugins/3d/3d_plugin.h" #include "plugins/3d/3d_plugin.h"
@ -152,34 +153,12 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
} }
#endif #endif
#ifndef _WIN32 fn.AssignDir( PATHS::GetStockPlugins3DPath() );
// PLUGINDIR = CMAKE_INSTALL_FULL_LIBDIR path is the absolute path
// corresponding to the install path used for constructing KICAD_USER_PLUGIN
wxString tfname = wxString::FromUTF8Unchecked( PLUGINDIR );
fn.Assign( tfname, "" );
fn.AppendDir( "kicad" );
#else
// on windows the plugins directory is within the executable's directory
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
#endif
fn.AppendDir( wxT( "plugins" ) );
fn.AppendDir( wxT( "3d" ) );
// checks plugin directory relative to executable path
checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths ); checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths );
// check for per-user third party plugins // check for per-user third party plugins
// note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name; // note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name;
fn.Assign( wxStandardPaths::Get().GetUserDataDir(), "" ); fn.AssignDir( PATHS::GetUserPlugins3DPath() );
fn.RemoveLastDir();
#ifdef _WIN32
fn.AppendDir( wxT( "kicad" ) );
#else
fn.AppendDir( wxT( ".kicad" ) );
#endif
fn.AppendDir( wxT( "plugins" ) );
fn.AppendDir( wxT( "3d" ) );
checkPluginPath( fn.GetPathWithSep(), searchpaths ); checkPluginPath( fn.GetPathWithSep(), searchpaths );
#else #else
@ -191,10 +170,7 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
checkPluginPath( GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths ); checkPluginPath( GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
// (3) Bundle kicad.app/Contents/PlugIns/3d // (3) Bundle kicad.app/Contents/PlugIns/3d
fn.Assign( Pgm().GetExecutablePath() ); fn.AssignDir( PATHS::GetStockPluginsPath() );
fn.AppendDir( wxT( "Contents" ) );
fn.AppendDir( wxT( "PlugIns" ) );
fn.AppendDir( wxT( "3d" ) );
checkPluginPath( fn.GetPathWithSep(), searchpaths ); checkPluginPath( fn.GetPathWithSep(), searchpaths );
#endif #endif

View File

@ -7,6 +7,30 @@
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
wxString PATHS::GetUserPluginsPath()
{
wxFileName tmp;
tmp.AssignDir( KIPLATFORM::ENV::GetDocumentsDir() );
tmp.AppendDir( "kicad" );
tmp.AppendDir( SETTINGS_MANAGER::GetSettingsVersion() );
tmp.AppendDir( "plugins" );
return tmp.GetFullPath();
}
wxString PATHS::GetUserPlugins3DPath()
{
wxFileName tmp;
tmp.AssignDir( PATHS::GetUserPluginsPath() );
tmp.AppendDir( "3d" );
return tmp.GetFullPath();
}
wxString PATHS::GetUserScriptingPath() wxString PATHS::GetUserScriptingPath()
{ {
wxFileName tmp; wxFileName tmp;
@ -68,4 +92,38 @@ wxString PATHS::GetStockScriptingPath()
} }
return path; return path;
}
wxString PATHS::GetStockPluginsPath()
{
wxFileName fn;
#if defined( __WXMAC__ )
fn.Assign( Pgm().GetExecutablePath() );
fn.AppendDir( wxT( "Contents" ) );
fn.AppendDir( wxT( "PlugIns" ) );
#elif defined( __WXMSW__ )
fn.Assign( Pgm().GetExecutablePath() + wxT( "../plugins/" ) );
#else
// PLUGINDIR = CMAKE_INSTALL_FULL_LIBDIR path is the absolute path
// corresponding to the install path used for constructing KICAD_USER_PLUGIN
wxString tfname = wxString::FromUTF8Unchecked( PLUGINDIR );
fn.Assign( tfname, "" );
fn.AppendDir( "kicad" );
fn.AppendDir( wxT( "plugins" ) );
#endif
return fn.GetPathWithSep();
}
wxString PATHS::GetStockPlugins3DPath()
{
wxFileName fn;
fn.Assign( PATHS::GetStockPluginsPath() );
fn.AppendDir( "3d" );
return fn.GetPathWithSep();
} }

View File

@ -7,8 +7,12 @@ class PATHS
public: public:
static wxString GetUserScriptingPath(); static wxString GetUserScriptingPath();
static wxString GetUserTemplatesPath(); static wxString GetUserTemplatesPath();
static wxString GetUserPluginsPath();
static wxString GetUserPlugins3DPath();
static wxString GetDefaultUserProjectsPath(); static wxString GetDefaultUserProjectsPath();
static wxString GetStockScriptingPath(); static wxString GetStockScriptingPath();
static wxString GetStockPluginsPath();
static wxString GetStockPlugins3DPath();
}; };
#endif #endif