28#include <wx/translation.h>
43 wxS(
"KICAD_USER_TEMPLATE_DIR" ),
44 wxS(
"KICAD_PTEMPLATES" ),
78 aVars->push_back( var );
88 return wxString::Format(
"KICAD%d_%s", version, aBaseName );
93 const wxString& aBaseName )
97 if( aMap.count( exactMatch ) )
98 return aMap.at( exactMatch ).GetValue();
100 wxString partialMatch = wxString::Format(
"KICAD*_%s", aBaseName );
102 for(
const auto& [k, v] : aMap )
104 if( k.Matches( partialMatch ) )
117 _(
"The base path of locally installed system footprint libraries (.pretty folders)." );
120 _(
"The base path of system footprint 3D shapes (.3Dshapes folders)." );
123 _(
"The base path of the locally installed symbol libraries." );
126 _(
"A directory containing project templates installed with KiCad." );
128 aMap[wxS(
"KICAD_USER_TEMPLATE_DIR" )] =
129 _(
"Optional. Can be defined if you want to create your own project templates folder." );
132 _(
"A directory containing 3rd party plugins, libraries and other downloadable content." );
134 aMap[wxS(
"KIPRJMOD" )] =
135 _(
"Internally defined by KiCad (cannot be edited) and is set to the absolute path of the currently "
136 "loaded project file. This environment variable can be used to define files and paths relative "
137 "to the currently loaded project. For instance, ${KIPRJMOD}/libs/footprints.pretty can be "
138 "defined as a folder containing a project specific footprint library named footprints.pretty." );
141 _(
"A directory containing system-wide scripts installed with KiCad." );
144 _(
"A directory containing user-specific scripts installed with KiCad." );
147#define DEP( var ) wxString::Format( _( "Deprecated version of %s." ), var )
160 static std::map<wxString, wxString> envVarHelpText;
162 if( envVarHelpText.size() == 0 )
165 return envVarHelpText[ aEnvVar ];
174 if( wxGetEnv( aEnvVarName, &env ) )
178 if( env.ToDouble( &value ) )
189 std::optional<wxString> optValue;
192 if( wxGetEnv( aEnvVarName, &env ) )
const std::tuple< int, int, int > & GetMajorMinorPatchTuple()
Get the build version numbers as a tuple.
static void initialiseEnvVarHelp(std::map< wxString, wxString > &aMap)
static const std::vector< wxString > predefinedEnvVars
List of pre-defined environment variables.
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 void GetEnvVarAutocompleteTokens(wxArrayString *aVars)
Return autocomplete tokens for environment variables for Scintilla.
KICOMMON_API std::optional< VAL_TYPE > GetEnvVar(const wxString &aEnvVarName)
Get an environment variable as a specific type, if set correctly.
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 const std::vector< wxString > & GetPredefinedEnvVars()
Get the list of pre-defined environment variables.
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.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.