From ed8fb9477815d37dddf923ff900a5d1f932c8d25 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Sat, 9 Nov 2019 11:18:58 +0800 Subject: [PATCH] Makefile: support make from XML for new board Currently make hypervisor will depend on a $(BOARD).config file to load board defconfig which triggered by oldconfig process, this will block make from XMLs for a new board because $(BOARD).config never exist. This requires us to patch configuration for new board earlier than make oldconfig. Tracked-On: #4067 Signed-off-by: Victor Sun --- Makefile | 47 ++++++++++-------------- hypervisor/Makefile | 50 ++++++++------------------ hypervisor/scripts/kconfig/kconfig.mk | 2 +- misc/acrn-config/library/cfg_update.mk | 48 +++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 65 deletions(-) create mode 100644 misc/acrn-config/library/cfg_update.mk diff --git a/Makefile b/Makefile index 7633d6a1e..5b6a28971 100644 --- a/Makefile +++ b/Makefile @@ -22,30 +22,20 @@ TOOLS_OUT := $(ROOT_OUT)/misc/tools DOC_OUT := $(ROOT_OUT)/doc BUILD_VERSION ?= BUILD_TAG ?= -BOARD_FILE ?= -SCENARIO_FILE ?= -CONFIG_XML_ENABLED ?= false -export TOOLS_OUT +export TOOLS_OUT BOARD SCENARIO FIRMWARE RELEASE .PHONY: all hypervisor devicemodel tools doc all: hypervisor devicemodel tools -ifneq ($(BOARD_FILE)$(SCENARIO_FILE),) -override BOARD := $(shell echo `sed -n '/ is not supported. "; exit 1; \ + fi + $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) clean + $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) defconfig + @if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ + echo "CONFIG_$(shell echo $(SCENARIO_IN_XML) | tr a-z A-Z)=y" >> $(HV_OUT)/.config; \ + echo "CONFIG_ENFORCE_VALIDATED_ACPI_INFO=y" >> $(HV_OUT)/.config; \ + elif [ "$(SCENARIO)" ]; then \ echo "CONFIG_$(shell echo $(SCENARIO) | tr a-z A-Z)=y" >> $(HV_OUT)/.config; \ fi - @if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ - echo "CONFIG_ENFORCE_VALIDATED_ACPI_INFO=y" >> $(HV_OUT)/.config; \ + $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) +#ifeq ($(FIRMWARE),uefi) + @if [ "$(SCENARIO)" != "logical_partition" ] && [ "$(SCENARIO)" != "hybrid" ]; then \ + echo "building hypervisor as EFI executable..."; \ + $(MAKE) -C $(T)/misc/efi-stub HV_OBJDIR=$(HV_OUT) EFI_OBJDIR=$(HV_OUT)/$(EFI_OUT); \ fi - $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD=$(BOARD) FIRMWARE=$(FIRMWARE) RELEASE=$(RELEASE) \ - BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) oldconfig - $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD=$(BOARD) FIRMWARE=$(FIRMWARE) RELEASE=$(RELEASE) \ - BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) -ifeq ($(FIRMWARE),uefi) - echo "building hypervisor as EFI executable..." - $(MAKE) -C $(T)/misc/efi-stub HV_OBJDIR=$(HV_OUT) SCENARIO=$(SCENARIO) EFI_OBJDIR=$(HV_OUT)/$(EFI_OUT) -endif +#endif devicemodel: tools diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 5b310da12..46306fb3f 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -5,8 +5,6 @@ include ../VERSION FULL_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(EXTRA_VERSION) -SCENARIO_IN_XML := - API_MAJOR_VERSION=1 API_MINOR_VERSION=0 @@ -43,14 +41,11 @@ ARCH_ASFLAGS := ARCH_ARFLAGS := ARCH_LDFLAGS := -ifneq ($(BOARD_FILE)$(SCENARIO_FILE),) -override BOARD := $(shell echo `sed -n '/ does not match Kconfig <$(CONFIG_BOARD)>!"; exit 1; \ - fi - @if [ "$(SCENARIO_IN_XML)" != "$(SCENARIO_NAME)" ]; then \ - echo "Scenario in xml file <$(SCENARIO_IN_XML)> does not match Kconfig <$(SCENARIO_NAME)>!"; exit 1; \ - fi - @python3 ../misc/acrn-config/board_config/board_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(HV_OBJDIR)/.cfg_src_result - @cat $(HV_OBJDIR)/.cfg_src_result - @if [ "`sed -n /successfully/p $(HV_OBJDIR)/.cfg_src_result`" = "" ]; then exit 1; fi - @python3 ../misc/acrn-config/scenario_config/scenario_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(HV_OBJDIR)/.cfg_src_result - @cat $(HV_OBJDIR)/.cfg_src_result - @if [ "`sed -n /successfully/p $(HV_OBJDIR)/.cfg_src_result`" = "" ]; then exit 1; fi - @echo "Import hypervisor configurations from Config-xmls, configurations in source code are ignored!" - @sed -i 's/#define HV_CONFIG_TOOL ""/#define HV_CONFIG_TOOL " with acrn-config"/g' $(VERSION) -else - @echo "Use hypervisor configurations from source code directly." -endif - .PHONY: pre_build pre_build: $(PRE_BUILD_OBJS) @@ -467,6 +436,7 @@ $(HV_OBJDIR)/$(HV_FILE).32.out: $(HV_OBJDIR)/$(HV_FILE).out $(HV_OBJDIR)/$(HV_FILE).bin: $(HV_OBJDIR)/$(HV_FILE).out $(OBJCOPY) -O binary $< $(HV_OBJDIR)/$(HV_FILE).bin + rm -f $(UPDATE_RESULT) $(HV_OBJDIR)/$(HV_FILE).out: $(MODULES) ${BASH} ${LD_IN_TOOL} $(ARCH_LDSCRIPT_IN) $(ARCH_LDSCRIPT) ${HV_OBJDIR}/.config @@ -487,6 +457,10 @@ distclean: PHONY: (VERSION) $(VERSION): + @echo "SCENARIO <$(SCENARIO_NAME)> for BOARD <$(BOARD)> is specified." + @if [ "$(CONFIG_XML_ENABLED)" = "true" ] && [ "$(SCENARIO_NAME)" != "$(SCENARIO_IN_XML)" ]; then \ + echo "SCENARIO in XML <$(SCENARIO_IN_XML)> does not match SCENARIO in Kconfig <$(SCENARIO_NAME)> !" ; exit 1; \ + fi touch $(VERSION) @COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\ DIRTY=`git diff-index --name-only HEAD`;\ @@ -509,7 +483,11 @@ $(VERSION): echo "#define HV_BUILD_TYPE "\""$$BUILD_TYPE"\""" >> $(VERSION);\ echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\ echo "#define HV_BUILD_USER "\""$$USER"\""" >> $(VERSION);\ - echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ + if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \ + echo "#define HV_CONFIG_TOOL \" with acrn-config\"" >> $(VERSION);\ + else \ + echo "#define HV_CONFIG_TOOL \"\"" >> $(VERSION);\ + fi;\ echo "#endif" >> $(VERSION) -include $(C_OBJS:.o=.d) diff --git a/hypervisor/scripts/kconfig/kconfig.mk b/hypervisor/scripts/kconfig/kconfig.mk index 729061874..05ee4d8a3 100644 --- a/hypervisor/scripts/kconfig/kconfig.mk +++ b/hypervisor/scripts/kconfig/kconfig.mk @@ -54,7 +54,7 @@ $(eval $(call check_dep_py3lib,kconfiglib,KCONFIG_DEPS)) # # A dummy command is necessary to trigger the remaking of config.mk right after # oldconfig changes HV_CONFIG in the same execution of make. -$(HV_OBJDIR)/$(HV_CONFIG): oldconfig +$(HV_OBJDIR)/$(HV_CONFIG): update_config oldconfig @true # Note: This target must not depend on a phony target (e.g. oldconfig) because diff --git a/misc/acrn-config/library/cfg_update.mk b/misc/acrn-config/library/cfg_update.mk new file mode 100644 index 000000000..580c0098c --- /dev/null +++ b/misc/acrn-config/library/cfg_update.mk @@ -0,0 +1,48 @@ +CONFIG_XML_ENABLED ?= +UPDATE_RESULT = $(HV_OBJDIR)/.cfg_src_result + +define check_xml_enabled = +CONFIG_XML_ENABLED := $(shell if [ "$(1)" != "" ] || [ "$(2)" != "" ]; then echo false; fi) +BOARD_IN_XML := $(shell echo `if [ "$(1)" != "" ]; then sed -n '/ $(UPDATE_RESULT);\ + cat $(UPDATE_RESULT);\ + if [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then rm -f $(UPDATE_RESULT); exit 1; fi;\ + python3 ../misc/acrn-config/scenario_config/scenario_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(UPDATE_RESULT);\ + cat $(UPDATE_RESULT);\ + if [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then rm -f $(UPDATE_RESULT); exit 1; fi;\ + echo "Import hypervisor Board/VM configuration from XMLs, configurations in source code has been overwritten!";\ + elif [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then \ + echo "Problem is found on Board/VM configration patching, please rebuild."; rm -f $(UPDATE_RESULT); exit 1; \ + else \ + echo "Configurations is patched already!";\ + fi; +else ifeq ($(CONFIG_XML_ENABLED),false) + @echo "Config XML file does not exist or with unknown format." + @exit 1 +else + @echo "Using hypervisor configurations from source code directly." +endif