Added `erc_warnings` option to consider ERC warnings as errors.

This commit is contained in:
Salvador E. Tropea 2021-02-24 12:34:49 -03:00
parent c3ec95e2ca
commit 8fba0d9909
8 changed files with 254 additions and 0 deletions

View File

@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- `erc_warnings` pre-flight option to consider ERC warnings as errors.
## [0.10.1] - 2021-02-22
### Added

View File

@ -40,6 +40,8 @@ class Run_ERC(BasePreFlight): # noqa: F821
output = self.get_targets()[0]
logger.debug('ERC report: '+output)
cmd = [CMD_EESCHEMA_DO, 'run_erc', '-o', output]
if BasePreFlight.get_option('erc_warnings'): # noqa: F821
cmd.append('-w')
if GS.filter_file:
cmd.extend(['-f', GS.filter_file])
cmd.extend([GS.sch_file, GS.out_dir])

24
kibot/pre_erc_warnings.py Normal file
View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021 Salvador E. Tropea
# Copyright (c) 2021 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Project: KiBot (formerly KiPlot)
from .macros import macros, pre_class # noqa: F401
from .error import (KiPlotConfigurationError)
@pre_class
class ERC_Warnings(BasePreFlight): # noqa: F821
""" [boolean=false] Option for `run_erc`. ERC warnings are considered errors """
def __init__(self, name, value):
super().__init__(name, value)
if not isinstance(value, bool):
raise KiPlotConfigurationError('must be boolean')
self._enabled = value
def get_example():
""" Returns a YAML value for the example config """
return 'false'
def apply(self):
BasePreFlight._set_option('erc_warnings', self._enabled) # noqa: F821

View File

@ -0,0 +1,59 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 3 3
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L warning-project-rescue:R-passive R1
U 1 1 5CA75C86
P 5500 2790
F 0 "R1" H 5492 2948 40 0000 C CNN
F 1 "R" H 5492 2872 40 0000 C CNN
F 2 "Resistor_SMD:R_0402_1005Metric" H 5500 2790 60 0001 C CNN
F 3 "" H 5500 2790 60 0000 C CNN
1 5500 2790
1 0 0 -1
$EndComp
$Comp
L warning-project-rescue:C-passive C2
U 1 1 5CA76352
P 5700 2860
F 0 "C2" V 5654 2904 40 0000 L CNN
F 1 "C" V 5730 2904 40 0000 L CNN
F 2 "Capacitor_SMD:C_0402_1005Metric" H 5700 2860 60 0001 C CNN
F 3 "" H 5700 2860 60 0000 C CNN
1 5700 2860
0 1 1 0
$EndComp
Wire Wire Line
5700 2790 5700 2810
Wire Wire Line
5700 2910 5700 3000
$Comp
L power:GND #PWR03
U 1 1 5CA77789
P 5700 3000
F 0 "#PWR03" H 5700 2750 50 0001 C CNN
F 1 "GND" H 5705 2827 50 0000 C CNN
F 2 "" H 5700 3000 50 0000 C CNN
F 3 "" H 5700 3000 50 0000 C CNN
1 5700 3000
1 0 0 -1
$EndComp
Wire Wire Line
5450 2790 5310 2790
Text HLabel 5310 2790 0 50 Input ~ 0
VCC
Wire Wire Line
5550 2790 5700 2790
$EndSCHEMATC

View File

