Some background: I have a project based on ESP-IDF which has a complex builtin building system which you plug into with your own makefile (their documentation on using it).
This works fine (apart from occasional horrendous build times), but now I wanted to add a build target for unit tests for a component, which requires building this component against another project (the unit-test-app
).
So, I need another build target that calls another make
with another makefile and directory. Something like this works fine:
make -C $(path to unit-test-app) \
EXTRA_COMPONENT_DIRS=$(my component directory) \
TEST_COMPONENTS=$(my component name) \
ESPPORT=$(my serial port) \
-j clean app-flash monitor
But only if I execute it from bash. If I try to execute it from another makefile, it breaks either not finding some header files (the include path is different between the main and unit test project) or ignores the change of project (-C
argument) and executes the main project build.
What I tried:
- using
$(MAKE)
,$(shell which $(MAKE))
andmake
in the custom target - using
env -i $(shell which $(MAKE) ) -C ...
with forwarding required environment arguments to the child make - using
bash -l make -C ...
andbash -c make -C ...
What works but is a dirty hack: using echo $(MAKE) -C ...
in the make target and then running $(make tests)
from the command line.
As far as I know, this is an issue of the parent makefile setting something up in the environment that I did not separate the child makefile from. What else can I do to separate these two?
UPDATE: I have created an example project that shows the issue more clearly, please look at the top Makefile
of https://github.com/chanibal/esp-idf-template-with-unit-tests