anchao edited a comment on pull request #395:
URL: 
https://github.com/apache/incubator-nuttx-apps/pull/395#issuecomment-694942015


   Hi @v01d,
   
   Yes, thanks for review, totally agree with you!
   
   Let me first introduce the cause of this issue first,
   In some open source projects, we often encounter files with the same source 
file name but in different directories, 
   for example:
   
   ```
   chao@archer:~/code/apps/examples/hello$ tree
   .
   ├── hello_main.c
   ├── Kconfig
   ├── Make.defs
   ├── Makefile
   ├── test
   │   └── test.c
   └── test2
       └── test.c
   ```
   
   
   If we use VPATH to build this project, we will find that only one file is 
compiled because VPATH mistakenly believes that another file is already 
dependent:
   
   Makefile:
   
   ```
   include $(APPDIR)/Make.defs
   ...
   VPATH := test test2
   CSRCS += test.c test.c
   ....
   include $(APPDIR)/Application.mk
   ```
   
   Compile object:
   
   ```
   chao@archer:~/code/apps/examples/hello$ tree
   .
   ├── hello_main.c
   ├── hello_main.home.chao.code.apps.examples.hello.o
   ├── Kconfig
   ├── Make.defs
   ├── Make.dep
   ├── Makefile
   ├── test
   │   └── test.c
   ├── test2
   │   └── test.c
   └── test.home.chao.code.apps.examples.hello.o
   ```
   
   So VPATH is not a good choice in this case, we must use relative paths to 
ensure that the files are compiled:
   
   Makefile:
   ```
   include $(APPDIR)/Make.defs
   ...
   CSRCS += test/test.c test2/test.c
   ...
   include $(APPDIR)/Application.mk
   ```
   
   compile object:
   
   ```
   chao@archer:~/code/apps/examples/hello$ tree
   .
   ├── hello_main.c
   ├── hello_main.home.chao.code.apps.examples.hello.o
   ├── Kconfig
   ├── Make.defs
   ├── Make.dep
   ├── Makefile
   ├── test
   │   ├── test.c
   │   └── test.home.chao.code.apps.examples.hello.o
   └── test2
       ├── test.c
       └── test.home.chao.code.apps.examples.hello.o
   ```
   
   As you see, the source code was compiled correctly, then we encountered a 
new problem, "How to clear it?"
   
   I have traversed a lot of source code in nuttx , the build system of nuttx 
is basically built with VPATH, so there is no case where the source code file 
names are the same.
   
   Therefore, this clean process will be a special and partially effective 
process. In order to reduce the damage, I only take effect when building 
external applications, I think this is a comprehensive consideration for a lot 
of 3rd open source project.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to