.git folder appears to be included during make
maximweb opened this issue · 9 comments
Only recently, after I started to add code and several libraries as git submodule
in my project, it appears as if make tries to compile libraries from the .git
folder in my project, resulting in multiple errors.
Adding .git
to EXCLUDE_DIRS
removes this issue.
I am not very familiar with how make works, but in a different project where I use a similar structure and Arduino-Makefile, no such error occurs.
Maybe all hidden folders with leading .
should be ignored?
What kind of files became selected from that directory structure?
I use the pubsubclient library as submodule and checked out the latest version (v2.8). This is in a subfolder of my project ./libs/pubsubclient
My error message looks like this:
In file included from <redacted>/esp8266/hardware/esp8266/3.1.1/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp:26:
<redacted>/Code/.git/modules/libs/pubsubclient/refs/tags/list:1:1: error: expected unqualified-id before numeric constant
1 | 2d228f2f862a95846c65a8518c79f48dfc8f188c
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is strange, there should be no files getting selected in the .git directory as the search is only done for files with source file extensions. Could you please check what is in the .git/modules/libs/pubsubclient/refs/tags directory?
Excluding hidden files is of course something that makes sense, not so easy to do in an os independent way though.
I found a single file called list
containing 2d228f2f862a95846c65a8518c79f48dfc8f188c
, which is basically the commit hash currently checked out in the submodule.
Maybe the regex for the source file pattern is .c instead of .c?
I found a single file called
list
containing2d228f2f862a95846c65a8518c79f48dfc8f188c
, which is basically the commit hash currently checked out in the submodule.
I did some more testing and found that said file was created accidentally by me when I tried to find a specific tag of the submodule. Inside the submodule's folder, I accidentally ran git tag list
, which basically created a new tag, which then results in the file .git/modules/libs/pubsubclient/refs/tags/list
containing the commit hash. Removing the tag removed the problem.
Yet, I am still puzzled why it is included in the first place.
UPDATE: If I use a different tag (eg. git tag test
), however, the issue never occurs.
UPDATE2: Is this the line searching for files?
I know nothing about perl, merely did a quick search and found an question on stackoverflow. Could this be in any way relateed?
Ok, I understand now. In ESP8266WiFiGeneric.cpp:26 there is:
#include <list>
and by default all sub directories to the main sketch directory are added to the include file search.
Next commit will add /.git/ as default to the exclusion list
Done now in latest version