Name component makefiles component.mk instead of Makefile

Fixes problems with Eclipse trying to build in directories it shouldn't.

This is a breaking change for existing repositories, they need to rename
any component Makefiles to component.mk and rename their references to
$(IDF_PATH)/make/component.mk to $(IDF_PATH)/make/component_common.mk
This commit is contained in:
Angus Gratton
2016-09-01 09:19:06 +10:00
parent 71785378bc
commit 3b1c3dab4b
12 changed files with 30 additions and 30 deletions

View File

@@ -127,7 +127,7 @@ all components and make the elf target depend on this. The targets
invoke Make on the makefiles of the components in a subshell: this way invoke Make on the makefiles of the components in a subshell: this way
the components have full freedom to do whatever is necessary to build the components have full freedom to do whatever is necessary to build
the library without influencing other components. By default, the the library without influencing other components. By default, the
component includes the utility makefile $(IDF_PATH)/make/component.mk. component includes the utility makefile $(IDF_PATH)/make/component_common.mk.
This provides default targets and configurations that will work This provides default targets and configurations that will work
out-of-the-box for most projects. out-of-the-box for most projects.
@@ -158,7 +158,7 @@ minimum, it will just include the ESP-IDF component makefile, which adds
component functionality: component functionality:
----8<---- ----8<----
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk
---->8---- ---->8----
This will take all the .c and .S files in the component root and compile This will take all the .c and .S files in the component root and compile
@@ -169,7 +169,7 @@ system by setting COMPONENT_SRCDIRS:
----8<---- ----8<----
COMPONENT_SRCDIRS := src1 src2 COMPONENT_SRCDIRS := src1 src2
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk
---->8---- ---->8----
This will compile all source files in the src1/ and src2/ subdirectories This will compile all source files in the src1/ and src2/ subdirectories
@@ -183,7 +183,7 @@ objects that need to be generated:
----8<---- ----8<----
COMPONENT_OBJS := file1.o file2.o thing/filea.o thing/fileb.o anotherthing/main.o COMPONENT_OBJS := file1.o file2.o thing/filea.o thing/fileb.o anotherthing/main.o
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk
---->8---- ---->8----
This can also be used in order to conditionally compile some files This can also be used in order to conditionally compile some files
@@ -200,7 +200,7 @@ config FOO_ENABLE_BAR
Makefile: Makefile:
----8<---- ----8<----
COMPONENT_OBJS := foo_a.o foo_b.o $(if $(CONFIG_FOO_ENABLE_BAR),foo_bar.o foo_bar_interface.o) COMPONENT_OBJS := foo_a.o foo_b.o $(if $(CONFIG_FOO_ENABLE_BAR),foo_bar.o foo_bar_interface.o)
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk
---->8---- ---->8----
Some components will have a situation where a source file isn't supplied Some components will have a situation where a source file isn't supplied
@@ -217,7 +217,7 @@ graphics_lib.o: logo.h
logo.h: $(COMPONENT_PATH)/logo.bmp logo.h: $(COMPONENT_PATH)/logo.bmp
bmp2h -i $^ -o $@ bmp2h -i $^ -o $@
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk
---->8---- ---->8----
In this example, graphics_lib.o and logo.h will be generated in the In this example, graphics_lib.o and logo.h will be generated in the
@@ -242,7 +242,7 @@ logo.h: $(COMPONENT_PATH)/logo.bmp
$(summary) BMP2H $@ $(summary) BMP2H $@
$(Q) bmp2h -i $^ -o $@ $(Q) bmp2h -i $^ -o $@
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk
---->8---- ---->8----
Obviously, there are cases where all these recipes are insufficient for a Obviously, there are cases where all these recipes are insufficient for a

View File

