I have an embedded project that needs to run on two different flash memory sizes of the microcontroller family. All code is written in C.
The code is exactly the same except:
- a few #defines in a header file
- a few variable values in a function in a source file
I feels unnecessary to have two separate branches in source control, two places to do bug fixes, two FW versions to test and validate before product release etc. Especially since the differences are so small..?
What I would like is to have two versions of the header file in question and two versions of the source file in question. And then have some condition in the Makefile to compile one of the two. Sounds reasonable?
Something like this:
And SourceFile1 and 2 respectively include header file 1 and 2 as:
and
The problem is that HeaderFile1.h is included in quite a lot of the other source files in the project. I guess their includes would have to change to HeaderFile2.h based on the Makefile condition. That seems a bit harder to accomplish. With my above reasoning it would mean having to have two different versions of all source files that includes that paricular header file and compile one of the two based on the condition. That's not what I'm after.
Do I want to do something that is not possible? Do you have any other ideas of how to solve this?
Any help would be greatly appreciated!
The code is exactly the same except:
- a few #defines in a header file
- a few variable values in a function in a source file
I feels unnecessary to have two separate branches in source control, two places to do bug fixes, two FW versions to test and validate before product release etc. Especially since the differences are so small..?
What I would like is to have two versions of the header file in question and two versions of the source file in question. And then have some condition in the Makefile to compile one of the two. Sounds reasonable?
Something like this:
Code:
Makefile
ifeq (condition)
C_OBJECTS += SourceFile1.o
endif
ifeq (condition)
C_OBJECTS += SourceFile2.o
endif
Code:
SourceFile1.c
#include "HeaderFile1.h"
//code
Code:
SourceFile2.c
#include "HeaderFile2.h"
//code
Do I want to do something that is not possible? Do you have any other ideas of how to solve this?
Any help would be greatly appreciated!