[HELP] Proper multi-directory custom app integration
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
### Description
I am having issues with make recognizing file changes in my custom app. As a result, I need to `make clean` before every build which is not ideal.
I believe the root cause is my app having `src` and `include` directories instead of being contained in one directory like the custom app example in the NuttX documentation.
## My Project Structure
I made a sample git repo that demonstrates how I have the project set up (https://github.com/stbenn/NuttxCustomAppQuestion.git) to reference in addition to the following explanation.
Directory structure:
```
ProjectDir/
nuttx/
apps/
external/
Make.defs
Makefile
custom_app/ (symlink)
custom_app/
/include
header_files.h
/src
custom_app.c
other_sources.c
KConfig
Make.defs
Makefile
```
Command used to link custom app directory: in `ProjectDir`, `ln -sr custom_app apps/external/custom_app`
### `apps/external/Makefile`
```
MENUDESC = "External Apps"
include $(APPDIR)/Directory.mk
```
### `apps/external/Make.defs`
```
include $(wildcard $(APPDIR)/external/*/Make.defs)
```
### `custom_app/Make.defs`
```
ifneq ($(CONFIG_CUSTOM_APP),)
CONFIGURED_APPS += $(APPDIR)/external/custom_app
endif
```
### `custom_app/Makefile`
```
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_CUSTOM_APP),y)
PROGNAME = $(CONFIG_CUSTOM_APP_PROGNAME)
PRIORITY = $(CONFIG_CUSTOM_APP_PRIORITY)
STACKSIZE = $(CONFIG_CUSTOM_APP_STACKSIZE)
MAINSRC = src/custom_app.c
CSRCS = src/other_sources.c
# This is how to add the include directory to the build system.
# the path to the directory should match AFTER the symlink. So here it's apps/external/custom_app/include
CFLAGS += ${shell $(INCDIR) "$(CC)" "$(APPDIR)$(DELIM)external$(DELIM)custom_app$(DELIM)include"}
endif
include $(APPDIR)/Application.mk
.PHONY: clean
clean::
rm -f src/*.su
```
Note: I have also experimented with using `CFLAGS += ${INCDIR_PREFIX}${APPDIR}/external/custom_app/include` in `custom_app/Make.defs`
## Desired Behavior
The NuttX build system detects when changes are made to files in the subdirectories of `custom_app` without requiring a `make clean` before `make`.
### Verification
- [x] I have verified before submitting the report.
Contributor guide
Assessment
This issue has not been assessed yet.