@@ -1,7 +1,7 @@
# #
# Main Makefile. This is basically the same as a component makefile. # Main Makefile. This is basically the same as a component makefile.
# #
# This Makefile should, at the very least, just include $(IDF_PATH)/make/component.mk. By default, # This Makefile should, at the very least, just include $(IDF_PATH)/make/component_common.mk. By default,
# this will take the sources in the src/ directory, compile them and link them into # this will take the sources in the src/ directory, compile them and link them into
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable, # lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
# please read the esp-idf build system document if you need to do this. # please read the esp-idf build system document if you need to do this.
@@ -10,4 +10,4 @@
COMPONENT_ADD_LDFLAGS := -L $(abspath .) -lmain -T esp32.bootloader.ld -T $(IDF_PATH)/components/esp32/ld/esp32.rom.ld COMPONENT_ADD_LDFLAGS := -L $(abspath .) -lmain -T esp32.bootloader.ld -T $(IDF_PATH)/components/esp32/ld/esp32.rom.ld
COMPONENT_EXTRA_INCLUDES := $(IDF_PATH)/components/esp32/include COMPONENT_EXTRA_INCLUDES := $(IDF_PATH)/components/esp32/include
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk

View File

@@ -1,7 +1,7 @@
# #
# Component Makefile # Component Makefile
# #
# This Makefile should, at the very least, just include $(IDF_PATH)/make/component.mk. By default, # This Makefile should, at the very least, just include $(IDF_PATH)/make/component_common.mk. By default,
# this will take the sources in this directory, compile them and link them into # this will take the sources in this directory, compile them and link them into
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable, # lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
# please read the esp-idf build system document if you need to do this. # please read the esp-idf build system document if you need to do this.
@@ -33,7 +33,7 @@ COMPONENT_ADD_LDFLAGS := -lesp32 \
-L $(abspath ld) \ -L $(abspath ld) \
$(LINKER_SCRIPTS) $(LINKER_SCRIPTS)
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk
ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS)) ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))

View File

@@ -6,4 +6,4 @@ COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME) -Wl,--undefined=uxTopUsedPriority
COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_ADD_INCLUDEDIRS := include
COMPONENT_PRIV_INCLUDEDIRS := include/freertos COMPONENT_PRIV_INCLUDEDIRS := include/freertos
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk

View File

@@ -8,4 +8,4 @@ COMPONENT_SRCDIRS := api apps/sntp apps core/ipv4 core/ipv6 core netif port/free
EXTRA_CFLAGS := -Wno-error=address -Waddress -DLWIP_ESP8266 EXTRA_CFLAGS := -Wno-error=address -Waddress -DLWIP_ESP8266
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk

View File

@@ -5,4 +5,4 @@ define COMPONENT_BUILDRECIPE
#Nothing to do; this does not generate a library. #Nothing to do; this does not generate a library.
endef endef
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk

View File

@@ -6,4 +6,4 @@ COMPONENT_ADD_INCLUDEDIRS := include
COMPONENT_SRCDIRS := src COMPONENT_SRCDIRS := src
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk

View File

@@ -1,3 +0,0 @@
COMPONENT_ADD_INCLUDEDIRS := include
include $(IDF_PATH)/make/component.mk

View File

@@ -0,0 +1,3 @@
COMPONENT_ADD_INCLUDEDIRS := include
include $(IDF_PATH)/make/component_common.mk

View File

@@ -4,4 +4,4 @@
EXTRA_CFLAGS := -DLWIP_ESP8266 EXTRA_CFLAGS := -DLWIP_ESP8266
include $(IDF_PATH)/make/component.mk include $(IDF_PATH)/make/component_common.mk

View File

