29#include <wx/translation.h>
44 wxS(
"KICAD_USER_TEMPLATE_DIR" ),
45 wxS(
"KICAD_PTEMPLATES" ),
73 aVars->push_back( var );
83 return wxString::Format(
"KICAD%d_%s", version, aBaseName );
89 static const wxString prefix = wxS(
"KICAD" );
90 const wxString suffix = wxS(
"_" ) + aBaseName;
92 if( !aName.StartsWith( prefix ) || !aName.EndsWith( suffix ) )
95 wxString version = aName.Mid( prefix.length(), aName.length() - prefix.length() - suffix.length() );
97 return !version.IsEmpty()
98 && std::all_of( version.begin(), version.end(),
99 []( wxUniChar c ) { return wxIsdigit( c ); } );
104 const wxString& aBaseName )
108 if( aMap.count( exactMatch ) )
109 return aMap.at( exactMatch ).GetValue();
111 for(
const auto& [k, v] : aMap )
126 _(
"The base path of locally installed system footprint libraries (.pretty folders)." );
129 _(
"The base path of system footprint 3D shapes (.3Dshapes folders)." );
132 _(
"The base path of the locally installed symbol libraries." );
135 _(
"A directory containing project templates installed with KiCad." );
137 aMap[wxS(
"KICAD_USER_TEMPLATE_DIR" )] =
138 _(
"Optional. Can be defined if you want to create your own project templates folder." );
141 _(
"A directory containing 3rd party plugins, libraries and other downloadable content." );
143 aMap[wxS(
"KIPRJMOD" )] =
144 _(
"Internally defined by KiCad (cannot be edited) and is set to the absolute path of the currently "
145 "loaded project file. This environment variable can be used to define files and paths relative "
146 "to the currently loaded project. For instance, ${KIPRJMOD}/libs/footprints.pretty can be "
147 "defined as a folder containing a project specific footprint library named footprints.pretty." );
150 _(
"A directory containing system-wide scripts installed with KiCad." );
153 _(
"A directory containing user-specific scripts installed with KiCad." );
156#define DEP( var ) wxString::Format( _( "Deprecated version of %s." ), var )
169 static std::map<wxString, wxString> envVarHelpText;
171 if( envVarHelpText.size() == 0 )
174 return envVarHelpText[ aEnvVar ];
183 if( wxGetEnv( aEnvVarName, &env ) )
187 if( env.ToDouble( &value ) )
198 std::optional<wxString> optValue;
201 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.
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 bool IsVersionedEnvVar(const wxString &aName, const wxString &aBaseName)
Test whether a name is a versioned KiCad environment variable for the given base, i....
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.