AnsweredAssumed Answered

Compiling variations on a common code base: best practices?

Question asked by Robert Poor on Jun 14, 2018
Latest reply on Sep 15, 2018 by Robert Poor

I have a large-ish body of code that supports seven different analog sensor boards (and more in the future...).  About 90% of the code is shared among all the variants.  I've already conditionalized the code to support the different sensor boards with constructs along these lines:

void sensor_init() {
#ifdef IS_SENSOR_A
    #error Unknown sensor!

When I build the project, MCUXpresso generates my_project.axf file compiled for one of the seven variants.  What I usually do then is rename my_project.axf to sensor_a.axf or sensor_b.axf depending on the conditionals in effect when I built it.


Of course, this approach is fraught with potential for errors -- it's easy to forget to rename the .axf file, and it's not obvious which variant  my_project.axf was compiled for after the fact.


Is there a way to do this automatically, or achieve the same effect?  (E.g. should I create seven different projects that share a common code base?  If so, how?)