From c93c8e16a5480205f452e18e022ad7f812ca7206 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 15:02:24 -0500 Subject: [PATCH] Improved library finding logic. Look first in the user dir. Any not found there are sought in the system (Arduino) dir. If any are not found, error out right away with a useful message. Show all libraries and where they were found (user or system) in the config info. --- arduino-mk/Arduino.mk | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5ab69c8..d50ff22 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -547,8 +547,19 @@ CAT = cat ECHO = echo # General arguments -SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS))) USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS))) +USER_LIB_NAMES= $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS)) + +# Let user libraries override system ones. +SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS)))) +SYS_LIB_NAMES = $(patsubst $(ARDUINO_LIB_PATH)/%,%,$(SYS_LIBS)) + +# Error here if any are missing. +LIBS_NOT_FOUND = $(filter-out $(USER_LIB_NAMES) $(SYS_LIB_NAMES),$(ARDUINO_LIBS)) +ifneq (,$(strip $(LIBS_NOT_FOUND))) + $(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH and ARDUINO_LIB_PATH): $(LIBS_NOT_FOUND)) +endif + SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS)) USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS)) LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS)))