This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

emBuild configuration - global macro

Hi,

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
// something
#else
#warning "CODE_VERSION_DEF is not defined"
// something else
#endif

We've found there is a 

-D 'macro'='value'        set the value of a global macro
option with "emBuild" but when we pass 
-D CODE_VERSION_DEF=0x00000001
to building command, and use -show, or -echo to show us the actual commands being used, but the new -D commands are not present in the building process.

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?

Thanks!

Siyuan

Parents Reply Children
  • Kind of...

    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...

Related