Merge pull request #277 from lukasz-e/arduino-1.5.x-libs
Arduino 1.5.x libs - handle new library layout (issue #275) and hardware/vendor specific libs (issue #276)
This commit is contained in:
commit
8d443f62c8
3 changed files with 123 additions and 26 deletions
118
Arduino.mk
118
Arduino.mk
|
@ -317,6 +317,7 @@ ifndef ARCHITECTURE
|
||||||
ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1)
|
ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1)
|
||||||
# default to avr for 1.5
|
# default to avr for 1.5
|
||||||
ARCHITECTURE = avr
|
ARCHITECTURE = avr
|
||||||
|
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_AVR
|
||||||
else
|
else
|
||||||
# unset for 1.0
|
# unset for 1.0
|
||||||
ARCHITECTURE =
|
ARCHITECTURE =
|
||||||
|
@ -324,6 +325,17 @@ ifndef ARCHITECTURE
|
||||||
$(call show_config_variable,ARCHITECTURE,[DEFAULT])
|
$(call show_config_variable,ARCHITECTURE,[DEFAULT])
|
||||||
else
|
else
|
||||||
$(call show_config_variable,ARCHITECTURE,[USER])
|
$(call show_config_variable,ARCHITECTURE,[USER])
|
||||||
|
|
||||||
|
#avoid using shell for known architectures
|
||||||
|
ifeq ($(ARCHITECTURE),avr)
|
||||||
|
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_AVR
|
||||||
|
else
|
||||||
|
ifeq ($(ARCHITECTURE),sam)
|
||||||
|
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_SAM
|
||||||
|
else
|
||||||
|
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_$(shell echo $(ARCHITECTURE) | tr '[:lower:]' '[:upper:]')
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -467,6 +479,17 @@ else
|
||||||
$(call show_config_variable,ARDUINO_CORE_PATH,[USER])
|
$(call show_config_variable,ARDUINO_CORE_PATH,[USER])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# 1.5.x platform dependent libs path
|
||||||
|
ifndef ARDUINO_PLATFORM_LIB_PATH
|
||||||
|
ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1)
|
||||||
|
# only for 1.5
|
||||||
|
ARDUINO_PLATFORM_LIB_PATH = $(ARDUINO_DIR)/hardware/$(VENDOR)/$(ARCHITECTURE)/libraries
|
||||||
|
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_DIR))
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[USER])
|
||||||
|
endif
|
||||||
|
|
||||||
# Third party hardware and core like ATtiny or ATmega 16
|
# Third party hardware and core like ATtiny or ATmega 16
|
||||||
ifdef ALTERNATE_CORE
|
ifdef ALTERNATE_CORE
|
||||||
$(call show_config_variable,ALTERNATE_CORE,[USER])
|
$(call show_config_variable,ALTERNATE_CORE,[USER])
|
||||||
|
@ -847,6 +870,30 @@ CAT = cat
|
||||||
ECHO = printf
|
ECHO = printf
|
||||||
MKDIR = mkdir -p
|
MKDIR = mkdir -p
|
||||||
|
|
||||||
|
# recursive wildcard function, call with params:
|
||||||
|
# - start directory (finished with /) or empty string for current dir
|
||||||
|
# - glob pattern
|
||||||
|
# (taken from http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html)
|
||||||
|
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
|
||||||
|
|
||||||
|
# functions used to determine various properties of library
|
||||||
|
# called with library path. Needed because of differences between library
|
||||||
|
# layouts in arduino 1.0.x and 1.5.x.
|
||||||
|
# Assuming new 1.5.x layout when there is "src" subdirectory in main directory
|
||||||
|
# and library.properties file
|
||||||
|
|
||||||
|
# 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)))
|
||||||
|
|
||||||
|
# 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)))
|
||||||
|
|
||||||
# General arguments
|
# General arguments
|
||||||
USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)))
|
USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)))
|
||||||
USER_LIB_NAMES = $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS))
|
USER_LIB_NAMES = $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS))
|
||||||
|
@ -855,22 +902,30 @@ USER_LIB_NAMES = $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS))
|
||||||
SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS))))
|
SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS))))
|
||||||
SYS_LIB_NAMES = $(patsubst $(ARDUINO_LIB_PATH)/%,%,$(SYS_LIBS))
|
SYS_LIB_NAMES = $(patsubst $(ARDUINO_LIB_PATH)/%,%,$(SYS_LIBS))
|
||||||
|
|
||||||
# Error here if any are missing.
|
ifdef ARDUINO_PLATFORM_LIB_PATH
|
||||||
LIBS_NOT_FOUND = $(filter-out $(USER_LIB_NAMES) $(SYS_LIB_NAMES),$(ARDUINO_LIBS))
|
PLATFORM_LIBS = $(wildcard $(patsubst %,$(ARDUINO_PLATFORM_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS))))
|
||||||
ifneq (,$(strip $(LIBS_NOT_FOUND)))
|
PLATFORM_LIB_NAMES = $(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%,%,$(PLATFORM_LIBS))
|
||||||
$(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH and ARDUINO_LIB_PATH): $(LIBS_NOT_FOUND))
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SYS_LIBS := $(wildcard $(SYS_LIBS) $(addsuffix /utility,$(SYS_LIBS)))
|
|
||||||
USER_LIBS := $(wildcard $(USER_LIBS) $(addsuffix /utility,$(USER_LIBS)))
|
# Error here if any are missing.
|
||||||
SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS))
|
LIBS_NOT_FOUND = $(filter-out $(USER_LIB_NAMES) $(SYS_LIB_NAMES) $(PLATFORM_LIB_NAMES),$(ARDUINO_LIBS))
|
||||||
USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS))
|
ifneq (,$(strip $(LIBS_NOT_FOUND)))
|
||||||
LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS)))
|
ifdef ARDUINO_PLATFORM_LIB_PATH
|
||||||
LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(SYS_LIBS)))
|
$(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH, ARDUINO_LIB_PATH and ARDUINO_PLATFORM_LIB_PATH): $(LIBS_NOT_FOUND))
|
||||||
LIB_AS_SRCS = $(wildcard $(patsubst %,%/*.S,$(SYS_LIBS)))
|
else
|
||||||
USER_LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(USER_LIBS)))
|
$(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH and ARDUINO_LIB_PATH): $(LIBS_NOT_FOUND))
|
||||||
USER_LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(USER_LIBS)))
|
endif
|
||||||
USER_LIB_AS_SRCS = $(wildcard $(patsubst %,%/*.S,$(USER_LIBS)))
|
endif
|
||||||
|
|
||||||
|
SYS_INCLUDES = $(foreach lib, $(SYS_LIBS), $(call get_library_includes,$(lib)))
|
||||||
|
USER_INCLUDES = $(foreach lib, $(USER_LIBS), $(call get_library_includes,$(lib)))
|
||||||
|
LIB_C_SRCS = $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),c))
|
||||||
|
LIB_CPP_SRCS = $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),cpp))
|
||||||
|
LIB_AS_SRCS = $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),S))
|
||||||
|
USER_LIB_CPP_SRCS = $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),cpp))
|
||||||
|
USER_LIB_C_SRCS = $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),c))
|
||||||
|
USER_LIB_AS_SRCS = $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),S))
|
||||||
LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_C_SRCS)) \
|
LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_C_SRCS)) \
|
||||||
$(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_CPP_SRCS)) \
|
$(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_CPP_SRCS)) \
|
||||||
$(patsubst $(ARDUINO_LIB_PATH)/%.S,$(OBJDIR)/libs/%.o,$(LIB_AS_SRCS))
|
$(patsubst $(ARDUINO_LIB_PATH)/%.S,$(OBJDIR)/libs/%.o,$(LIB_AS_SRCS))
|
||||||
|
@ -878,8 +933,19 @@ USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/userlibs/%.o,$
|
||||||
$(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/userlibs/%.o,$(USER_LIB_C_SRCS)) \
|
$(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/userlibs/%.o,$(USER_LIB_C_SRCS)) \
|
||||||
$(patsubst $(USER_LIB_PATH)/%.S,$(OBJDIR)/userlibs/%.o,$(USER_LIB_AS_SRCS))
|
$(patsubst $(USER_LIB_PATH)/%.S,$(OBJDIR)/userlibs/%.o,$(USER_LIB_AS_SRCS))
|
||||||
|
|
||||||
|
ifdef ARDUINO_PLATFORM_LIB_PATH
|
||||||
|
PLATFORM_INCLUDES = $(foreach lib, $(PLATFORM_LIBS), $(call get_library_includes,$(lib)))
|
||||||
|
PLATFORM_LIB_CPP_SRCS = $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),cpp))
|
||||||
|
PLATFORM_LIB_C_SRCS = $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),c))
|
||||||
|
PLATFORM_LIB_AS_SRCS = $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),S))
|
||||||
|
PLATFORM_LIB_OBJS = $(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.cpp,$(OBJDIR)/platformlibs/%.o,$(PLATFORM_LIB_CPP_SRCS)) \
|
||||||
|
$(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.c,$(OBJDIR)/platformlibs/%.o,$(PLATFORM_LIB_C_SRCS)) \
|
||||||
|
$(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.S,$(OBJDIR)/platformlibs/%.o,$(PLATFORM_LIB_AS_SRCS))
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
# Dependency files
|
# Dependency files
|
||||||
DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $(CORE_OBJS:.o=.d)
|
DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(PLATFORM_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $(CORE_OBJS:.o=.d)
|
||||||
|
|
||||||
# Optimization level for the compiler.
|
# Optimization level for the compiler.
|
||||||
# You can get the list of options at http://www.nongnu.org/avr-libc/user-manual/using_tools.html#gcc_optO
|
# You can get the list of options at http://www.nongnu.org/avr-libc/user-manual/using_tools.html#gcc_optO
|
||||||
|
@ -906,9 +972,9 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Using += instead of =, so that CPPFLAGS can be set per sketch level
|
# Using += instead of =, so that CPPFLAGS can be set per sketch level
|
||||||
CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -D__PROG_TYPES_COMPAT__ \
|
CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) $(ARDUINO_ARCH_FLAG) -D__PROG_TYPES_COMPAT__ \
|
||||||
-I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \
|
-I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \
|
||||||
$(SYS_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \
|
$(SYS_INCLUDES) $(PLATFORM_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \
|
||||||
-fdata-sections
|
-fdata-sections
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
|
@ -998,7 +1064,7 @@ ifneq (,$(strip $(USER_LIB_NAMES)))
|
||||||
$(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER]))
|
$(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER]))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(strip $(SYS_LIB_NAMES)))
|
ifneq (,$(strip $(SYS_LIB_NAMES) $(PLATFORM_LIB_NAMES)))
|
||||||
$(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM]))
|
$(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM]))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1042,6 +1108,18 @@ $(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.S
|
||||||
@$(MKDIR) $(dir $@)
|
@$(MKDIR) $(dir $@)
|
||||||
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/platformlibs/%.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.c
|
||||||
|
@$(MKDIR) $(dir $@)
|
||||||
|
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/platformlibs/%.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.cpp
|
||||||
|
@$(MKDIR) $(dir $@)
|
||||||
|
$(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/platformlibs/%.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.S
|
||||||
|
@$(MKDIR) $(dir $@)
|
||||||
|
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
|
||||||
|
|
||||||
$(OBJDIR)/userlibs/%.o: $(USER_LIB_PATH)/%.cpp
|
$(OBJDIR)/userlibs/%.o: $(USER_LIB_PATH)/%.cpp
|
||||||
@$(MKDIR) $(dir $@)
|
@$(MKDIR) $(dir $@)
|
||||||
$(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
$(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
||||||
|
@ -1271,8 +1349,8 @@ pre-build:
|
||||||
$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
|
$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
|
||||||
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm
|
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm
|
||||||
|
|
||||||
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
|
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
|
||||||
$(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
|
$(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
|
||||||
|
|
||||||
error_on_caterina:
|
error_on_caterina:
|
||||||
$(ERROR_ON_CATERINA)
|
$(ERROR_ON_CATERINA)
|
||||||
|
|
|
@ -5,6 +5,8 @@ The following is the rough list of changes that went into different versions.
|
||||||
I tried to give credit whenever possible. If I have missed anyone, kindly add it to the list.
|
I tried to give credit whenever possible. If I have missed anyone, kindly add it to the list.
|
||||||
|
|
||||||
### In development
|
### In development
|
||||||
|
- New: Add support for new 1.5.x library layout (Issue #275) (https://github.com/lukasz-e)
|
||||||
|
- New: Add support for 1.5.x vendor/hardware architecture library location (Issue #276) (https://github.com/lukasz-e)
|
||||||
- New: Added test suite and integration with travis CI. (https://github.com/peplin)
|
- New: Added test suite and integration with travis CI. (https://github.com/peplin)
|
||||||
- New: Add information about `Bare-Arduino–Project` in README. (https://github.com/ladislas)
|
- New: Add information about `Bare-Arduino–Project` in README. (https://github.com/ladislas)
|
||||||
- New: Add information about reporting bugs to the correct project (Issue #231). (https://github.com/sej7278)
|
- New: Add information about reporting bugs to the correct project (Issue #231). (https://github.com/sej7278)
|
||||||
|
|
|
@ -111,6 +111,23 @@ ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
### ARDUINO_PLATFORM_LIB_PATH
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
|
||||||
|
Directory where the Arduino platform dependent libraries are stored.
|
||||||
|
(Used only for Arduino 1.5.x)
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```Makefile
|
||||||
|
ARDUINO_PLATFORM_LIB_PATH = /usr/share/arduino/hardware/arduino/avr/libraries
|
||||||
|
```
|
||||||
|
|
||||||
|
**Requirement:** *Optional*
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
### ARDUINO_VERSION
|
### ARDUINO_VERSION
|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
|
|
Loading…
Reference in a new issue