From e9eb5a5e212f4a406006916471e4f6d4bb68dcca Mon Sep 17 00:00:00 2001 From: "Marcus A. Romer" <5656753-aimylios@users.noreply.gitlab.com> Date: Sat, 20 Mar 2021 16:41:34 +0100 Subject: [PATCH] Refactor definition of stock data path It is not always useful to distinguish between the cases when KiCad is run from the build or the installation directory. E.g., the libraries are generally not available in the same path as the code. Make the evaluation of KICAD_RUN_FROM_BUILD_DIR conditional to accomodate these scenarios. --- common/paths.cpp | 28 +++++++--------------------- include/paths.h | 2 +- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/common/paths.cpp b/common/paths.cpp index 52f9b82be8..6526f43d3f 100644 --- a/common/paths.cpp +++ b/common/paths.cpp @@ -137,11 +137,11 @@ wxString PATHS::GetDefaultUserProjectsPath() } -wxString PATHS::GetStockDataPath() +wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir ) { wxString path; - if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) + if( aRespectRunFromBuildDir && wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) { // Allow debugging from build dir by placing relevant files/folders in the build root path = Pgm().GetExecutablePath() + wxT( ".." ); @@ -165,15 +165,7 @@ wxString PATHS::GetStockScriptingPath() { wxString path; - if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) - { - // Allow debugging from build dir by placing a "scripting" folder in the build root - path = Pgm().GetExecutablePath() + wxT( "../scripting" ); - } - else - { - path = GetStockDataPath() + wxT( "/scripting" ); - } + path = GetStockDataPath() + wxT( "/scripting" ); return path; } @@ -183,18 +175,12 @@ wxString PATHS::GetStockPluginsPath() { wxFileName fn; -#if defined( __WXMAC__ ) - fn.Assign( PATHS::GetOSXKicadDataDir() ); - fn.AppendDir( wxT( "plugins" ) ); -#elif defined( __WXMSW__ ) - fn.Assign( Pgm().GetExecutablePath() + wxT( "/plugins/" ) ); +#if defined( __WXMSW__ ) + fn.AssignDir( Pgm().GetExecutablePath() ); #else - // KICAD_DATA is the absolute path - // corresponding to the install path used for constructing KICAD_USER_PLUGIN - wxString tfname = wxString::FromUTF8Unchecked( KICAD_DATA ); - fn.Assign( tfname, "" ); - fn.AppendDir( wxT( "plugins" ) ); + fn.AssignDir( PATHS::GetStockDataPath( false ) ); #endif + fn.AppendDir( wxT( "plugins" ) ); return fn.GetPathWithSep(); } diff --git a/include/paths.h b/include/paths.h index 9b0601f982..a158b25eca 100644 --- a/include/paths.h +++ b/include/paths.h @@ -70,7 +70,7 @@ public: /** * Gets the stock (install) data path, which is the base path for things like scripting, etc */ - static wxString GetStockDataPath(); + static wxString GetStockDataPath( bool aRespectRunFromBuildDir = true ); /** * Gets the stock (install) scripting path