diff --git a/.gitconfig b/.gitconfig index 376c95f..5d8053b 100644 --- a/.gitconfig +++ b/.gitconfig @@ -2,3 +2,4 @@ submodulesummary = 1 [submodule] recurse = true + propogateBranches = true diff --git a/.gitignore b/.gitignore index 1388381..a8098cd 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ fp-info-cache # Exported BOM files *.xml *.csv +*.xlsx* # Backup Folders **/*backups/** @@ -37,3 +38,19 @@ fp-info-cache # CAD *.FCStd *.dxf +*.step +*.stp + +# CI +Fabrication/ +.gitlab-ci-local/ + +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +*.pyc + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6c0e819..ba10a8c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,13 +5,18 @@ workflow: when: never - if: $CI_COMMIT_BRANCH +variables: + GIT_STRATEGY: clone + GIT_SUBMODULE_STRATEGY: recursive + GIT_SUBMODULE_DEPTH: 1 + GIT_SUBMODULE_FORCE_HTTPS: "true" + stages: - - run_erc - - run_drc + - gen_mech - gen_fab image: - name: ghcr.io/inti-cmnb/kicad7_auto:latest + name: ghcr.io/inti-cmnb/kicad7_auto:1.6.2 .main_rules: rules: @@ -50,25 +55,34 @@ image: - | for i in $(seq 1 $END) do + if [[ ${dir_arr[i-1]} == "./Frame" ]]; then + continue + fi echo ${dir_arr[i-1]} + echo ${sch_arr[i-1]} cd $CI_PROJECT_DIR/${dir_arr[i-1]} kibot -e ${sch_arr[i-1]} -c $CI_PROJECT_DIR/default.kibot.yaml -d $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]} -s $SUFFIX done + - cd $CI_PROJECT_DIR panel: - - 'SEARCH="boards.json"' + - 'SEARCH="_panel.json"' - !reference [.commands, get_dirs] - | for d in $DIRS do echo $d cd $CI_PROJECT_DIR/$d - JSON=$(find panel_*.json ) + JSON=$(find *_panel.json) NAME=$(echo "${JSON%.json}") - mkdir panel - kikit -p $JSON boards.json panel/$NAME.kicad_pcb - touch panel/$NAME.kicad_sch + PCB=$(find *.kicad_pcb) + mkdir $CI_PROJECT_DIR/$NAME + kikit panelize -p $JSON $PCB $CI_PROJECT_DIR/$NAME/$NAME.kicad_pcb + touch $CI_PROJECT_DIR/$NAME/$NAME.kicad_sch + cp fp-lib-table $CI_PROJECT_DIR/$NAME/ + python3 $CI_PROJECT_DIR/.scripts/post_panel.py $CI_PROJECT_DIR/$NAME/$NAME.kicad_pro done + - cd $CI_PROJECT_DIR neo: - 'SEARCH=".kicad_pro"' @@ -76,35 +90,31 @@ image: - | for d in $DIRS do - python3 scripts/neo.py $d + if [[ $d == "./Frame" ]]; then + continue + fi + echo $d + python3 .scripts/neo.py $d done -.template: - rules: - - !reference [.main_rules, rules] - variables: - SUFFIX: "" + templates: + - if [ $GITLAB_CI == 'true' ]; then git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/Micromelon/kicad-project.git .templates; fi + - cd .templates + - shopt -s extglob + - rm -rf !(*.kicad_wks) + - cd $CI_PROJECT_DIR + +output_mech: + stage: gen_mech + artifacts: + when: always + paths: + - Fabrication/ + variables: + SUFF_MECH: run_erc,run_drc step script: + - SUFFIX=$SUFF_MECH - !reference [.commands, kibot] - dependencies: [] - -.temprc: - extends: .template - rules: - - !reference [.main_rules, rules] - - !reference [.dev_rules, rules] - -erc: - extends: .temprc - stage: run_erc - variables: - SUFFIX: update_xml,run_drc -i - -drc: - extends: .temprc - stage: run_drc - variables: - SUFFIX: update_xml,run_erc -i outputs_dev: rules: @@ -115,9 +125,10 @@ outputs_dev: paths: - Fabrication/ variables: - SUFF_SCH: run_drc,run_erc print_sch step - SUFF_PCB: all print_front + SUFF_SCH: run_drc print_sch + SUFF_PCB: run_erc,update_xml print_front script: + - !reference [.commands, templates] - SUFFIX=$SUFF_SCH - !reference [.commands, kibot] - SUFFIX=$SUFF_PCB @@ -128,15 +139,14 @@ outputs_all: rules: - !reference [.main_rules, rules] variables: - SUFF_SCH: run_drc,run_erc print_sch step bom - SUFF_PCB: all print_front gerbers drill position + SUFF_SCH: run_drc sch + SUFF_PCB: run_erc,update_xml pcb script: + - !reference [.commands, templates] - SUFFIX=$SUFF_SCH - !reference [.commands, kibot] - - cd $CI_PROJECT_DIR - !reference [.commands, panel] - SUFFIX=$SUFF_PCB - - cd $CI_PROJECT_DIR - !reference [.commands, kibot] - - cd $CI_PROJECT_DIR - !reference [.commands, neo] + diff --git a/.scripts/ki_plugin.py b/.scripts/ki_plugin.py new file mode 100644 index 0000000..538dc92 --- /dev/null +++ b/.scripts/ki_plugin.py @@ -0,0 +1,30 @@ +from kikit import panelize_ui_impl as ki +from kikit.panelize import Panel +from kikit.panelize_ui_impl import Substrate, readLength +from pcbnewTransition import pcbnew +from pcbnewTransition.pcbnew import LoadBoard, VECTOR2I +from kikit.plugin import LayoutPlugin +import json +from typing import Iterable +from kikit.common import fromDegrees + +class ManualLayout(LayoutPlugin): + def buildLayout(self, panel: Panel, inputFile: str, + sourceArea: pcbnew.BOX2I) -> Iterable[Substrate]: + + netRenamer = lambda x, y: self.netPattern.format(n=x, orig=y) + refRenamer = lambda x, y: self.refPattern.format(n=x, orig=y) + with open("boards.json") as json_file: + json_str = json_file.read() + boards = [] + for d in json.loads(json_str): + source = {"type": "auto", "tolerance": readLength("5mm")} + board = LoadBoard(d["board"]) + sourceArea = ki.readSourceArea(source, board) + drc_flag = False + if d["board"] == inputFile and not len(panel.sourcePaths): + drc_flag = True + panel.appendBoard(d["board"], VECTOR2I(*[readLength(p) for p in d["pos"]]),\ + sourceArea, inheritDrc=drc_flag, rotationAngle=fromDegrees(d.get("rot", 0.0)),\ + netRenamer=netRenamer, refRenamer=refRenamer) + return panel.substrates diff --git a/.scripts/post_panel.py b/.scripts/post_panel.py new file mode 100644 index 0000000..99a13dc --- /dev/null +++ b/.scripts/post_panel.py @@ -0,0 +1,11 @@ +import json +import sys + +proj = sys.argv[1] +json_file = open(proj) +json_str = json_file.read() +d = json.loads(json_str) +d["board"]["design_settings"]["rule_severities"]["lib_footprint_issues"] = "ignore" +d["board"]["design_settings"]["rule_severities"]["lib_footprint_mismatch"] = "ignore" +with open(proj, mode="w") as json_file: + json.dump(d, json_file, indent=2) diff --git a/default.kibot.yaml b/default.kibot.yaml index 3228736..45d408e 100644 --- a/default.kibot.yaml +++ b/default.kibot.yaml @@ -1,15 +1,25 @@ # Example KiPlot config file kibot: version: 1 +import: + - file: JLCPCB preflight: run_erc: true update_xml: true run_drc: true - check_zone_fills: false + set_text_variables: + - name: 'rev' + command: "if [ $(git describe --tags | wc -w) -gt 0 ]; then git describe --tags; else echo $CI_COMMIT_SHORT_SHA; fi" + - name: 'date' + expand_kibot_patterns: true + text: '%D' + fill_zones: true ignore_unconnected: false + global: environment: - models_3d: "/models_3d" + user_templates: "${CI_PROJECT_DIR}/.templates" + outputs: - name: 'print_sch' comment: "Print schematic (PDF)" @@ -25,7 +35,7 @@ outputs: options: output_name: PCB_Top.pdf layers: - - layer: B.Cu + - 'copper' - layer: F.SilkS - name: 'bom' @@ -39,6 +49,8 @@ outputs: - field: Quantity Per PCB name: Qty - Description + - mpn + - manf - field: References name: Schematic Reference csv: @@ -57,10 +69,11 @@ outputs: type: step dir: . options: - download: true - kicad_3d_url: https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/ + output: '%f_%r.%x' + download: false + subst_models: true - - name: 'position' + - name: 'neo_position' comment: "Pick and place" type: position options: @@ -70,125 +83,13 @@ outputs: separate_files_for_front_and_back: false only_smd: true - - name: 'assembly' - comment: "Pick and place file, JLC style" - type: position - options: - output: '%f_cpl.%x' - format: CSV - units: millimeters - separate_files_for_front_and_back: false - only_smd: true - columns: - - id: Ref - name: Designator - - Val - - Package - - id: PosX - name: "Mid X" - - id: PosY - name: "Mid Y" - - id: Rot - name: Rotation - - id: Side - name: Layer - - - name: 'gerbers' - comment: "Gerbers for the board house" - type: gerber - dir: Gerbers - options: - # generic layer options - exclude_edge_layer: true - exclude_pads_from_silkscreen: false - use_aux_axis_as_origin: false - plot_sheet_reference: false - plot_footprint_refs: true - plot_footprint_values: true - force_plot_invisible_refs_vals: false - tent_vias: true - # gerber options - line_width: 0.1 - subtract_mask_from_silk: false - use_protel_extensions: false - gerber_precision: 4.6 - create_gerber_job_file: true - use_gerber_x2_attributes: true - use_gerber_net_attributes: true - layers: - - 'copper' - - 'technical' - - layer: Edge.Cuts - suffix: Edge_Cuts - - - name: JLCPCB_gerbers - comment: Gerbers compatible with JLCPCB - type: gerber - dir: JLCPCB - options: - exclude_edge_layer: true - exclude_pads_from_silkscreen: true - plot_sheet_reference: false - plot_footprint_refs: true - plot_footprint_values: false - force_plot_invisible_refs_vals: false - tent_vias: true - use_protel_extensions: true - create_gerber_job_file: false - disable_aperture_macros: true - gerber_precision: 4.6 - use_gerber_x2_attributes: false - use_gerber_net_attributes: false - line_width: 0.1 - subtract_mask_from_silk: true - inner_extension_pattern: '.g%n' - layers: - # Note: a more generic approach is to use 'copper' but then the filenames - # are slightly different. - - F.Cu - - B.Cu - - In1.Cu - - In2.Cu - - In3.Cu - - In4.Cu - - In5.Cu - - In6.Cu - - F.SilkS - - B.SilkS - - F.Mask - - B.Mask - - Edge.Cuts - - - name: JLCPCB_drill - comment: Drill files compatible with JLCPCB - type: excellon - dir: JLCPCB - options: - pth_and_npth_single_file: false - pth_id: '-PTH' - npth_id: '-NPTH' - metric_units: true - map: gerber - route_mode_for_oval_holes: false - output: "%f%i.%x" - - - name: JLCPCB_fab - comment: ZIP file for JLCPCB - type: compress - dir: JLCPCB - options: - files: - - from_output: JLCPCB_gerbers - dest: / - - from_output: JLCPCB_drill - dest: / - - name: 'diff_pcb' comment: "Diff for visual comparison" type: diff dir: . options: only_different: true + old: KIBOT_TAG-0 - name: 'diff_sch' comment: "Diff for visual comparison" @@ -197,4 +98,17 @@ outputs: options: only_different: true pcb: false + old: KIBOT_TAG-0 + +groups: + - name: pcb + outputs: + - _JLCPCB_fab + - neo_position + - print_front + + - name: sch + outputs: + - bom + - print_sch