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/
Seeing the same here. Did you find a solution ?
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
I was trying out everything I could think of, and I did try something similar to what you discribed in the other reply. And got the same issue.
I also tried to see if the IDE can grab values from an OS environment var. However, the IDE's documentation on (what I think was) relevant parts is next to none.
If the -D option does not over-ride/create a new definition, then hopping through yet another pre-processor def only makes my project messier.
So what I decided to do was a python script that generates the "version" #define (you can put this into a "pre build" command), and use the "post build" to call another script (in my case, same script with a different option) to delete the "version" so that you won't be accidentally building a code that has wrong version info.
This is waaaay more convoluted that what I envisioned at first... but kinda works for the time being...
Word of caution: Cross building platform is another beast and my solution here does not play nice enough, at least across Win <-> Linux, but I didn't put too much effort in it...