@ -0,0 +1,101 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 2 3
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L warning-project-rescue:CONN_01X02-conn P1
U 1 1 5CA714F2
P 4350 3610
AR Path="/5CA714F2" Ref="P1" Part="1"
AR Path="/5CA71704/5CA714F2" Ref="P1" Part="1"
F 0 "P1" H 4267 3335 50 0000 C CNN
F 1 "CONN_01X02" H 4267 3426 50 0000 C CNN
F 2 "Connector_JST:JST_JWPF_B02B-JWPF-SK-R_1x02_P2.00mm_Vertical" H 4350 3610 50 0001 C CNN
F 3 "" H 4350 3610 50 0000 C CNN
1 4350 3610
-1 0 0 1
$EndComp
$Comp
L power:PWR_FLAG #FLG02
U 1 1 5CA72902
P 4850 3660
F 0 "#FLG02" H 4850 3755 50 0001 C CNN
F 1 "PWR_FLAG" H 4850 3883 50 0000 C CNN
F 2 "" H 4850 3660 50 0000 C CNN
F 3 "" H 4850 3660 50 0000 C CNN
1 4850 3660
-1 0 0 1
$EndComp
Wire Wire Line
4550 3660 4850 3660
Wire Wire Line
4850 3660 5210 3660
Wire Wire Line
5210 3660 5210 3760
Connection ~ 4850 3660
$Comp
L power:GND #PWR01
U 1 1 5CA73F58
P 5210 3760
F 0 "#PWR01" H 5210 3510 50 0001 C CNN
F 1 "GND" H 5215 3587 50 0000 C CNN
F 2 "" H 5210 3760 50 0000 C CNN
F 3 "" H 5210 3760 50 0000 C CNN
1 5210 3760
1 0 0 -1
$EndComp
$Comp
L warning-project-rescue:C-passive C1
U 1 1 5CA745A6
P 5450 3610
F 0 "C1" V 5404 3654 40 0000 L CNN
F 1 "C" V 5480 3654 40 0000 L CNN
F 2 "Capacitor_SMD:C_0402_1005Metric" H 5450 3610 60 0001 C CNN
F 3 "" H 5450 3610 60 0000 C CNN
1 5450 3610
0 1 1 0
$EndComp
Connection ~ 5450 3560
Wire Wire Line
5450 3560 5620 3560
$Comp
L power:GND #PWR02
U 1 1 5CA755F5
P 5450 3660
F 0 "#PWR02" H 5450 3410 50 0001 C CNN
F 1 "GND" H 5455 3487 50 0000 C CNN
F 2 "" H 5450 3660 50 0000 C CNN
F 3 "" H 5450 3660 50 0000 C CNN
1 5450 3660
1 0 0 -1
$EndComp
Text HLabel 5620 3560 2 50 Output ~ 0
VCC
$Comp
L power:VCC #PWR0101
U 1 1 5CA71FA4
P 5210 3560
F 0 "#PWR0101" H 5210 3410 50 0001 C CNN
F 1 "VCC" H 5227 3733 50 0000 C CNN
F 2 "" H 5210 3560 50 0000 C CNN
F 3 "" H 5210 3560 50 0000 C CNN
1 5210 3560
1 0 0 -1
$EndComp
Connection ~ 5210 3560
Wire Wire Line
5210 3560 5450 3560
Wire Wire Line
4550 3560 5210 3560
$EndSCHEMATC

View File

@ -0,0 +1,32 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 3
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Sheet
S 3220 2140 1130 1460
U 5CA71704
F0 "Power" 50
F1 "power.sch" 50
F2 "VCC" O R 4350 2490 50
$EndSheet
$Sheet
S 5460 2180 1230 1430
U 5CA75BC1
F0 "logic" 50
F1 "logic.sch" 50
F2 "VCC" I L 5460 2490 50
$EndSheet
Wire Wire Line
4350 2490 5460 2490
$EndSCHEMATC

View File

@ -53,6 +53,26 @@ def test_erc_fail_2(test_dir):
ctx.clean_up()
def test_erc_warning_1(test_dir):
""" Using an SCH with ERC warnings """
prj = 'warning-project'
ctx = context.TestContextSCH(test_dir, 'test_erc_warning_1', 'erc_warning/'+prj, 'erc', '')
ctx.run()
# Check all outputs are there
ctx.expect_out_file(prj+'-erc.txt')
ctx.clean_up()
def test_erc_warning_2(test_dir):
""" Using an SCH with ERC warnings as errors """
prj = 'warning-project'
ctx = context.TestContextSCH(test_dir, 'test_erc_warning_1', 'erc_warning/'+prj, 'erc_no_w', '')
ctx.run(ERC_ERROR)
# Check all outputs are there
ctx.expect_out_file(prj+'-erc.txt')
ctx.clean_up()
def test_drc_1(test_dir):
prj = 'bom'
ctx = context.TestContext(test_dir, 'DRC', prj, 'drc', '')

View File

@ -0,0 +1,14 @@
# Example KiBot config file
kibot:
version: 1
preflight:
run_erc: true
erc_warnings: true
filters:
- filter: 'Ignore C3 pad 2 too close to anything'
number: 4
regex: 'Pad 2 of C3'
- filter: 'Ignore unconnected pad 2 of C4'
number: 2
regex: 'Pad 2 of C4'