I need to generate header files at compile time. As https://docs.espressif.com/projects/esp ... onentbuild claims it can be done using Makefile.componentbuild file. However there are no examples and I can not find any in the web.
I have tried to use additional component for that which overrides build and clean targets and sets COMPONENT_ADD_LDFLAGS to empty string. Unfortunately ESP-IDF build system still tries to do something with component's library which is not created in the case of pure code generating component.
As a last resort I can think of a custom target which will be executed before building sources. I don't want to create explicit dependencies for sources on this code generation target since there are quite a lot of files which include generated header and it is tedious to manage these deps manually. Therefore I would like to have this target always built before build target is executed but I don't really know how to do that.
I am talking about Make build system.
Thanks!
How to add code generation target?
-
- Posts: 69
- Joined: Thu Nov 01, 2018 8:32 am
Re: How to add code generation target?
Hi nameofuser1,
Please follow the description in the docs https://docs.espressif.com/projects/esp ... generation, you can see some usage examples here https://github.com/espressif/esp-idf/bl ... ent.mk#L65.
If you don't want to define dependencies, it's possible to setup the target as PHONY, so at the end your component.mk might look something like:
Since you're talking about GNU Make build system, so please take it only as a side-note (or a note to other users) that using CMake, generating of source files is described here https://docs.espressif.com/projects/esp ... generation,
Please follow the description in the docs https://docs.espressif.com/projects/esp ... generation, you can see some usage examples here https://github.com/espressif/esp-idf/bl ... ent.mk#L65.
If you don't want to define dependencies, it's possible to setup the target as PHONY, so at the end your component.mk might look something like:
Code: Select all
COMPONENT_EXTRA_CLEAN := generated_file
$(COMPONENT_LIBRARY): generated_file
.PHONY: generated_file
generated_file:
echo "Generating file" > $(COMPONENT_PATH)/generated_file
Who is online
Users browsing this forum: brushlow18 and 100 guests