@@ -1,13 +1,13 @@
# #
# Main Project Makefile # Main Project Makefile
# This Makefile is included directly from the user project Makefile in order to call the Makefiles of all the # This Makefile is included directly from the user project Makefile in order to call the component.mk
# components (in a separate make process) to build all the libraries, then links them together # makefiles of all components (in a separate make process) to build all the libraries, then links them
# into the final file. If so, PWD is the project dir (we assume). # together into the final file. If so, PWD is the project dir (we assume).
# #
# #
# This Makefile requires the environment variable IDF_PATH to be set to the directory where this # This makefile requires the environment variable IDF_PATH to be set to the top-level esp-idf directory
# Makefile is located. # where this file is located.
# #
.PHONY: build-components menuconfig defconfig all build clean all_binaries .PHONY: build-components menuconfig defconfig all build clean all_binaries
@@ -77,9 +77,9 @@ SRCDIRS ?= main
COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp))))) COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)))))
COMPONENT_PATHS += $(abspath $(SRCDIRS)) COMPONENT_PATHS += $(abspath $(SRCDIRS))
#A component is buildable if it has a Makefile; we assume that a 'make -C $(component dir) build' results in a #A component is buildable if it has a component.mk makefile; we assume that a
#lib$(componentname).a. # 'make -C $(component dir) -f component.mk build' results in a lib$(componentname).a
COMPONENT_PATHS_BUILDABLE := $(foreach cp,$(COMPONENT_PATHS),$(if $(wildcard $(cp)/Makefile),$(cp))) COMPONENT_PATHS_BUILDABLE := $(foreach cp,$(COMPONENT_PATHS),$(if $(wildcard $(cp)/component.mk),$(cp)))
# Assemble global list of include dirs (COMPONENT_INCLUDES), and # Assemble global list of include dirs (COMPONENT_INCLUDES), and
# LDFLAGS args (COMPONENT_LDFLAGS) supplied by each component. # LDFLAGS args (COMPONENT_LDFLAGS) supplied by each component.
@@ -98,7 +98,7 @@ COMPONENT_LDFLAGS :=
# #
# Debugging this? Replace $(shell with $(error and you'll see the full command as-run. # Debugging this? Replace $(shell with $(error and you'll see the full command as-run.
define GetVariable define GetVariable
$(shell "$(MAKE)" -s --no-print-directory -C $(1) get_variable PROJECT_PATH=$(PROJECT_PATH) GET_VARIABLE=$(2) | sed -En "s/^$(2)=(.+)/\1/p" ) $(shell "$(MAKE)" -s --no-print-directory -C $(1) -f component.mk get_variable PROJECT_PATH=$(PROJECT_PATH) GET_VARIABLE=$(2) | sed -En "s/^$(2)=(.+)/\1/p" )
endef endef
COMPONENT_INCLUDES := $(abspath $(foreach comp,$(COMPONENT_PATHS_BUILDABLE),$(addprefix $(comp)/, \ COMPONENT_INCLUDES := $(abspath $(foreach comp,$(COMPONENT_PATHS_BUILDABLE),$(addprefix $(comp)/, \
@@ -193,7 +193,7 @@ define GenerateComponentPhonyTarget
# $(2) - target to generate (build, clean) # $(2) - target to generate (build, clean)
.PHONY: $(notdir $(1))-$(2) .PHONY: $(notdir $(1))-$(2)
$(notdir $(1))-$(2): | $(BUILD_DIR_BASE)/$(notdir $(1)) $(notdir $(1))-$(2): | $(BUILD_DIR_BASE)/$(notdir $(1))
@+$(MAKE) -C $(BUILD_DIR_BASE)/$(notdir $(1)) -f $(1)/Makefile COMPONENT_BUILD_DIR=$(BUILD_DIR_BASE)/$(notdir $(1)) $(2) @+$(MAKE) -C $(BUILD_DIR_BASE)/$(notdir $(1)) -f $(1)/component.mk COMPONENT_BUILD_DIR=$(BUILD_DIR_BASE)/$(notdir $(1)) $(2)
endef endef
define GenerateComponentTargets define GenerateComponentTargets
@@ -206,7 +206,7 @@ $(BUILD_DIR_BASE)/$(notdir $(1)):
# only invoked for the targets whose libraries appear in COMPONENT_LIBRARIES and hence the # only invoked for the targets whose libraries appear in COMPONENT_LIBRARIES and hence the
# APP_ELF dependencies.) # APP_ELF dependencies.)
$(BUILD_DIR_BASE)/$(notdir $(1))/lib$(notdir $(1)).a: $(notdir $(1))-build $(BUILD_DIR_BASE)/$(notdir $(1))/lib$(notdir $(1)).a: $(notdir $(1))-build
$(details) echo "$$^ responsible for $$@" # echo which build target built this file $(details) "Target '$$^' responsible for '$$@'" # echo which build target built this file
endef endef
$(foreach component,$(COMPONENT_PATHS_BUILDABLE),$(eval $(call GenerateComponentTargets,$(component)))) $(foreach component,$(COMPONENT_PATHS_BUILDABLE),$(eval $(call GenerateComponentTargets,$(component))))