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
  • Quirky, but this looks like a way to do it ...

    https://forum.segger.com/index.php/Thread/4785-SOLVED-EMBuild-D-option/

    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:

    MY_PREPROCESS_VAR=$(EXT_MY_PREPROCESS_VAR)

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

    Grrr ...

Children
No Data
Related