Neo: fixed up script to point to the 'Fabrication' folder properly

Variants: able to use kibot variants, separate variants for: mech, sch,
and pcb outputs. This because a BOM variant does not affect the PCB, but it might affect the step file.
This commit is contained in:
ac
2025-04-29 21:29:05 +10:00
parent cf480237f5
commit ebee7ef48e
10 changed files with 201 additions and 99 deletions

View File

@@ -1,4 +1,5 @@
import csv import csv
import os
import sys import sys
from copy import deepcopy from copy import deepcopy
from glob import glob from glob import glob
@@ -31,8 +32,9 @@ print("bottom Orig: ", bottomOrig)
output_dir = deepcopy(pcb_dir) output_dir = deepcopy(pcb_dir)
csv_files = glob(output_dir + "/*.csv") csv_files = glob(output_dir + "/*.csv")
print("CSV Files: ", csv_files)
if len(csv_files) < 1: if len(csv_files) < 1:
output_dir = "Fabrication/" + output_dir output_dir = os.path.join(os.environ.get('CI_PROJECT_DIR', ''), '') + "Fabrication/" + output_dir
csv_files = glob(output_dir + "/*.csv") csv_files = glob(output_dir + "/*.csv")
input = next(filter(lambda f: KI_POS_SUFFIX in f, csv_files)) input = next(filter(lambda f: KI_POS_SUFFIX in f, csv_files))

2
blank.kibot.yaml Normal file
View File

@@ -0,0 +1,2 @@
kibot:
version: 1

View File

