通过读makefile知道了,components路径如下所示。
# Component directories. These directories are searched for components (either the directory is a component,
# or the directory contains subdirectories which are components.)
# The project Makefile can override these component dirs, or add extras via EXTRA_COMPONENT_DIRS
ifndef COMPONENT_DIRS
EXTRA_COMPONENT_DIRS ?=
COMPONENT_DIRS := $(PROJECT_PATH)/components $(EXTRA_COMPONENT_DIRS) $(BL60X_SDK_PATH)/components $(BL60X_SDK_PATH)/customer_components $(PROJECT_PATH)/$(PROJECT_NAME) $(PROJECT_COMPONENT)
endif
export COMPONENT_DIRS
- 工程目录下和SDK目录下的
components
文件夹
- SDK目录下的
customer_components
文件夹
PROJECT_COMPONENT
和EXTRA_COMPONENT_DIRS
定义的目录
PROJECT_PATH/PROJECT_NAME
目录
下面这部分代码没看很明白,不过大概意思知道了。这部分代码就是添加对应的components的makefile的规则。
# The project Makefile can define a list of components, but if it does not do this we just take all available components
# in the component dirs. A component is COMPONENT_DIRS directory, or immediate subdirectory,
# which contains a bouffalo.mk file.
#
# Use the "make list-components" target to debug this step.
#ifndef COMPONENTS
# Find all component names. The component names are the same as the
# directories they're in, so /bla/components/mycomponent/bouffalo.mk -> mycomponent.
# using by https://stackoverflow.com/questions/3774568/makefile-issue-smart-way-to-scan-directory-tree-for-c-files
ifeq ("$(wildcard ${BL60X_SDK_PATH}/components.mk)","")
rwildcard = $(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
COMPONENTS_RAL_PATH := $(dir $(foreach cd,$(COMPONENT_DIRS), \
$(call rwildcard,$(cd)/,bouffalo.mk) \
))
COMPONENTS := $(sort $(foreach comp,$(COMPONENTS_RAL_PATH),$(lastword $(subst /, ,$(comp)))))
COMPONENTS_REAL_PATH := $(patsubst %/,%,$(COMPONENTS_RAL_PATH))
else
COMPONENTS := $(notdir $(PROJECT_PATH))
COMPONENTS_REAL_PATH := $(PROJECT_PATH)/$(notdir $(PROJECT_PATH))
include $(BL60X_SDK_PATH)/components.mk
$(info use existing components.mk file)
endif