Page 1 of 1

How do I build to support multiple variants of an Application?

Posted: Wed Mar 23, 2022 1:48 pm
by genedyne
I have an App that builds (against ESP-IDF) for a board used in one product.
I need to build the same App for the same board to be used in a different product. The second build requires a subset of the code (i.e., some of the files are not included) used in the original product, plus some 'variation' of the original code (i.e., different screens defined, some features not used, etc.).

For any build, the ESP-IDF build definition will be constant (i.e 'sdkconfig' does not change).

It seems like CMake defines the 'variant' system (cmake-variants.yaml) to address this type of issue, but it's not clear to me this is ideal, as changing variants might (?) require rebuilding of ALL components for each variant. Also, I don't see that use of CMake variants is explicitly supported in the ESP-IDF build system.

I might be able to use the ESP-IDF concept of 'Apps' to define the requirements for each build, but this also might (?) require rebuilding of ALL components for each variant.

I'm building on Linux, so I might be able to setup a second folder, soft-linking source files as required, plus using "#ifdef" extensively, but this seems fragile & convoluted.

Ideally, I would like a simple way to build the SDK components once, then rebuild only my App for each 'application variant' as I make changes to App source.

Does the ESP-IDF build system support this? If so, what is the preferred / recommended way to configure it?

Re: How do I build to support multiple variants of an Application?

Posted: Wed Mar 23, 2022 3:34 pm
by burtrum
Hi
I’ve just started looking at the exact opposite problem: the same app on ESP32 variants. I have ESP32, ESP32C3 and ESP32S2.

I think this is the Espressif example to look it.

https://github.com/espressif/esp-idf/tr ... lti_config

Separate build directories hold specific config files.

Burtrum

Re: How do I build to support multiple variants of an Application?

Posted: Wed Mar 23, 2022 5:06 pm
by genedyne
Thanks for the pointer @burtrum.
I updated to esp-idf v4.4 (I was on v4.3, which does not provide the example you cite), and checked the multi_config example.
It's not ideal, in that it builds the _entire_ SDK twice (once each for 'build_prod1', and 'build_prod2' folders).

Of course, apart from the unnecessary duplication, once compiled (and assuming no 'sdkconfig' changes occur), future builds will depend only on my source, so I can make this work.

Best Regards.

Re: How do I build to support multiple variants of an Application?

Posted: Wed Mar 23, 2022 9:37 pm
by tommeyers
I have built a configurator in java. It is to build variants of sensors configured from a library of modules. Each module has a companion xml of prompts, rules, resource items used.

I had an information block interface between modules. You picked one OS root / dispatcher and any sensor combination.

Ultimately it put all the code in a single file that was compiled.

It also prepared configuration reports and assured named resources ,(like gpio pins) we're not reserved for multiple uses.

Gui I/f.

Tom
It. Works well.