Post build hooks, toolchain.cmake and inheriting from targets

DFU (at least for nordic) requires a .dat file with a computed checksum. I cribbed some work from a nordic python script to generate that
https://github.com/jacobrosenthal/redbearlab-nrf51822-gcc/blob/master/scripts/generate_dat.py

Now Im trying to find a place for it in the build pipeline. I thought maybe by my target would be a good place to put it, as I already have a target that inherits from nordic, so I added it to a scripts folder and added a toolchain.cmake and call it during a POST BUILD hook

This works, but now the nordic target Im inheriting from doesnt have its toolchain.cmake called anymore, which I want because it generates the combined .hex file with their softdevice.

I could obviously copy the entirety of nordics target scripts, but then whats the point of inheritance anymore?

Any ideas?

Currently there can only be one yotta_apply_target_rules function. Ideally these would be inherited, but I’m not yet sure how best to do that.

For now you will need to duplicate the objcopy rule from the base target into your own yotta_apply_target_rules function, sorry!

Note that the toolchain.cmake file from the base target still does get run (other things are inherited correctly), but when you define yotta_apply_target_rules it replaces the existing definition, instead of extending it.

The base target could be improved to provide that function under a different name that you can chain a call to, though that still isn’t ideal.