[Diff] Added schematic variants compare

Closes #278
This commit is contained in:
Salvador E. Tropea 2022-09-09 11:36:48 -03:00
parent b85aca8c29
commit f615790ddc
4 changed files with 76 additions and 9 deletions

View File

@ -1523,7 +1523,7 @@ Notes:
- `new`: [string|list(string)] The file you want to compare. Leave it blank for the current PCB/SCH.
A list is accepted only for the `multivar` type.
- `new_type`: [string='file'] [git,file,output,multivar] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant` output.
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
Use `multivar` to compare a set of variants, in this mode `new` is the list of variants.
If `old` is also `multivar` then it becomes the reference, otherwise we compare using pairs of variants.
- `old`: [string='HEAD'] Reference file. When using git use `HEAD` to refer to the last commit.
@ -1533,7 +1533,7 @@ Notes:
changes in the history you want to go back. A 0 is the same as `HEAD`,
a 1 means the last time the PCB/SCH was changed, etc.
- `old_type`: [string='git'] [git,file,output,multivar] How to interpret the `old` name. Use `git` for a git hash, branch, etc.
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant` output.
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
Use `multivar` to specify a reference file when `new_type` is also `multivar`.
- `pcb`: [boolean=true] Compare the PCB, otherwise compare the schematic.
- `threshold`: [number=0] [0,1000000] Error threshold for the `stats` mode, 0 is no error. When specified a

View File

@ -441,7 +441,7 @@ outputs:
# A list is accepted only for the `multivar` type
new: ''
# [string='file'] [git,file,output,multivar] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
# Use `file` for a file name. Use `output` to specify the name of a `pcb_variant` output.
# Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
# Use `multivar` to compare a set of variants, in this mode `new` is the list of variants.
# If `old` is also `multivar` then it becomes the reference, otherwise we compare using pairs of variants
new_type: 'file'
@ -453,7 +453,7 @@ outputs:
# a 1 means the last time the PCB/SCH was changed, etc
old: 'HEAD'
# [string='git'] [git,file,output,multivar] How to interpret the `old` name. Use `git` for a git hash, branch, etc.
# Use `file` for a file name. Use `output` to specify the name of a `pcb_variant` output.
# Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
# Use `multivar` to specify a reference file when `new_type` is also `multivar`
old_type: 'git'
# [string='%f-%i%I%v.%x'] Filename for the output (%i=diff_pcb/diff_sch, %x=pdf). Affected by global options

View File

@ -55,14 +55,14 @@ class DiffOptions(BaseOptions):
a 1 means the last time the PCB/SCH was changed, etc """
self.old_type = 'git'
""" [git,file,output,multivar] How to interpret the `old` name. Use `git` for a git hash, branch, etc.
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant` output.
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
Use `multivar` to specify a reference file when `new_type` is also `multivar` """
self.new = ''
""" [string|list(string)] The file you want to compare. Leave it blank for the current PCB/SCH.
A list is accepted only for the `multivar` type """
self.new_type = 'file'
""" [git,file,output,multivar] How to interpret the `new` name. Use `git` for a git hash, branch, etc.
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant` output.
Use `file` for a file name. Use `output` to specify the name of a `pcb_variant`/`sch_variant` output.
Use `multivar` to compare a set of variants, in this mode `new` is the list of variants.
If `old` is also `multivar` then it becomes the reference, otherwise we compare using pairs of variants """
self.cache_dir = ''
@ -309,16 +309,23 @@ class DiffOptions(BaseOptions):
self.undo_git()
return hash
@staticmethod
def check_output_type(out, must_be):
if out.type != must_be:
raise KiPlotConfigurationError('Output `{}` must be `{}` type, not `{}`'.format(out.name, must_be, out.type))
def cache_output(self, name):
logger.debugl(2, 'From output `{}`'.format(name))
out = RegOutput.get_output(name)
if out is None:
raise KiPlotConfigurationError('Unknown output `{}`'.format(name))
if out.type != 'pcb_variant':
raise KiPlotConfigurationError('Output `{}` must be `pcb_variant` type, not `{}`'.format(name, out.type))
self.check_output_type(out, 'pcb_variant' if self.pcb else 'sch_variant')
config_output(out)
out_dir = get_output_dir(out.dir, out, dry=True)
fname = out.get_targets(out_dir)[0]
if self.pcb:
fname = out.get_targets(out_dir)[0]
else:
fname = out.get_output_sch_name(out_dir)
logger.debug('File from output {} is {}'.format(name, fname))
if not out._done:
run_output(out)

View File

@ -0,0 +1,60 @@
# Example KiBot config file
kibot:
version: 1
variants:
- name: 'production'
comment: 'Production variant'
type: ibom
file_id: '_(production)'
variants_blacklist: T2
- name: 'test'
comment: 'Test variant'
type: ibom
file_id: '_(test)'
variants_blacklist: T1
- name: 'default'
comment: 'Default variant'
type: ibom
variants_blacklist: T2,T3
outputs:
- name: 'sch_default'
comment: "Schematic w/default variant"
type: sch_variant
dir: default_variant
options:
variant: default
copy_project: true
- name: 'sch_production'
comment: "Schematic w/production variant"
type: sch_variant
dir: production_variant
options:
variant: production
copy_project: true
- name: 'sch_test'
comment: "Schematic w/test variant"
type: sch_variant
dir: test_variant
options:
variant: test
copy_project: true
- name: 'diff_sch'
comment: "Schematic difference with variant"
type: diff
options:
# old: pcb_default
# old_type: output
pcb: false
old: ''
old_type: multivar
new: [sch_default, sch_production, sch_test]
new_type: multivar
cache_dir: .cache
# add_link_id: true