halconf and preprocessor switches

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Guillaume227
Posts: 13
Joined: Tue Apr 18, 2017 6:52 pm
Has thanked: 8 times

halconf and preprocessor switches

Postby Guillaume227 » Thu Nov 18, 2021 3:06 pm

Seeing how halconf.h is laid out with preprocessor switches like:

Code: Select all

#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
#define HAL_USE_SIO   FALSE
#endif

I expected to be able to set HAL_USE_SIO in the Makefile (e.g. USE_OPT+= -DHAL_USE_SIO=TRUE) as an alternative to editing the halconf.h file.
I ran into undefined errors which I tracked down to that kind of statement in driver.mk:

Code: Select all

ifneq ($(findstring HAL_USE_SIO TRUE,$(HALCONF)),)


So it seems the only way to activate a HAL feature is to actually have a different copy of halconf where the feature is set to TRUE?
Is it just me thinking that's misleading? Am I missing a way to turn a hal feature on 'programmatically'?

User avatar
Giovanni
Site Admin
Posts: 13809
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 934 times
Been thanked: 797 times
Contact:

Re: halconf and preprocessor switches

Postby Giovanni » Thu Nov 18, 2021 3:08 pm

Hi,

You need to disable the "smart build" option in the makefile then you can add -D switches to override configuration files.

Giovanni

Guillaume227
Posts: 13
Joined: Tue Apr 18, 2017 6:52 pm
Has thanked: 8 times

Re: halconf and preprocessor switches

Postby Guillaume227 » Thu Nov 18, 2021 3:27 pm

Sounds good - trading some compilation time in that case is totally fine. Thank you Giovanni.


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 4 guests