KiCad PCB EDA Suite
env_vars.cpp File Reference
#include <env_vars.h>
#include <map>
#include <common.h>

Go to the source code of this file.

Typedefs

using STRING_MAP = std::map< wxString, wxString >
 

Functions

bool IsEnvVarImmutable (const wxString &aEnvVar)
 Determine if an environment variable is "predefined", i.e. More...
 
const ENV_VAR_LISTGetPredefinedEnvVars ()
 Get the list of pre-defined environment variables. More...
 
void initialiseEnvVarHelp (STRING_MAP &aMap)
 
wxString LookUpEnvVarHelp (const wxString &aEnvVar)
 Look up long-form help text for a given environment variable. More...
 

Variables

static const ENV_VAR_LIST predefined_env_vars
 

Typedef Documentation

using STRING_MAP = std::map<wxString, wxString>

Definition at line 26 of file env_vars.cpp.

Function Documentation

const ENV_VAR_LIST& GetPredefinedEnvVars ( )

Get the list of pre-defined environment variables.

Definition at line 59 of file env_vars.cpp.

References predefined_env_vars.

Referenced by DIALOG_CONFIGURE_PATHS::OnHelp().

60 {
61  return predefined_env_vars;
62 }
static const ENV_VAR_LIST predefined_env_vars
Definition: env_vars.cpp:35
void initialiseEnvVarHelp ( STRING_MAP aMap)

Definition at line 65 of file env_vars.cpp.

Referenced by LookUpEnvVarHelp().

66 {
67  // Set up dynamically, as we want to be able to use _() translations,
68  // which can't be done statically
69  aMap["KISYSMOD"] =
70  _( "The base path of locally installed system "
71  "footprint libraries (.pretty folders).");
72  aMap["KISYS3DMOD"] =
73  _( "The base path of system footprint 3D shapes (.3Dshapes folders).");
74  aMap["KICAD_SYMBOL_DIR"] =
75  _( "The base path of the locally installed symbol libraries.");
76  aMap["KIGITHUB"] =
77  _( "Used by KiCad to define the URL of the repository "
78  "of the official KiCad footprint libraries.");
79  aMap["KICAD_TEMPLATE_DIR"] =
80  _( "A directory containing project templates installed with KiCad.");
81  aMap["KICAD_USER_TEMPLATE_DIR"] =
82  _( "Optional. Can be defined if you want to create your own project "
83  "templates folder.");
84  aMap["KIPRJMOD"] =
85  _("Internally defined by KiCad (cannot be edited) and is set "
86  "to the absolute path of the currently loaded project file. This environment "
87  "variable can be used to define files and paths relative to the currently loaded "
88  "project. For instance, ${KIPRJMOD}/libs/footprints.pretty can be defined as a "
89  "folder containing a project specific footprint library named footprints.pretty." );
90 
91  // Deprecated vars
92  aMap["KICAD_PTEMPLATES"] =
93  _( "Deprecated version of KICAD_TEMPLATE_DIR.");
94 }
bool IsEnvVarImmutable ( const wxString &  aEnvVar)

Determine if an environment variable is "predefined", i.e.

if the name of the variable is special to KiCad, and isn't just a user-specified substitution name.

Parameters
aEnvVarthe variable to check
Returns
true if predefined

Definition at line 47 of file env_vars.cpp.

References predefined_env_vars.

Referenced by DIALOG_CONFIGURE_PATHS::AppendEnvVar(), and DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar().

48 {
49  for( const auto& s: predefined_env_vars )
50  {
51  if( s == aEnvVar )
52  return true;
53  }
54 
55  return false;
56 }
static const ENV_VAR_LIST predefined_env_vars
Definition: env_vars.cpp:35
wxString LookUpEnvVarHelp ( const wxString &  aEnvVar)

Look up long-form help text for a given environment variable.

This is intended for use in more verbose help resources (as opposed to tooltip text)

Parameters
aEnvVarThe variable to look up
Returns
A string with help for that variable. Empty if no help available for this variable.

Definition at line 97 of file env_vars.cpp.

References initialiseEnvVarHelp().

Referenced by DIALOG_CONFIGURE_PATHS::OnHelp().

98 {
99  static STRING_MAP env_var_help_text;
100 
101  if( env_var_help_text.size() == 0 )
102  initialiseEnvVarHelp( env_var_help_text );
103 
104  return env_var_help_text[aEnvVar];
105 }
std::map< wxString, wxString > STRING_MAP
Definition: env_vars.cpp:26
void initialiseEnvVarHelp(STRING_MAP &aMap)
Definition: env_vars.cpp:65

Variable Documentation

const ENV_VAR_LIST predefined_env_vars
static
Initial value:
= {
"KIPRJMOD",
"KICAD_SYMBOL_DIR",
"KISYS3DMOD",
"KISYSMOD",
"KIGITHUB",
"KICAD_TEMPLATE_DIR",
"KICAD_USER_TEMPLATE_DIR",
"KICAD_PTEMPLATES",
}

Definition at line 35 of file env_vars.cpp.

Referenced by GetPredefinedEnvVars(), and IsEnvVarImmutable().