diff --git a/Dockerfile b/Dockerfile index 8343584..c3e41bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM setsoft/kicad_debian as kicad LABEL MAINTAINER nerdyscout LABEL Description="export various files from KiCad projects" +LABEL VERSION="v0.2" # update packages RUN apt-get update @@ -34,11 +35,10 @@ RUN cd /opt/kiplot && pip3 install -e . COPY submodules/kicad-automation-scripts /opt/kicad-automation RUN pip3 install psutil==5.7.0 RUN pip3 install xvfbwrapper==0.2.9 -RUN apt-get install -y xvfb xclip xdotool +RUN apt-get install -y xvfb xclip xdotool xsltproc RUN cd /opt/kicad-automation && python3 setup.py install RUN alias pcbnew_do=/opt/kicad-automation/src/pcbnew_do && alias eeschema_do=/opt/kicad-automation/src/eeschema_do - #alias for all commands COPY functions.sh . COPY kicad-exports.sh /entrypoint.sh diff --git a/Makefile b/Makefile index 043c168..098f0c9 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ build: docker build -t kicad-exports . # echo "$(DOCKER)" > kicad-exports # chmod +x kicad-exports - cp -u kicad-exports ~/.local/bin/kicad-exports +# cp -u kicad-exports ~/.local/bin/kicad-exports shell: $(DOCKER) bash diff --git a/README.md b/README.md index 288a2e6..b9e31eb 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,17 @@ -This project aims to auto generate several files (gerbers, documentation, pictures, ...) for kicad projects. You could run it locally or on every `git push` with Github actions. +:warning: This project is still in a beta state, please use with care! -# Quick usage +kicad-exports aims to auto generate several files (gerbers, documentation, pictures, ...) for [kicad](kicad-pcb.org/) projects. You could run it locally or on every `git push` with Github Actions. + +# tl;dr ``` -./kicad-exports $COMMAND $DIR $SCHMATIC $BOARD $PROJECT $MANUFACTURER $PARAMETERS +cd /my/kicad/project +./kicad-exports $COMMAND $DIR_OUT $SCHMATIC_FILE $BOARD_FILE $PROJECT_FILE $MANUFACTURER $PARAMETERS ``` # usage of kicad-exports with Github Actions -run kicad-exports as individual step, as `cmd` several [functions](funtions.sh) are defined. +run kicad-exports as individual step, select `cmd` from list of [functions](functions.sh) according whatever you want to run. ```yaml name: example @@ -28,7 +31,7 @@ on: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: nerdyscout/kicad-exports@master + - uses: nerdyscout/kicad-exports@v0.2 with: # Required - command to run cmd: command to run on kicad files @@ -51,12 +54,14 @@ on: path: example ``` -For examples of more full workflows see [kicad-exports-test](https://github.com/nerdyscout/kicad-exports-test/tree/master/.github/workflows). +For examples of more full workflows see [kicad-exports-test](https://github.com/nerdyscout/kicad-exports-test/blob/v0.2/.github/workflows). # use kicad-exports local ## Installation +You need to have [Docker](https://www.docker.com/) installed. + ``` git clone github.com/nerdyscout/kicad-exports /some/where/kicad-exports cd /some/where/kicad-exports @@ -68,14 +73,14 @@ make build go to your KiCad project folder and run kicad-exports.sh ``` cd /my/kicad/project -./some/where/kicad-exports/kicad-exports.sh *$COMMAND* +./some/where/kicad-exports/kicad-exports.sh $COMMAND ``` -*$COMMAND* can be anything running within the container, e.g. +$COMMAND can be anything running within the container, e.g. ``` ./some/where/kicad-exports/kicad-exports.sh "eeschema_do export -f pdf $SCHEMATIC $DIR" ./some/where/kicad-exports/kicad-exports.sh kicad-schematic-pdf ``` -both lines do the same as there are several aliases defined, checkout the [functions.sh](functions.sh) +Both lines produce the same output as there are several aliases defined, checkout the [functions.sh](functions.sh). kicad-exports tries to guess your schematic file, board file etc. but if they are in a subfolder you have to set it manually. # Credits - [Kiplot](https://github.com/INTI-CMNB/kiplot) @@ -85,5 +90,4 @@ both lines do the same as there are several aliases defined, checkout the [funct - [PCBDraw](https://github.com/yaqwsx/PcbDraw) - [Tracespace](https://github.com/tracespace/tracespace/tree/master/packages/cli) - [IBoM](https://github.com/openscopeproject/InteractiveHtmlBom/wiki/Usage) -- https://github.com/obra/ -- https://github.com/INTI-CMNB/ \ No newline at end of file +- [kicad-tools](https://github.com/obra/kicad-tools) \ No newline at end of file diff --git a/action.yml b/action.yml index 5239ea1..95ba68c 100644 --- a/action.yml +++ b/action.yml @@ -25,7 +25,7 @@ inputs: required: false runs: using: 'docker' - image: docker://nerdyscout/kicad-exports:latest + image: docker://nerdyscout/kicad-exports:v0.2 args: - ${{ inputs.cmd }} - ${{ inputs.dir }} diff --git a/functions.sh b/functions.sh index 0842af6..eb7e5a3 100755 --- a/functions.sh +++ b/functions.sh @@ -2,6 +2,8 @@ function schematic() { kicad-schematic + mv $DIR/$NAME.pdf $DIR/$NAME"_schematic.pdf" + mv $DIR/$NAME.pdf $DIR/$NAME"_schematic.svg" } function report() { @@ -15,6 +17,19 @@ function fabrication() { kiplot-drills } +#function mechanics() { +# kiplot -b $BOARD -c /opt/kiplot/documentation.yaml -d /tmp +# kiplot -b $BOARD -c /opt/kiplot/drills.yaml -d /tmp +# tracespace -L /tmp/*Edge_Cuts.gbr /tmp/*PTH-drl.gbr /tmp/*Dwgs*.gbr +#} + +#function documentation() { +# schematic +# kiplot-documentation +# #TODO: run something to generate shiny svg from /tmp/$NAME*.gbr +# #eg board measurments, pinouts from comment layer etc +#} + function kicad-schematic() { kicad-schematic-svg kicad-schematic-pdf @@ -32,10 +47,18 @@ function kicad-netlist() { eeschema_do $VERBOSE netlist $SCHEMATIC $DIR } +function erc() { + kicad-erc +} + function kicad-erc() { eeschema_do $VERBOSE run_erc $SCHEMATIC $DIR } +function drc() { + kicad-drc +} + function kicad-drc() { pcbnew_do $VERBOSE run_drc $BOARD $DIR } @@ -46,9 +69,10 @@ function bom() { kicost } -#TODO: this one still fails +# dont get confused... this actually outputs a CSV function kicad-bom() { eeschema_do $VERBOSE bom_xml $SCHEMATIC $DIR + rm $DIR/$NAME.xml } #TODO: define more sets with various layers @@ -56,25 +80,29 @@ function kicad-board() { pcbnew_do $VERBOSE export $BOARD $DIR Dwgs.User Cmts.User } -#TODO: this one still fails function kibom() { - eeschema_do $VERBOSE bom_xml $SCHEMATIC /tmp - python3 -m kibom $VERBOSE -d $DIR /tmp/$NAME.xml --cfg /opt/kibom/bom.ini $DIR/$PROJECT.xlsx + python3 -m kibom $VERBOSE -d $DIR $NAME.xml --cfg /opt/kibom/bom.ini $DIR/$NAME.xlsx + rm $DIR/$NAME.xml } function ibom() { sh /opt/ibom/ibom.sh $BOARD $DIR } -#FIXME function kicost() { - python3 -m kicost -i $DIR/$NAME.xml -o $DIR/$NAME.xlsx --include digikey farnell + eeschema_do $VERBOSE bom_xml $SCHEMATIC $DIR + python3 -m kicost -i $DIR/$NAME.xml -o $DIR/$NAME.xlsx $PARAMETERS + rm $DIR/$NAME.xml } function gerbers() { kiplot-gerber } +function kiplot-documentation() { + kiplot -b $BOARD -c /opt/kiplot/documentation.yaml $VERBOSE -d $DIR +} + function kiplot-gerber() { kiplot -b $BOARD -c /opt/kiplot/gerbers.yaml $VERBOSE -d $DIR } @@ -82,8 +110,9 @@ function kiplot-gerber() { function kiplot-position() { kiplot -b $BOARD -c /opt/kiplot/position.yaml $VERBOSE -d $DIR if [ "$MANUFACTURER" = "jlcpcb" ]; then - sed s/'Ref,Val,Package,PosX,PosY,Rot,Side'/'Designator,Value,Package,Mid X,Mid Y,Rotation,Layer'/g $DIR/*pos.csv + sed -i s/'Ref,Val,Package,PosX,PosY,Rot,Side'/'Designator,Value,Package,Mid X,Mid Y,Rotation,Layer'/g $DIR/*pos.csv fi + # define other manufacturers } function kiplot-drills() { @@ -109,44 +138,44 @@ function pcbdraw-bottom() { # fi } +#fails because of "swig/python detected a memory leak of type 'DLIST_ITERATOR_WRAPPER< D_PAD > *', no destructor found." function pcbdraw-bare() { pcbdraw-bare-front pcbdraw-bare-bottom } function pcbdraw-bare-front() { - -# if [ "$MANUFACTURER" = "oshpark" ]; then -# TODO: -# generate purple pcb -# else + if [ "$MANUFACTURER" = "oshpark" ]; then + # FIXME: might fail as i dont know wher the styles are located + pcbdraw --filter "" --style oshpark-purple.json $BOARD $DIR/$NAME"_bare_front.png" + else pcbdraw --filter "" $BOARD $DIR/$NAME"_bare_front.png" -# fi + fi } function pcbdraw-bare-bottom() { -# if [ "$MANUFACTURER" = "oshpark" ]; then -# TODO: -# generate purple pcb -# else + if [ "$MANUFACTURER" = "oshpark" ]; then + # FIXME: might fail as i dont know wher the styles are located + pcbdraw --filter "" --style oshpark-purple.json -b $BOARD $DIR/$NAME"_bare_bottom.png" + else pcbdraw --filter "" -b $BOARD $DIR/$NAME"_bare_bottom.png" -# fi + fi } function tracespace-board() { kiplot -b $BOARD -c /opt/kiplot/gerbers.yaml $VERBOSE -d /tmp kiplot -b $BOARD -c /opt/kiplot/drills.yaml $VERBOSE -d /tmp tracespace -L /tmp/*Edge_Cuts.gbr /tmp/*.drl /tmp/*Mask.gbr /tmp/*SilkS.gbr /tmp/*Cu.gbr - mv $NAME*top*.svg $DIR/$NAME"_Top_Board.svg" - mv $NAME*bottom*.svg $DIR/$NAME"_Bottom_Board.svg" + mv $NAME*top*.svg $DIR/$NAME"_Board_Top.svg" + mv $NAME*bottom*.svg $DIR/$NAME"_Board_Bottom.svg" } function tracespace-assembly() { kiplot -b $BOARD -c /opt/kiplot/gerbers.yaml $VERBOSE -d /tmp kiplot -b $BOARD -c /opt/kiplot/drills.yaml $VERBOSE -d /tmp tracespace -B /tmp/*Fab.gbr - mv $NAME*B_Fab*.svg $DIR/$NAME"_Bottom_Assembly.svg" - mv $NAME*F_Fab*.svg $DIR/$NAME"_Top_Assembly.svg" + mv $NAME*B_Fab*.svg $DIR/$NAME"_Assembly_Bottom.svg" + mv $NAME*F_Fab*.svg $DIR/$NAME"_Assembly_Top.svg" } function kikit-panelize() { diff --git a/kicad-exports b/kicad-exports deleted file mode 100755 index de1b28f..0000000 --- a/kicad-exports +++ /dev/null @@ -1 +0,0 @@ -docker run -it --volume $PWD:/mnt kicad-exports diff --git a/opt/kiplot/documentation.yaml b/opt/kiplot/documentation.yaml new file mode 100644 index 0000000..1cb220a --- /dev/null +++ b/opt/kiplot/documentation.yaml @@ -0,0 +1,61 @@ +# https://github.com/INTI-CMNB/kiplot + +kiplot: + version: 1 + + preflight: + run_erc: false + update_xml: false + run_drc: false + check_zone_fills: true + ignore_unconnected: true + +outputs: + - name: "documentation" + comment: "documentation layers from PCB" + type: "gerber" + dir: "" + options: + # generic layer options + exclude_edge_layer: false + exclude_pads_from_silkscreen: false + use_aux_axis_as_origin: false + plot_sheet_reference: true + plot_footprint_refs: true + plot_footprint_values: true + force_plot_invisible_refs_vals: false + tent_vias: true + check_zone_fills: true + + # gerber options + line_width: 0.15 + subtract_mask_from_silk: true + use_protel_extensions: false + gerber_precision: 4.5 + create_gerber_job_file: false + use_gerber_x2_attributes: true + use_gerber_net_attributes: false + + layers: + - layer: F.SilkS + suffix: F_SilkS + - layer: F.Fab + suffix: F_Fab + - layer: B.SilkS + suffix: B_SilkS + - layer: B.Fab + suffix: B_Fab + - layer: Edge.Cuts + suffix: Edge_Cuts + - layer: Cmts.User + suffix: Cmts_User + - layer: Dwgs.User + suffix: Dwgs_User + - layer: Eco1.User + suffix: Eco1_User + - layer: Eco2.User + suffix: Eco2_User + - layer: F.CrtYd + suffix: F_CrtYd + - layer: B.CrtYd + suffix: B_CrtYd \ No newline at end of file