Skip to content

Process KiCad output #16

Open
Open
@stif

Description

@stif

It would be great if you could process the KiCad Output so it is more useful to KiCad Users:

  • Copy *.kicad_mod files into seperate folder
  • *.mod files are not needed for recent KiCad Versions as far as i know
  • concat all *.lib files together
  • concat all *.dcm files together

I wrote a small bash script for the necessary steps, but i dont know how to do it in rust:

#!/bin/bash

LIBRARY="LibraryLoader.lib"
DOCLIB="LibraryLoader.dcm"
FOOTPRINT_FOLDER="LibraryLoader.pretty"

#Add static Lines at beginning of Library and Doclib File
echo 'EESchema-LIBRARY Version 2.3' > ${LIBRARY}
echo '#encoding utf-8' >> ${LIBRARY}
echo 'EESchema-DOCLIB  Version 2.0' > ${DOCLIB}

echo Footprint Folder: ${FOOTPRINT_FOLDER}

if [ ! -d ${FOOTPRINT_FOLDER} ]; then
mkdir ${FOOTPRINT_FOLDER}
fi

for d in *; do
  if [ -d ${d} ]; then # test if it is a directory or file
  	if [ ${d} != ${FOOTPRINT_FOLDER} ]; then # skip Footprint Folder itself
      echo processing $d ...
      # copy footprint to footprint folder
      cp -av ${d}/*.kicad_mod ${FOOTPRINT_FOLDER} 
      # concat all chars between DEF and ENDDEF to Library file
      cat ${d}/*.lib | sed -e '1h;2,$H;$!d;g' -re 's/.*(DEF.*ENDDEF).*/\1/g' >> ${LIBRARY}
      # concat all chars between $CMP and ENDCMP to Doclib file
      cat ${d}/*.dcm | sed -e '1h;2,$H;$!d;g' -re 's/.*(\$CMP.*ENDCMP).*/\1/g' >> ${DOCLIB}
    fi
  fi
done

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions