sudar / Arduino-Makefile

Makefile for Arduino sketches. It defines the workflows for compiling code, flashing it to Arduino and even communicating through Serial.
http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile
GNU Lesser General Public License v2.1
2.02k stars 449 forks source link

Search for headers and source files in subdirectories other than utility #521

Open ladislas opened 7 years ago

ladislas commented 7 years ago

Currently, get_library_includes and get_library_files are only searching inside the utility subfolder.

But it sometimes happens that directories have different names like ChRt.

Adding the following lines fixes everything! 👍 And we could even remove the utility part as the wildcard takes care of that.


diff --git a/Arduino.mk b/Arduino.mk
index 50d60ee..78d1eac 100644
--- a/Arduino.mk
+++ b/Arduino.mk
@@ -926,14 +926,15 @@ rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst
 # Gets include flags for library
 get_library_includes = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \
                            -I$(1)/src, \
-                           $(addprefix -I,$(1) $(wildcard $(1)/utility)))
+                           $(addprefix -I,$(1) $(wildcard $(1)/utility)) \
+                           $(addprefix -I,$(1) $(dir $(wildcard $(1)/*/))))

 # Gets all sources with given extension (param2) for library (path = param1)
 # for old (1.0.x) layout looks in . and "utility" directories
 # for new (1.5.x) layout looks in src and recursively its subdirectories
 get_library_files  = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \
                         $(call rwildcard,$(1)/src/,*.$(2)), \
-                        $(wildcard $(1)/*.$(2) $(1)/utility/*.$(2)))
+                        $(wildcard $(1)/*.$(2) $(1)/*/*.$(2) $(1)/utility/*.$(2)))

 # General arguments
 USER_LIBS      := $(sort $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS))))```
sej7278 commented 7 years ago

yup, makes sense. PR?

ladislas commented 7 years ago

sure, just a sec

ladislas commented 7 years ago

522 here you go