Remove hard-coded versioned env vars in most places

This commit is contained in:
Jon Evans
2024-01-16 17:20:45 -05:00
parent 0cd59dc278
commit 7b0bb59b37
15 changed files with 187 additions and 79 deletions
+14 -5
View File
@@ -37,6 +37,7 @@
#include <string>
#include <eda_base_frame.h>
#include <env_vars.h>
#include <gal/color4d.h>
#include <gestfich.h>
#include <trace_helpers.h>
@@ -578,20 +579,28 @@ wxString SCRIPTING::PyScriptingPath( PATH_TYPE aPathType )
case STOCK:
path = PATHS::GetStockScriptingPath();
break;
case USER:
path = PATHS::GetUserScriptingPath();
break;
case THIRDPARTY:
const ENV_VAR_MAP& env = Pgm().GetLocalEnvVariables();
auto it = env.find( "KICAD7_3RD_PARTY" );
if( it != env.end() && !it->second.GetValue().IsEmpty() )
path = it->second.GetValue();
case THIRDPARTY:
{
const ENV_VAR_MAP& env = Pgm().GetLocalEnvVariables();
if( std::optional<wxString> v = ENV_VAR::GetVersionedEnvVarValue( env,
wxT( "3RD_PARTY" ) ) )
{
path = *v;
}
else
{
path = PATHS::GetDefault3rdPartyPath();
}
break;
}
}
wxFileName scriptPath( path );
scriptPath.MakeAbsolute();