Generated silk text with version number

This week I fininalized my toolchain too make arduino projects with. There are 2 things which could be used for pcb designs in kicad.

I have made a python script which can initialize a git repo and push it to github.com without touching the browser and I have a release script which helps with making software releases. It commits, makes a tag, makes a changelog.txt, pushes etc etc.

One of things this release script does, is generating a header file with the latest git tag number. The tag number is embedded in the binaries.

For kicad I would like something similars. I want to use a release script which handles all the git stuff, make gerbers, drill files, zip those and I want one of the silk texts to become generated.

I have examined a small .kicad_pcb file and I found that silk texts are stored in this format.

  (gr_text "servoDriver V2.0\nBy Bas Knippels" (at 189.992 138.176) (layer F.SilkS)
    (effects (font (size 0.6 0.6) (thickness 0.12)))
  )

I noticed that I cannot simply add a new line to the bottom of the file. So I need to let a script start doing cutting and pasting in the mid of the kicad_pcb file.

The only way to do this is to read the entire file, store it in the python script and assemble a new file.

The phrase ‘version’ only exists one whole time on the top of the file. I was thinking to use the word ‘version’ in the silk text as a token for my text so I can find it.

I don’t think it is that much work tbh, but I was wondering if others already did something like this for me which I can use?

Kind regards,

Bas

One option is to use the string replacement feature in kicad-v6

you can declare a string replacement (say VER) from the board setup and then use it within PCBNEW as ${VER} and it is replaced by the value.

the VER:string mapping is stored in the kicad_pro file so a simple SED can update it as it is a KEY:VALUE mapping

I’m trying to work out how you know, a priori, what the hash will be BEFORE you incorporate it into the design. Are you, perhaps, saving the version hash as an unversioned file, that you indirectly reference within the pcb file?

Otherwise, you only know post facto and your commit cannot actually include the its own hash and your commits and references will be ‘off by one’.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.