Application: fix multiple main target mismatch during incremental compile

MAINSRC will fail to match with PROGNAME if one of main source is changed in incremental compilation
this PR will correct this issue.

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-02-28 14:45:50 +08:00 committed by Alin Jerpelea
parent b13f70ca59
commit 7ad9525c35

View File

@ -203,16 +203,16 @@ else
MAINNAME := $(addsuffix _main,$(PROGNAME))
$(MAINCXXOBJ): %$(CXXEXT)$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))})
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))})
$(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME)))
$(eval MAIN=$(word $(call GETINDEX,$<,$(MAINCXXSRCS)),$(MAINNAME)))
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(MAIN)})
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(MAIN)})
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
$(MAINCOBJ): %.c$(SUFFIX)$(OBJEXT): %.c
$(eval $<_CFLAGS += ${DEFINE_PREFIX}main=$(firstword $(MAINNAME)))
$(eval $<_CELFFLAGS += ${DEFINE_PREFIX}main=$(firstword $(MAINNAME)))
$(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME)))
$(eval MAIN=$(word $(call GETINDEX,$<,$(MAINCSRCS)),$(MAINNAME)))
$(eval $<_CFLAGS += ${DEFINE_PREFIX}main=$(MAIN))
$(eval $<_CELFFLAGS += ${DEFINE_PREFIX}main=$(MAIN))
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))