@@ -2,10 +2,13 @@
kibot: kibot:
version: 1 version: 1
import:
- file: '../kibot.yaml'
preflight: preflight:
erc: true # erc: true
update_xml: true # update_xml: true
drc: true # drc: true
set_text_variables: set_text_variables:
- name: 'rev' - name: 'rev'
command: 'if [ $(git describe --tags | wc -w) -gt 0 ]; then git describe --tags | sed -e "s/\([r,R][0-9]\+\)*$//g"; else echo $CI_COMMIT_SHORT_SHA; fi' command: 'if [ $(git describe --tags | wc -w) -gt 0 ]; then git describe --tags | sed -e "s/\([r,R][0-9]\+\)*$//g"; else echo $CI_COMMIT_SHORT_SHA; fi'
@@ -31,14 +34,14 @@ outputs:
type: pdf_sch_print type: pdf_sch_print
dir: . dir: .
options: options:
output: "%f_%r_%i.%x" output: "%f%v_%r_%i.%x"
- name: 'print_pcb' - name: 'print_pcb'
comment: "Print Top and Bottom Copper+Silk" comment: "Print Top and Bottom Copper+Silk"
type: pcb_print type: pcb_print
dir: . dir: .
options: options:
output: "%f_%r_PCB.%x" output: "%f%v_%r_PCB.%x"
pages: pages:
- layers: - layers:
- layer: F.Cu - layer: F.Cu
@@ -51,7 +54,7 @@ outputs:
- name: '_bom' - name: '_bom'
type: bom type: bom
dir: . dir: /tmp
options: options:
columns: columns:
- field: Value - field: Value
@@ -70,14 +73,14 @@ outputs:
- field: References - field: References
name: refs name: refs
exclude_filter: "" exclude_filter: ""
output: "%f_%r_%i.%x" output: "%f%v_%r_%i.%x"
expand_text_vars: true expand_text_vars: true
disable_run_by_default: true
- name: 'bom_csv' - name: 'bom_csv'
type: bom type: bom
dir: . dir: .
extends: "_bom" extends: "_bom"
disable_run_by_default: _bom
options: options:
csv: csv:
separator: ';' separator: ';'
@@ -89,6 +92,7 @@ outputs:
type: bom type: bom
dir: . dir: .
extends: '_bom' extends: '_bom'
disable_run_by_default: _bom
options: options:
xlsx: xlsx:
# this is a relative path unfortunately # this is a relative path unfortunately
@@ -108,7 +112,7 @@ outputs:
type: step type: step
dir: . dir: .
options: options:
output: '%f_%r.%x' output: '%f%v_%r.%x'
download: false download: false
subst_models: true subst_models: true
@@ -124,7 +128,7 @@ outputs:
download: false download: false
download_lcsc: false download_lcsc: false
orthographic: true orthographic: true
output: 'PCB_%f_%r.%x' output: 'PCB_%f%v_%r.%x'
show_components: 'none' show_components: 'none'
- name: 'pcba_render' - name: 'pcba_render'
@@ -139,14 +143,14 @@ outputs:
zoom: -1 zoom: -1
download_lcsc: false download_lcsc: false
orthographic: true orthographic: true
output: 'PCBA_%f_%r.%x' output: 'PCBA_%f%v_%r.%x'
show_components: 'all' show_components: 'all'
- name: 'neo_position' - name: 'neo_position'
comment: "Pick and place" comment: "Pick and place"
type: position type: position
options: options:
output: '%f_%r_cpl.%x' output: '%f%v_%r_cpl.%x'
format: CSV format: CSV
units: millimeters units: millimeters
separate_files_for_front_and_back: false separate_files_for_front_and_back: false
@@ -157,7 +161,7 @@ outputs:
type: stencil_3d type: stencil_3d
dir: '3D_Stencil' dir: '3D_Stencil'
options: options:
output: '%f_%r_%i.%x' output: '%f%v_%r_%i.%x'
- name: 'diff_pcb' - name: 'diff_pcb'
comment: "Diff for visual comparison" comment: "Diff for visual comparison"
@@ -181,7 +185,7 @@ outputs:
type: ibom type: ibom
dir: . dir: .
options: options:
output: '%f_%r_%i.%x' output: '%f%v_%r_%i.%x'
dark_mode: true dark_mode: true
- name: JLCPCB_gerbers - name: JLCPCB_gerbers
@@ -234,7 +238,7 @@ outputs:
metric_units: true metric_units: true
map: gerber map: gerber
route_mode_for_oval_holes: false route_mode_for_oval_holes: false
output: "%f%i.%x" output: "%f%v%i.%x"
- name: 'JLCPCB_compress' - name: 'JLCPCB_compress'
comment: ZIP file for JLCPCB comment: ZIP file for JLCPCB
@@ -245,29 +249,29 @@ outputs:
dest: / dest: /
- from_output: JLCPCB_drill - from_output: JLCPCB_drill
dest: / dest: /
output: '%f_%r_JLC.%x' output: '%f%v_%r_JLC.%x'
groups: # groups:
- name: pcb # - name: pcb
outputs: # outputs:
- JLCPCB_compress # - JLCPCB_compress
- neo_position # - neo_position
- print_pcb # - print_pcb
- stencil # - stencil
- interactive_bom # - interactive_bom
#
- name: pcb_panel # - name: pcb_panel
outputs: # outputs:
- JLCPCB_compress # - JLCPCB_compress
- neo_position # - neo_position
- print_pcb # - print_pcb
- step # - step
- interactive_bom # - interactive_bom
#
- name: sch # - name: sch
outputs: # outputs:
- bom_csv # - bom_csv
- bom_xlsx # - bom_xlsx
- print_sch # - print_sch
... ...
definitions: definitions:
_KIBOT_POS_ENABLED: false _KIBOT_POS_ENABLED: false

View File

