Page 1 of 1

Compile components selectively

Posted: Wed May 22, 2019 8:03 pm
by magnomp
My project will consist in a familly of many different device types for home automation based on esp mesh
My idea is to have a single project where main app code will do the common things (set up esp mesh, etc), and the functionality for specific device type will be in components.
Is this a good way?

So my question is : Can I select only one component during compile time?

I mean, supose my product family consist on "device type A", "device type B" and "device type C"
I will have a single project which has three subcomponents named "A", "B" and "C"
When I want to flash a device of type "B", I will compile the project without compiling "A" and "C"

Re: Compile components selectively

Posted: Thu May 23, 2019 1:48 am
by ESP_Sprite
The standard way of doing things would be to always compile A, B and C, but to use e.g. preprocessor macros in your main program to not call any functions in them unless they're selected.

Re: Compile components selectively

Posted: Thu May 23, 2019 7:47 pm
by magnomp
Will code from unused components be present on the final image?
For me it's ok if they're compiled but do not consume space on device.

Also, is this a good architecture? Would be better to have actual separated projects?

Re: Compile components selectively

Posted: Fri May 24, 2019 3:59 am
by ESP_Sprite
No, code consumed as such will not use memory (as it doesn't get linked in if it's not referred anywhere). With regards to architecture... I'd personally prefer having a shared component that does all the overlapping functionality, then referring to that from each project using an EXTRA_COMPONENT_DIRS line in your project makefile.

Re: Compile components selectively

Posted: Sun May 26, 2019 7:54 am
by Ritesh
magnomp wrote:
Wed May 22, 2019 8:03 pm
My project will consist in a familly of many different device types for home automation based on esp mesh
My idea is to have a single project where main app code will do the common things (set up esp mesh, etc), and the functionality for specific device type will be in components.
Is this a good way?

So my question is : Can I select only one component during compile time?

I mean, supose my product family consist on "device type A", "device type B" and "device type C"
I will have a single project which has three subcomponents named "A", "B" and "C"
When I want to flash a device of type "B", I will compile the project without compiling "A" and "C"
Hi,

I have one suggestion from my side like you can also use concept of Kconfig and Menuconfig related stuffs in which you can enable and compile components which are required as per your requirements with single source code.

Let me know if need any help regarding that.