27#include <wx/translation.h>
44 wxS(
"KICAD_USER_TEMPLATE_DIR" ),
45 wxS(
"KICAD_PTEMPLATES" ),
79 return wxString::Format(
"KICAD%d_%s", version, aBaseName );
84 const wxString& aBaseName )
88 if( aMap.count( exactMatch ) )
89 return aMap.at( exactMatch ).GetValue();
91 wxString partialMatch = wxString::Format(
"KICAD*_%s", aBaseName );
93 for(
const auto& [k, v] : aMap )
95 if( k.Matches( partialMatch ) )
108 _(
"The base path of locally installed system "
109 "footprint libraries (.pretty folders).");
111 _(
"The base path of system footprint 3D shapes (.3Dshapes folders).");
113 _(
"The base path of the locally installed symbol libraries.");
115 _(
"A directory containing project templates installed with KiCad.");
116 aMap[wxS(
"KICAD_USER_TEMPLATE_DIR" )] =
117 _(
"Optional. Can be defined if you want to create your own project "
118 "templates folder.");
120 _(
"A directory containing 3rd party plugins, libraries and other "
121 "downloadable content.");
122 aMap[wxS(
"KIPRJMOD" )] =
123 _(
"Internally defined by KiCad (cannot be edited) and is set "
124 "to the absolute path of the currently loaded project file. This environment "
125 "variable can be used to define files and paths relative to the currently loaded "
126 "project. For instance, ${KIPRJMOD}/libs/footprints.pretty can be defined as a "
127 "folder containing a project specific footprint library named footprints.pretty." );
129 _(
"A directory containing system-wide scripts installed with KiCad" );
131 _(
"A directory containing user-specific scripts installed with KiCad" );
134#define DEP( var ) wxString::Format( _( "Deprecated version of %s." ), var )
136 aMap[wxS(
"KICAD_PTEMPLATES" )] =
150 if( envVarHelpText.size() == 0 )
153 return envVarHelpText[ aEnvVar ];
162 if( wxGetEnv( aEnvVarName, &env ) )
166 if( env.ToDouble( &value ) )
177 std::optional<wxString> optValue;
181 if( wxGetEnv( aEnvVarName, &env ) )
const std::tuple< int, int, int > & GetMajorMinorPatchTuple()
Get the build version numbers as a tuple.
static const ENV_VAR::ENV_VAR_LIST predefinedEnvVars
List of pre-defined environment variables.
static void initialiseEnvVarHelp(STRING_MAP &aMap)
std::map< wxString, wxString > STRING_MAP
const wxRegEx versionedEnvVarRegex(wxS("KICAD[0-9]+_[A-Z0-9_]+(_DIR)?"))
Functions related to environment variables, including help functions.
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
KICOMMON_API wxString LookUpEnvVarHelp(const wxString &aEnvVar)
Look up long-form help text for a given environment variable.
KICOMMON_API std::optional< VAL_TYPE > GetEnvVar(const wxString &aEnvVarName)
Get an environment variable as a specific type, if set correctly.
KICOMMON_API const ENV_VAR_LIST & GetPredefinedEnvVars()
Get the list of pre-defined environment variables.
KICOMMON_API std::optional< wxString > GetVersionedEnvVarValue(const std::map< wxString, ENV_VAR_ITEM > &aMap, const wxString &aBaseName)
Attempt to retrieve the value of a versioned environment variable, such as KICAD8_TEMPLATE_DIR.
KICOMMON_API wxString GetVersionedEnvVarName(const wxString &aBaseName)
Construct a versioned environment variable based on this KiCad major version.
KICOMMON_API bool IsEnvVarImmutable(const wxString &aEnvVar)
Determine if an environment variable is "predefined", i.e.
std::vector< wxString > ENV_VAR_LIST