Now the default output name applies to the DRC and ERC report names.

This provides more coherent file names.
This commit is contained in:
Salvador E. Tropea 2021-01-12 13:44:09 -03:00
parent b2594ec8d3
commit e0ab45e95d
8 changed files with 43 additions and 24 deletions

View File

@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Internal BoM: `no_conflict` option to exclude fields from conflict detection.
- Support for KICAD_CONFIG_HOME defined from inside KiCad
### Changed
- Now the default output name applies to the DRC and ERC report names.
This provides more coherent file names.
## [0.9.0] - 2021-01-04
### Added
- iBoM output: file name patterns are allowed for the `netlist_file` option.

View File

@ -109,7 +109,9 @@ This section is used to specify tasks that will be executed before generating an
- *regexp*: Alias for regex.
- ignore_unconnected: [boolean=false] Option for `run_drc`. Ignores the unconnected nets. Useful if you didn't finish the routing.
- run_drc: [boolean=false] Runs the DRC (Distance Rules Check). To ensure we have a valid PCB.
The report file name is controlled by the global output pattern (%i=drc %x=txt).
- run_erc: [boolean=false] Runs the ERC (Electrical Rules Check). To ensure the schematic is electrically correct.
The report file name is controlled by the global output pattern (%i=erc %x=txt).
- update_xml: [boolean=false] Update the XML version of the BoM (Bill of Materials).
To ensure our generated BoM is up to date.
Note that this isn't needed when using the internal BoM generator (`bom`).

View File

@ -16,8 +16,10 @@ preflight:
# [boolean=false] Option for `run_drc`. Ignores the unconnected nets. Useful if you didn't finish the routing.
ignore_unconnected: false
# [boolean=false] Runs the DRC (Distance Rules Check). To ensure we have a valid PCB.
# The report file name is controlled by the global output pattern (%i=drc %x=txt).
run_drc: true
# [boolean=false] Runs the ERC (Electrical Rules Check). To ensure the schematic is electrically correct.
# The report file name is controlled by the global output pattern (%i=erc %x=txt).
run_erc: true
# [boolean=false] Update the XML version of the BoM (Bill of Materials).
# To ensure our generated BoM is up to date.

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2018 John Beard
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
@ -108,7 +108,7 @@ def check_script(cmd, url, version=None):
def check_eeschema_do():
check_script(CMD_EESCHEMA_DO, URL_EESCHEMA_DO, '1.4.0')
check_script(CMD_EESCHEMA_DO, URL_EESCHEMA_DO, '1.5.4')
def exec_with_retry(cmd):

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
""" Base class for output options """
@ -199,7 +199,7 @@ class Optionable(object):
name = name.replace('%p', GS.pcb_title)
name = name.replace('%r', GS.pcb_rev)
name = name.replace('%T', GS.time)
name = name.replace('%v', self._find_variant())
name = name.replace('%v', self._find_variant() if self else '')
name = name.replace('%x', ext)
# sanitize the name to avoid characters illegal in file systems
name = name.replace('\\', '/')
@ -221,7 +221,7 @@ class Optionable(object):
name = name.replace('%p', GS.sch_title)
name = name.replace('%r', GS.sch_rev)
name = name.replace('%T', GS.time)
name = name.replace('%v', self._find_variant())
name = name.replace('%v', self._find_variant() if self else '')
name = name.replace('%x', ext)
# sanitize the name to avoid characters illegal in file systems
name = name.replace('\\', '/')

View File

@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
from sys import (exit)
from .macros import macros, pre_class # noqa: F401
from .error import (KiPlotConfigurationError)
from .gs import (GS)
from .kiplot import check_script, exec_with_retry
from .optionable import Optionable
from .kiplot import check_script, exec_with_retry, load_board
from .misc import (CMD_PCBNEW_RUN_DRC, URL_PCBNEW_RUN_DRC, DRC_ERROR)
from .log import (get_logger)
@ -16,7 +17,8 @@ logger = get_logger(__name__)
@pre_class
class Run_DRC(BasePreFlight): # noqa: F821
""" [boolean=false] Runs the DRC (Distance Rules Check). To ensure we have a valid PCB """
""" [boolean=false] Runs the DRC (Distance Rules Check). To ensure we have a valid PCB.
The report file name is controlled by the global output pattern (%i=drc %x=txt) """
def __init__(self, name, value):
super().__init__(name, value)
if not isinstance(value, bool):
@ -26,7 +28,11 @@ class Run_DRC(BasePreFlight): # noqa: F821
def run(self):
check_script(CMD_PCBNEW_RUN_DRC, URL_PCBNEW_RUN_DRC, '1.4.0')
cmd = [CMD_PCBNEW_RUN_DRC, 'run_drc']
if GS.board is None:
load_board()
output = Optionable.expand_filename(None, GS.out_dir, GS.def_global_output, 'drc', 'txt')
logger.debug('DRC report: '+output)
cmd = [CMD_PCBNEW_RUN_DRC, 'run_drc', '-o', output]
if GS.filter_file:
cmd.extend(['-f', GS.filter_file])
if BasePreFlight.get_option('ignore_unconnected'): # noqa: F821