@@ -20,7 +20,7 @@ stages:
- release - release
image: image:
name: ghcr.io/inti-cmnb/kicad8_auto:1.8.2 name: ghcr.io/inti-cmnb/kicad8_auto:1.8.4
.main_rules: .main_rules:
rules: rules:
@@ -82,27 +82,33 @@ image:
fi fi
echo ${dir_arr[i-1]} echo ${dir_arr[i-1]}
echo ${sch_arr[i-1]} echo ${sch_arr[i-1]}
USER_FILE="$CI_PROJECT_DIR/.gitlab/blank.kibot.yaml"
if [ -f "${dir_arr[i-1]}/kibot.yaml" ]; then
USER_FILE="${dir_arr[i-1]}/kibot.yaml"
fi
cp $USER_FILE $CI_PROJECT_DIR/kibot.yaml
python3 $CI_PROJECT_DIR/.gitlab/.scripts/orig.py ${dir_arr[i-1]} python3 $CI_PROJECT_DIR/.gitlab/.scripts/orig.py ${dir_arr[i-1]}
kibot -e ${dir_arr[i-1]}/${sch_arr[i-1]} -c $CI_PROJECT_DIR/.gitlab/default.kibot.yaml -d $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]} -s $SUFFIX for CONF in $KIBOT_CONF
do
kibot -e ${dir_arr[i-1]}/${sch_arr[i-1]} -c $CI_PROJECT_DIR/.gitlab/$CONF.kibot.yaml -d $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]} $VARIANTS
done
mv $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]}/*.zip Fabrication/ 2> /dev/null || true mv $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]}/*.zip Fabrication/ 2> /dev/null || true
done done
- cd $CI_PROJECT_DIR - cd $CI_PROJECT_DIR
panel: pre_panel:
- cd $CI_PROJECT_DIR
- mkdir panels
- 'SEARCH="_panel.json"' - 'SEARCH="_panel.json"'
- !reference [.commands, get_dirs] - !reference [.commands, get_dirs]
- | - |
mkdir panels
cd $CI_PROJECT_DIR
for d in $DIRS for d in $DIRS
do do
echo "found panel" echo "found panel: $d"
echo $d
JSON=$(find $d/*_panel.json) JSON=$(find $d/*_panel.json)
FILE=$(basename "${JSON}") FILE=$(basename "${JSON}")
NAME=$(echo "${FILE%.json}") NAME=$(echo "${FILE%.json}")
PCB=$(find $d/*.kicad_pcb) PCB=$(find $d/*.kicad_pcb)
echo "mkdring"
mkdir -p panels/$NAME mkdir -p panels/$NAME
echo "panelising" echo "panelising"
kikit panelize -p $JSON $PCB panels/$NAME/$NAME.kicad_pcb kikit panelize -p $JSON $PCB panels/$NAME/$NAME.kicad_pcb
@@ -110,10 +116,10 @@ image:
cp $d/fp-lib-table panels/$NAME/ cp $d/fp-lib-table panels/$NAME/
python3 .gitlab/.scripts/post_panel.py panels/$NAME/$NAME.kicad_pro $PCB python3 .gitlab/.scripts/post_panel.py panels/$NAME/$NAME.kicad_pro $PCB
done done
- cd panels || true - cd panels
- !reference [.commands, kibot]
post_panel:
- mv panels/* . || true - mv panels/* . || true
- rm -rf panels/ || true
neo: neo:
- 'SEARCH=".kicad_pro"' - 'SEARCH=".kicad_pro"'
@@ -231,87 +237,86 @@ image:
strip_tag: strip_tag:
- TAG=$(echo ${CI_COMMIT_MESSAGE} | tr -d \\n) - TAG=$(echo ${CI_COMMIT_MESSAGE} | tr -d \\n)
output_mech: outputs_mech:
stage: gen_mech stage: gen_mech
when: always
artifacts: artifacts:
when: always when: always
paths: paths:
- Fabrication/**/* - Fabrication/**/*
variables:
SUFF_MECH: erc,drc step pcb_render pcba_render
script:
- !reference [.commands, git_tag]
- SUFFIX=$SUFF_MECH
- !reference [.commands, kibot]
outputs_dev:
rules:
- !reference [.dev_rules, rules]
stage: gen_fab
artifacts:
when: always
name: "$CI_PROJECT_TITLE-$CI_COMMIT_SHORT_SHA"
paths:
- Fabrication/**/*
expire_in: 1 week expire_in: 1 week
variables: before_script:
SUFF_SCH: drc sch
SUFF_PCB: erc,update_xml,set_text_variables print_pcb
script:
- !reference [.commands, git_tag] - !reference [.commands, git_tag]
- SUFFIX=$SUFF_SCH script:
- !reference [.commands, kibot] - VARIANTS="$VARIANTS_MECH"
- SUFFIX=$SUFF_PCB - KIBOT_CONF="mech"
- !reference [.commands, kibot] - !reference [.commands, kibot]
outputs_all:
extends: outputs_dev outputs_dev:
rules: extends: outputs_mech
- !reference [.main_rules, rules] stage: gen_fab
variables:
SUFF_SCH: drc sch
SUFF_PCB: erc,update_xml,set_text_variables pcb
SUFF_PANEL: erc,update_xml,set_text_variables pcb_panel
script: script:
- !reference [.commands, git_tag] # SCH
- SUFFIX=$SUFF_SCH - VARIANTS="$VARIANTS_SCH"
- KIBOT_CONF="sch"
- !reference [.commands, kibot] - !reference [.commands, kibot]
- SUFFIX=$SUFF_PCB # PCB
- VARIANTS="$VARIANTS_PCB"
- KIBOT_CONF="pcb_dev"
- !reference [.commands, kibot]
outputs_main:
extends: outputs_dev
script:
# SCH
- VARIANTS="$VARIANTS_SCH"
- KIBOT_CONF="sch"
- !reference [.commands, kibot]
# PCB
- VARIANTS="$VARIANTS_PCB"
- KIBOT_CONF="pcb_main"
- !reference [.commands, kibot]
# Panels
- !reference [.commands, pre_panel]
- KIBOT_CONF="panel"
- !reference [.commands, kibot]
- !reference [.commands, post_panel]
# Pos
- VARIANTS="$VARIANTS_SCH"
- KIBOT_CONF="pos"
- !reference [.commands, kibot] - !reference [.commands, kibot]
- SUFFIX=$SUFF_PANEL
- !reference [.commands, panel]
- !reference [.commands, neo] - !reference [.commands, neo]
- ls Fabrication/
inventree_job_dev: inventree_job_dev:
stage: inventree stage: inventree
rules:
- !reference [.dev_rules, rules]
needs: needs:
- job: output_mech - job: outputs_mech
artifacts: true artifacts: true
- job: outputs_dev - job: outputs_dev
artifacts: true artifacts: true
rules:
- !reference [.dev_rules, rules]
script: script:
- !reference [.commands, boms] - !reference [.commands, boms]
inventree_job: inventree_job_main:
stage: inventree stage: inventree
needs:
- job: output_mech
artifacts: true
- job: outputs_all
artifacts: true
rules: rules:
- !reference [.main_rules, rules] - !reference [.main_rules, rules]
needs:
- job: outputs_mech
artifacts: true
- job: outputs_main
artifacts: true
script: script:
- !reference [.commands, boms] - !reference [.commands, boms]
upload_job: upload_job:
stage: upload stage: upload
needs: needs:
- job: inventree_job - job: inventree_job_main
- job: outputs_all - job: outputs_main
artifacts: true artifacts: true
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG

