make: kconfig: use fixdep to enable incremental compilation
This commit is contained in:
parent
f49eb4305c
commit
132b7328e3
@ -107,33 +107,46 @@ $(OBJC_LTO): CFLAGS+=$(LTOFLAGS)
|
|||||||
|
|
||||||
# Define dependencies for object files
|
# Define dependencies for object files
|
||||||
OBJ_DEPS += $(RIOTBUILD_CONFIG_HEADER_C)
|
OBJ_DEPS += $(RIOTBUILD_CONFIG_HEADER_C)
|
||||||
ifneq (,$(SHOULD_RUN_KCONFIG))
|
|
||||||
OBJ_DEPS += $(KCONFIG_GENERATED_AUTOCONF_HEADER_C)
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(OBJC): $(BINDIR)/$(MODULE)/%.o: %.c $(OBJ_DEPS)
|
$(OBJC): $(BINDIR)/$(MODULE)/%.o: %.c $(OBJ_DEPS) | $(if $(SHOULD_RUN_KCONFIG),$(KCONFIG_GENERATED_AUTOCONF_HEADER_C))
|
||||||
$(Q)$(CCACHE) $(CC) \
|
$(Q)$(CCACHE) $(CC) \
|
||||||
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \
|
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \
|
||||||
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
|
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
|
||||||
$(CFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<)
|
$(CFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<)
|
||||||
|
ifneq (,$(SHOULD_RUN_KCONFIG))
|
||||||
|
$(Q)$(FIXDEP) $(@:.o=.d) $@ $(KCONFIG_SYNC_DIR) > $(@:.o=.tmp)
|
||||||
|
$(Q)mv $(@:.o=.tmp) $(@:.o=.d)
|
||||||
|
endif
|
||||||
|
|
||||||
$(GENOBJC): %.o: %.c $(OBJ_DEPS)
|
$(GENOBJC): %.o: %.c $(OBJ_DEPS) | $(if $(SHOULD_RUN_KCONFIG),$(KCONFIG_GENERATED_AUTOCONF_HEADER_C))
|
||||||
$(Q) $(CCACHE) $(CC) \
|
$(Q) $(CCACHE) $(CC) \
|
||||||
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$<)\" \
|
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$<)\" \
|
||||||
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
|
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
|
||||||
$(CFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $<
|
$(CFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $<
|
||||||
|
ifneq (,$(SHOULD_RUN_KCONFIG))
|
||||||
|
$(Q)$(FIXDEP) $(@:.o=.d) $@ $(KCONFIG_SYNC_DIR) > $(@:.o=.tmp)
|
||||||
|
$(Q)mv $(@:.o=.tmp) $(@:.o=.d)
|
||||||
|
endif
|
||||||
|
|
||||||
$(OBJCXX): $(BINDIR)/$(MODULE)/%.o: %.$(SRCXXEXT) $(OBJ_DEPS)
|
$(OBJCXX): $(BINDIR)/$(MODULE)/%.o: %.$(SRCXXEXT) $(OBJ_DEPS) | $(if $(SHOULD_RUN_KCONFIG),$(KCONFIG_GENERATED_AUTOCONF_HEADER_C))
|
||||||
$(Q)$(CCACHE) $(CXX) \
|
$(Q)$(CCACHE) $(CXX) \
|
||||||
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \
|
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \
|
||||||
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
|
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
|
||||||
$(CXXFLAGS) $(CXXINCLUDES) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<)
|
$(CXXFLAGS) $(CXXINCLUDES) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<)
|
||||||
|
ifneq (,$(SHOULD_RUN_KCONFIG))
|
||||||
|
$(Q)$(FIXDEP) $(@:.o=.d) $@ $(KCONFIG_SYNC_DIR) > $(@:.o=.tmp)
|
||||||
|
$(Q)mv $(@:.o=.tmp) $(@:.o=.d)
|
||||||
|
endif
|
||||||
|
|
||||||
$(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: %.s
|
$(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: %.s
|
||||||
$(Q)$(AS) $(ASFLAGS) -o $@ $(abspath $<)
|
$(Q)$(AS) $(ASFLAGS) -o $@ $(abspath $<)
|
||||||
|
|
||||||
$(ASSMOBJ): $(BINDIR)/$(MODULE)/%.o: %.S $(OBJ_DEPS)
|
$(ASSMOBJ): $(BINDIR)/$(MODULE)/%.o: %.S $(OBJ_DEPS) | $(if $(SHOULD_RUN_KCONFIG),$(KCONFIG_GENERATED_AUTOCONF_HEADER_C))
|
||||||
$(Q)$(CCAS) $(CCASFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<)
|
$(Q)$(CCAS) $(CCASFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<)
|
||||||
|
ifneq (,$(SHOULD_RUN_KCONFIG))
|
||||||
|
$(Q)$(FIXDEP) $(@:.o=.d) $@ $(KCONFIG_SYNC_DIR) > $(@:.o=.tmp)
|
||||||
|
$(Q)mv $(@:.o=.tmp) $(@:.o=.d)
|
||||||
|
endif
|
||||||
|
|
||||||
# pull in dependency info for *existing* .o files
|
# pull in dependency info for *existing* .o files
|
||||||
# deleted header files will be silently ignored
|
# deleted header files will be silently ignored
|
||||||
|
|||||||
@ -4,11 +4,14 @@ KCONFIG ?= $(RIOTBASE)/Kconfig
|
|||||||
# Include tools targets
|
# Include tools targets
|
||||||
include $(RIOTMAKE)/tools/kconfiglib.inc.mk
|
include $(RIOTMAKE)/tools/kconfiglib.inc.mk
|
||||||
|
|
||||||
|
# Include fixdep tool
|
||||||
|
include $(RIOTMAKE)/tools/fixdep.inc.mk
|
||||||
|
|
||||||
# Generated dir will contain Kconfig generated configurations
|
# Generated dir will contain Kconfig generated configurations
|
||||||
GENERATED_DIR = $(BINDIR)/generated
|
GENERATED_DIR = $(BINDIR)/generated
|
||||||
|
|
||||||
# The sync dir will contain a tree of header files that represent Kconfig symbols
|
# The sync dir will contain a tree of header files that represent Kconfig symbols
|
||||||
KCONFIG_SYNC_DIR = $(GENERATED_DIR)/deps
|
export KCONFIG_SYNC_DIR = $(GENERATED_DIR)/deps
|
||||||
|
|
||||||
# This file will contain all generated configuration from kconfig
|
# This file will contain all generated configuration from kconfig
|
||||||
export KCONFIG_GENERATED_AUTOCONF_HEADER_C = $(GENERATED_DIR)/autoconf.h
|
export KCONFIG_GENERATED_AUTOCONF_HEADER_C = $(GENERATED_DIR)/autoconf.h
|
||||||
@ -72,13 +75,13 @@ SHOULD_RUN_KCONFIG ?= $(or $(wildcard $(APPDIR)/*.config), \
|
|||||||
$(if $(CLEAN),,$(wildcard $(KCONFIG_OUT_CONFIG))), \
|
$(if $(CLEAN),,$(wildcard $(KCONFIG_OUT_CONFIG))), \
|
||||||
$(filter menuconfig, $(MAKECMDGOALS)))
|
$(filter menuconfig, $(MAKECMDGOALS)))
|
||||||
|
|
||||||
|
# export variable to make it visible in other Makefiles
|
||||||
|
export SHOULD_RUN_KCONFIG
|
||||||
|
|
||||||
ifneq (,$(SHOULD_RUN_KCONFIG))
|
ifneq (,$(SHOULD_RUN_KCONFIG))
|
||||||
|
|
||||||
# Flag to enable the --sync-dir feature of Kconfiglib
|
|
||||||
KCONFIG_SYNC_DEPS ?=
|
|
||||||
|
|
||||||
# Add configuration header to build dependencies
|
# Add configuration header to build dependencies
|
||||||
BUILDDEPS += $(KCONFIG_GENERATED_AUTOCONF_HEADER_C)
|
BUILDDEPS += $(KCONFIG_GENERATED_AUTOCONF_HEADER_C) $(FIXDEP)
|
||||||
|
|
||||||
# Include configuration header when building
|
# Include configuration header when building
|
||||||
CFLAGS += -imacros '$(KCONFIG_GENERATED_AUTOCONF_HEADER_C)'
|
CFLAGS += -imacros '$(KCONFIG_GENERATED_AUTOCONF_HEADER_C)'
|
||||||
@ -126,12 +129,11 @@ endif # eq (clean, $(MAKECMDGOALS))
|
|||||||
# as KCONFIG_OUT_CONFIG, and is used to inject the configurations during
|
# as KCONFIG_OUT_CONFIG, and is used to inject the configurations during
|
||||||
# compilation.
|
# compilation.
|
||||||
#
|
#
|
||||||
# This will optionally generate the 'dummy' header files needed for incremental
|
# This will generate the 'dummy' header files needed for incremental builds.
|
||||||
# builds.
|
|
||||||
$(KCONFIG_GENERATED_AUTOCONF_HEADER_C): $(KCONFIG_OUT_CONFIG)
|
$(KCONFIG_GENERATED_AUTOCONF_HEADER_C): $(KCONFIG_OUT_CONFIG)
|
||||||
$(Q) $(GENCONFIG) \
|
$(Q) $(GENCONFIG) \
|
||||||
--header-path $(KCONFIG_GENERATED_AUTOCONF_HEADER_C) \
|
--header-path $(KCONFIG_GENERATED_AUTOCONF_HEADER_C) \
|
||||||
$(if $(KCONFIG_SYNC_DEPS),--sync-deps $(KCONFIG_SYNC_DIR)) \
|
--sync-deps $(KCONFIG_SYNC_DIR) \
|
||||||
--kconfig-filename $(KCONFIG) \
|
--kconfig-filename $(KCONFIG) \
|
||||||
--config-sources $(KCONFIG_OUT_CONFIG) && \
|
--config-sources $(KCONFIG_OUT_CONFIG) && \
|
||||||
touch $(KCONFIG_GENERATED_AUTOCONF_HEADER_C)
|
touch $(KCONFIG_GENERATED_AUTOCONF_HEADER_C)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user