We are building our project with nRF52811 and Segger Studio V5.34. (I have Ubuntu 1804 if it helps.)
We have certain variable configurations but would like the ability to build the project without having to change the source files, i.e. the ability to modify/define a handful of macro definitions.
We are using a custom script to call "embuild" with
./emBuild -config Release -rebuild [....]beacon.emProject
And it's been workin well for us.
However, we'd also like the ability to modify a handful of macro #defined values, for example: to go with C source code:
#ifdef CODE_VERSION_DEF // also tried #if
#warning "CODE_VERSION_DEF is not defined"
// something else
We've found there is a
-D 'macro'='value' set the value of a global macro
I've found this page with Segger's official documentation, but sadly, it doesn't give me an example or specific use cases.
Would you guys be able to help us figure out whether this is a supported use case, or if the -D option meant something entirely differently?
I think this question is best directed to SEGGER:https://www.segger.com/support/technical-support/ https://forum.segger.com/
Quirky, but this looks like a way to do it ...
Only downside is if not using the embuild command-line (ie. using SES IDE), it is not clear what $(EXT_APP_VER) may default to.
The functionality works, but as expected, there seems to be a problem when using the same .emproject via the SES IDE.
If I setup up a preprocessor variable defined as follows:
... then using -D EXT_MY_PREPROCESS_VAR=3 works fine.
BUT via SES IDE, the MY_PREPROCESS_VAR will exist, but I cannot test it as below .. because compiler / preprocessor will see MY_PREPROCESS_VAR defined as $(EXT_MY_PREPROCESS_VAR) and exit on a compile error.
#if defined(MY_PREPROCESS_VAR) && (MY_PREPROCESS_VAR == 3)
In the project, I can define a default project macro: e.g EXT_MY_PREPROCESS_VAR=2
... but here is the jist of the problem. This project macro value does not get over-ridden by -D EXT_MY_PREPROCESS_VAR=3