Added option to export old variables

- When using the global/environment
This commit is contained in:
Salvador E. Tropea 2022-06-12 11:29:34 -03:00
parent e0fa00f68b
commit 3eaf9c025e
3 changed files with 37 additions and 24 deletions

View File

@ -611,6 +611,8 @@ global:
You can make reference to any OS environment variable using ${VARIABLE}.
The KIPRJMOD is also available for expansion.
* Valid keys:
- `define_old`: [boolean=false] Also define legacy versions of the variables.
Useful when using KiCad 6 and some libs uses old KiCad 5 names.
- `footprints`: [string=''] System level footprints (aka modules) dir. KiCad 5: KICAD_FOOTPRINT_DIR and KISYSMOD.
KiCad 6: KICAD6_FOOTPRINT_DIR.
- `models_3d`: [string=''] System level 3D models dir. KiCad 5: KISYS3DMOD. KiCad 6: KICAD6_3DMODEL_DIR.

View File

@ -10,7 +10,7 @@ all: ../README.md samples/generic_plot.kibot.yaml ../kibot/report_templates/rep
../kibot/config_templates/bom/%.kibot.yaml: samples/%.kibot.yaml
cp $< $@
../README.md: README.in replace_tags.pl ../kibot/out_*.py ../kibot/pre_*.py ../kibot/fil_*.py ../kibot/__main__.py ../kibot/config_reader.py
../README.md: README.in replace_tags.pl ../kibot/out_*.py ../kibot/pre_*.py ../kibot/fil_*.py ../kibot/__main__.py ../kibot/config_reader.py ../kibot/globals.py
cat README.in | perl replace_tags.pl > ../README.md
../src/kibot-check: ../src/kibot-check.in replace_tags.pl ../kibot/out_*.py ../kibot/pre_*.py ../kibot/registrable.py ../kibot/misc.py ../kibot/config_reader.py

View File

@ -34,35 +34,46 @@ class Environment(Optionable):
""" User level templates dir. KiCad 5/6: KICAD_USER_TEMPLATE_DIR """
self.third_party = ''
""" 3rd party dir. KiCad 6: KICAD6_3RD_PARTY """
self.define_old = False
""" Also define legacy versions of the variables.
Useful when using KiCad 6 and some libs uses old KiCad 5 names """
def define_k5_vars(self, defs):
if self.symbols:
defs['KICAD_SYMBOL_DIR'] = self.symbols
if self.footprints:
defs['KICAD_FOOTPRINT_DIR'] = self.symbols
defs['KISYSMOD'] = self.symbols
if self.models_3d:
defs['KISYS3DMOD'] = self.models_3d
if self.templates:
defs['KICAD_TEMPLATE_DIR'] = self.templates
if self.user_templates:
defs['KICAD_USER_TEMPLATE_DIR'] = self.user_templates
def define_k6_vars(self, defs):
if self.symbols:
defs['KICAD6_SYMBOL_DIR'] = self.symbols
if self.footprints:
defs['KICAD6_FOOTPRINT_DIR'] = self.symbols
if self.models_3d:
defs['KICAD6_3DMODEL_DIR'] = self.models_3d
if self.templates:
defs['KICAD6_TEMPLATE_DIR'] = self.templates
if self.user_templates:
defs['KICAD_USER_TEMPLATE_DIR'] = self.user_templates
if self.third_party:
defs['KICAD6_3RD_PARTY'] = self.third_party
def config(self, parent):
super().config(parent)
defs = {}
if GS.ki5():
if self.symbols:
defs['KICAD_SYMBOL_DIR'] = self.symbols
if self.footprints:
defs['KICAD_FOOTPRINT_DIR'] = self.symbols
defs['KISYSMOD'] = self.symbols
if self.models_3d:
defs['KISYS3DMOD'] = self.models_3d
if self.templates:
defs['KICAD_TEMPLATE_DIR'] = self.templates
if self.user_templates:
defs['KICAD_USER_TEMPLATE_DIR'] = self.user_templates
self.define_k5_vars(defs)
else:
if self.symbols:
defs['KICAD6_SYMBOL_DIR'] = self.symbols
if self.footprints:
defs['KICAD6_FOOTPRINT_DIR'] = self.symbols
if self.models_3d:
defs['KICAD6_3DMODEL_DIR'] = self.models_3d
if self.templates:
defs['KICAD6_TEMPLATE_DIR'] = self.templates
if self.user_templates:
defs['KICAD_USER_TEMPLATE_DIR'] = self.user_templates
if self.third_party:
defs['KICAD6_3RD_PARTY'] = self.third_party
self.define_k6_vars(defs)
if self.define_old:
self.define_k5_vars(defs)
if len(defs):
logger.debug('Defining environment vars from the global section')
env = {}