View File

@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Salvador E. Tropea
# Copyright (c) 2020 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2021 Salvador E. Tropea
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
from sys import (exit)
from .macros import macros, pre_class # noqa: F401
from .gs import (GS)
from .optionable import Optionable
from .kiplot import check_eeschema_do, exec_with_retry
from .error import (KiPlotConfigurationError)
from .misc import (CMD_EESCHEMA_DO, ERC_ERROR)
@ -16,7 +17,8 @@ logger = get_logger(__name__)
@pre_class
class Run_ERC(BasePreFlight): # noqa: F821
""" [boolean=false] Runs the ERC (Electrical Rules Check). To ensure the schematic is electrically correct """
""" [boolean=false] Runs the ERC (Electrical Rules Check). To ensure the schematic is electrically correct.
The report file name is controlled by the global output pattern (%i=erc %x=txt) """
def __init__(self, name, value):
super().__init__(name, value)
if not isinstance(value, bool):
@ -26,7 +28,9 @@ class Run_ERC(BasePreFlight): # noqa: F821
def run(self):
check_eeschema_do()
cmd = [CMD_EESCHEMA_DO, 'run_erc']
output = Optionable.expand_filename_sch(None, GS.out_dir, GS.def_global_output, 'erc', 'txt')
logger.debug('ERC report: '+output)
cmd = [CMD_EESCHEMA_DO, 'run_erc', '-o', output]
if GS.filter_file:
cmd.extend(['-f', GS.filter_file])
cmd.extend([GS.sch_file, GS.out_dir])

View File

@ -23,7 +23,7 @@ if prev_dir not in sys.path:
sys.path.insert(0, prev_dir)
# Utils import
from utils import context
from kibot.misc import (DRC_ERROR, ERC_ERROR, BOM_ERROR)
from kibot.misc import (DRC_ERROR, ERC_ERROR, BOM_ERROR, CORRUPTED_PCB)
def test_erc_1():
@ -31,7 +31,7 @@ def test_erc_1():
ctx = context.TestContext('ERC', prj, 'erc', '')
ctx.run()
# Check all outputs are there
ctx.expect_out_file(prj+'.erc')
ctx.expect_out_file(prj+'-erc.txt')
ctx.clean_up()
@ -41,7 +41,7 @@ def test_erc_fail_1():
ctx = context.TestContext('ERCFail1', prj, 'erc', '')
ctx.run(ERC_ERROR)
# Check all outputs are there
ctx.expect_out_file(prj+'.erc')
ctx.expect_out_file(prj+'-erc.txt')
ctx.clean_up()
@ -58,7 +58,7 @@ def test_drc_1():
ctx = context.TestContext('DRC', prj, 'drc', '')
ctx.run()
# Check all outputs are there
ctx.expect_out_file('drc_result.rpt')
ctx.expect_out_file(prj+'-drc.txt')
ctx.clean_up()
@ -67,7 +67,7 @@ def test_drc_filter():
ctx = context.TestContext('DRC_Filter', prj, 'drc_filter', '')
ctx.run()
# Check all outputs are there
ctx.expect_out_file('drc_result.rpt')
ctx.expect_out_file(prj+'-drc.txt')
ctx.expect_out_file('kibot_errors.filter')
ctx.clean_up()
@ -78,7 +78,7 @@ def test_drc_unco():
ctx = context.TestContext('DRCUnco', prj, 'drc_unco', '')
ctx.run()
# Check all outputs are there
ctx.expect_out_file('drc_result.rpt')
ctx.expect_out_file(prj+'-drc.txt')
ctx.clean_up()
@ -88,7 +88,7 @@ def test_drc_error():
ctx = context.TestContext('DRCError', prj, 'drc', '')
ctx.run(DRC_ERROR)
# Check all outputs are there
ctx.expect_out_file('drc_result.rpt')
ctx.expect_out_file(prj+'-drc.txt')
ctx.clean_up()
@ -96,7 +96,7 @@ def test_drc_fail():
""" Check we dummy PCB """
prj = 'bom_no_xml'
ctx = context.TestContext('DRCFail', prj, 'drc', '')
ctx.run(DRC_ERROR)
ctx.run(CORRUPTED_PCB)
ctx.clean_up()