Page 1 of 1

Create define for build question

Posted: Thu Apr 11, 2019 5:42 pm
by fly135
I want to be able to dynamically create a define for builds. I'm planning to have a build script that will write...

CXXFLAGS=-Dmydefine to a component.mk file. If i write it in my root project directory it seems to do nothing. If I write to my main project subdirectory it works, but doesn't work in a parallel folder components subdirectory. For example....

MyRootFolder
<tab>mainFolder
<tab>components/sensorsFolder
<tab>components/audioFolder

So the component.mk in mainFolder works for those files. But it appears I would have to modify component.mk in all the component subfolders. I'm looking for a simpler method that would cover the entire project.

Re: Create define for build question

Posted: Fri Apr 12, 2019 4:36 am
by ESP_Angus
To make project-wide changes, add a Makefile.projbuild file to one of your components (alongside component.mk), that sets "CPPFLAGS += -Dxyz"

(Note that these are a blunt instrument as they will also change all IDF source file compiler flags. Sparing use is recommended.)

Re: Create define for build question

Posted: Fri Apr 12, 2019 6:32 pm
by fly135
ESP_Angus wrote:
Fri Apr 12, 2019 4:36 am
To make project-wide changes, add a Makefile.projbuild file to one of your components (alongside component.mk), that sets "CPPFLAGS += -Dxyz"

(Note that these are a blunt instrument as they will also change all IDF source file compiler flags. Sparing use is recommended.)
The guy who's going to automate the builds wants to export an environment variable to define which H/W version of the device he's building the firmware for. I was able to do that with Makefile.projbuild. Thanks!!!

John A