main
John Lauer
Review component pin functions and validate isolated library model and hole corrections
7fb4d36
"""Run native DRC on an isolated candidate with its project rules and footprint libraries."""
from pathlib import Path
import argparse,subprocess,json,uuid
p=argparse.ArgumentParser();p.add_argument('board',type=Path);a=p.parse_args();board=a.board.resolve();out=board.parent
remote='C:/Users/john/adom-projects/adom-custom-electronic-load/review/library-drc-'+uuid.uuid4().hex[:12]
def call(v,args,label):
r=subprocess.run(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',v,json.dumps(args)],capture_output=True,text=True)
d=json.loads(r.stdout);(out/(label+'.json')).write_text(json.dumps(d,indent=2)+'\n')
assert r.returncode==0 and d.get('success',d.get('ok',True)) and not d.get('errors') and d.get('exitCode',0)==0,d
return d
files=[board,board.with_suffix('.kicad_pro'),board.with_suffix('.kicad_dru'),out/'fp-lib-table'];assert all(f.is_file() for f in files)
call('send_files',{'filePaths':list(map(str,files)),'dest':remote+'/','reason':'Validate candidate with original project constraints'},'native-send-inputs')
for name in ['Load','Molecule']:
call('send_files',{'filePaths':[str(p) for p in (out/'lib'/f'{name}.pretty').glob('*.kicad_mod')],'dest':remote+'/lib/'+name+'.pretty','reason':'Include original footprint library context'},'native-send-'+name)
cli=call('kicad_status',{},'native-status')['install']['kicadCli']
call('shell_execute',{'command':'"'+cli+'"','args':['pcb','drc','--refill-zones','--format','json','--output',remote+'/native-drc.json',remote+'/'+board.name],'timeoutSeconds':120,'reason':'Native candidate DRC without changing the open board'},'native-drc-command')
call('pull_file',{'filePaths':[remote+'/native-drc.json'],'saveTo':str(out)},'native-pull-drc')
r=json.loads((out/'native-drc.json').read_text());print(json.dumps({'violations':len(r['violations']),'opens':len(r['unconnected_items']),'findings':[{'type':x['type'],'severity':x['severity'],'description':x['description']} for x in r['violations']]}));raise SystemExit(bool(r['violations'] or r['unconnected_items']))