Compile components selectively

magnomp
Posts: 13
Joined: Tue Sep 11, 2018 7:57 pm

Compile components selectively

Postby magnomp » 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"

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: Compile components selectively

Postby ESP_Sprite » Thu May 23, 2019 1:48 am

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.

magnomp
Posts: 13
Joined: Tue Sep 11, 2018 7:57 pm

Re: Compile components selectively

Postby magnomp » Thu May 23, 2019 7:47 pm

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?

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: Compile components selectively

Postby ESP_Sprite » Fri May 24, 2019 3:59 am

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.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Compile components selectively

Postby Ritesh » Sun May 26, 2019 7:54 am

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.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: Google [Bot] and 257 guests