13
mech.kibot.yaml Normal file
View File

@@ -0,0 +1,13 @@
# Example KiPlot config file
kibot:
version: 1
import:
- file: default.kibot.yaml
outputs:
- step
preflight:
erc: false
update_xml: false
drc: false

17
panel.kibot.yaml Normal file
View File

@@ -0,0 +1,17 @@
# Example KiPlot config file
kibot:
version: 1
import:
- file: default.kibot.yaml
outputs:
- JLCPCB_compress
- neo_position
- print_pcb
- step
- interactive_bom
preflight:
erc: false
update_xml: false
drc: true

13
pcb_dev.kibot.yaml Normal file
View File

@@ -0,0 +1,13 @@
# Example KiPlot config file
kibot:
version: 1
import:
- file: default.kibot.yaml
outputs:
- print_pcb
preflight:
erc: false
update_xml: false
drc: true

18
pcb_main.kibot.yaml Normal file
View File

@@ -0,0 +1,18 @@
# Example KiPlot config file
kibot:
version: 1
import:
- file: default.kibot.yaml
outputs:
- JLCPCB_gerbers
- JLCPCB_drill
- JLCPCB_compress
- print_pcb
- stencil
- interactive_bom
preflight:
erc: false
update_xml: false
drc: true

13
pos.kibot.yaml Normal file
View File

@@ -0,0 +1,13 @@
# Example KiPlot config file
kibot:
version: 1
import:
- file: default.kibot.yaml
outputs:
- neo_position
preflight:
erc: false
update_xml: false
drc: true

15
sch.kibot.yaml Normal file
View File

@@ -0,0 +1,15 @@
kibot:
version: 1
import:
- file: default.kibot.yaml
outputs:
- print_sch
- _bom
- bom_csv
- bom_xlsx
preflight:
erc: true
update_xml: true
drc: false