How to setup a Legato Application project that can be built for different hardware setups

Hi,

I use Developer Studio 5.3.1 to create Legato projects which should run on both mangOH Green and customer boards.
I would like to build for these different hardware boards using the same project source stack.
At this moment, I use a preprocessor #define in my C sources, and I use an environment variable in my .adef file.
So, this means that I always have to change my configuration at 2 different places.

Is there a way to use 1 type of configuration/variable/definition/symbol which can be used in both C sources and .adef files?

Example:

C source

#define HW_BOARD CUSTOMER_BOARD

#if HW_BOARD == MANGOH_GREEN
le_tty_Open(“/dev/ttyHSL1”, O_RDWR | O_NOCTTY | O_NDELAY);
#else
le_tty_Open(“/dev/ttyUSB4”, O_RDWR | O_NOCTTY | O_NDELAY);
#endif

adef file

requires:
{
device:
{
#if ${ENVIRONMENT_VAR_HW_BOARD} = mangoh_green
[rw] /dev/ttyHSL1 /dev/ttyHSL1
#else
[rw] /dev/ttyUSB4 /dev/ttyUSB4
#endif
}
}

Greetings,
annaertd

Maybe have a cflags section in your definition files and pass the preprocessor your board specific defines with the -D option?

Hi @annaertd,
same suggestion than @ktanikel: you should be able to use a cflags section with a different content according to your ENVIRONMENT_VAR_HW_BOARD value, specifying different -D options.

This solves my issue.
Thanks a lot!