Skip to content

Commit

Permalink
Add COMPONENT_PREREQUISITES and COMPONENT_BUILD_BASE to build framework
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Dec 8, 2020
1 parent 8754311 commit 43a8814
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Sming/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,14 @@ These values are for reference only and should not be modified.
This should be used if the Component provides any application code or targets to ensure it is
built in the correct directory (but not by this makefile).

This value changes depending on the build variant.

.. envvar:: COMPONENT_BUILD_BASE

This value does not change with build variant.

If the Component generates source code, for example, it can be placed here (in a sub-directory).

.. envvar:: COMPONENT_LIBDIR

Location to store created Component (shared) libraries
Expand Down Expand Up @@ -500,6 +508,11 @@ changed as required.
If targets should be built for each application, use :envvar:`CUSTOM_TARGETS` instead.
See :component:`spiffs` for an example.

.. envvar:: COMPONENT_PREREQUISITES

These targets will be built before anything else. If your library generates source code,
for example, then it should be done by setting this value to the appropriate targets.

.. envvar:: COMPONENT_RULE

This is a special value used to prefix any custom targets which are to be built as
Expand Down
12 changes: 10 additions & 2 deletions Sming/project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ COMPONENT_INCDIRS := include
COMPONENT_NAME := $1
COMPONENT_LIBNAME := $1
CMP_$1_BUILD_BASE := $3/$1
COMPONENT_BUILD_BASE := $$(CMP_$1_BUILD_BASE)
COMPONENT_BUILD_DIR := $$(CMP_$1_BUILD_BASE)
COMPONENT_VARS :=
COMPONENT_RELINK_VARS :=
COMPONENT_PREREQUISITES :=
COMPONENT_TARGETS :=
COMPONENT_DEPENDS :=
COMPONENT_PYTHON_REQUIREMENTS := $$(wildcard $2/requirements.txt)
Expand All @@ -184,6 +186,7 @@ LIBS += $$(EXTRA_LIBS)
CMP_$1_LDFLAGS := $$(EXTRA_LDFLAGS)
LDFLAGS += $$(CMP_$1_LDFLAGS)
endif
CMP_$1_PREREQUISITES := $$(COMPONENT_PREREQUISITES)
CMP_$1_TARGETS := $$(COMPONENT_TARGETS)
CMP_$1_BUILD_DIR := $$(COMPONENT_BUILD_DIR)
CMP_$1_LIBNAME := $$(COMPONENT_LIBNAME)
Expand Down Expand Up @@ -266,7 +269,7 @@ $(foreach c,$(COMPONENTS),$(eval $(call ResolveDependencies,$c)))
# $1 => Component name
define CheckComponentMatches
ifneq ($1,Sming)
COMPONENT_MATCHES := $(filter %/$1,$(ALL_COMPONENT_DIRS))
COMPONENT_MATCHES := $(sort $(filter %/$1,$(ALL_COMPONENT_DIRS)))
ifeq ($$(words $$(COMPONENT_MATCHES)),0)
$$(warning No matches found for Component '$1')
else ifneq ($$(words $$(COMPONENT_MATCHES)),1)
Expand Down Expand Up @@ -362,6 +365,7 @@ $1-build: $(addsuffix -build,$(filter $(CMP_$1_DEPENDS),$(BUILDABLE_COMPONENTS))
+$(Q) $(MAKE) -r -R --no-print-directory -C $(CMP_$1_BUILD_DIR) -f $(SMING_HOME)/component-wrapper.mk \
COMPONENT_NAME=$1 \
COMPONENT_PATH=$(CMP_$1_PATH) \
COMPONENT_BUILD_BASE=$(CMP_$1_BUILD_BASE) \
COMPONENT_LIBDIR=$(CMP_$1_LIBDIR) \
COMPONENT_LIBNAME=$(CMP_$1_LIBNAME) \
COMPONENT_LIBHASH=$(CMP_$1_LIBHASH) \
Expand Down Expand Up @@ -432,9 +436,12 @@ checkdirs: | $(BUILD_BASE) $(FW_BASE) $(TOOLS_BASE) $(APP_LIBDIR) $(USER_LIBDIR)
$(BUILD_BASE) $(FW_BASE) $(TOOLS_BASE) $(APP_LIBDIR) $(USER_LIBDIR):
$(Q) mkdir -p $@

# Targets to be built before anything else (e.g. source code generators)
PREREQUISITES := $(foreach c,$(COMPONENTS),$(CMP_$c_PREREQUISITES))

# Build all Component (user) libraries
.PHONY: components
components: $(ALL_COMPONENT_TARGETS) $(CUSTOM_TARGETS)
components: $(PREREQUISITES) $(ALL_COMPONENT_TARGETS) $(CUSTOM_TARGETS)

##@Cleaning

Expand Down Expand Up @@ -523,6 +530,7 @@ list-config: ##Print the contents of build variables
$(info ** Sming build configuration **)
$(info )
$(if $(V),$(call PrintVariable,MAKEFILE_LIST))
$(call PrintVariableSorted,PREREQUISITES)
$(call PrintVariableSorted,CUSTOM_TARGETS)
$(call PrintVariableSorted,LIBS)
$(call PrintVariableSorted,ARDUINO_LIBRARIES)
Expand Down

0 comments on commit 43a8814

Please sign in to comment.