mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-16 00:16:12 +00:00
Makefile: support make with external configurations
Customer might have specific folder where stores their own configurations for their customized scenario/board, so add TARGET_DIR parameter to support option that build hyprvisor with specified configurations. So valid usages are: (target = all | hypervisor) 1. make <target> 2. make <target> KCONFIG_FILE=xxx [TARGET_DIR=xxx] 3. make <target> BOARD=xxx SCENARIO=xxx [TARGET_DIR=xxx] 4. make <target> BOARD_FILE=xxx SCENARIO_FILE=xxx [TARGET_DIR=xxx] 5. make <target> KCONFIG_FILE=xxx BOARD_FILE=xxx SCENARIO_FILE=xxx [TARGET_DIR=xxx] If TARGET_DIR parameter is not specified in make command, hypervisor will be built with board configurations under hypervisor/arch/x86/configs/ and scenario configurations under hypervisor/scenarios/. Moreover, the configurations would be overwritten if BOARD/SCENARIO files are specified in make command. If TARGET_DIR parameter is specified in make command, hypervisor will be built with configuration under that folder if no BOARD/SCENARIO files are specified. When BOARD/SCENARIO files are available in make command, the TARGET_DIR is used to store configurations that BOARD/SCENARIO file provided, i.e. Configurations in TARGET_DIR folder will be overwritten. Tracked-On: #4517 Signed-off-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
471f7e5b28
commit
e5777adf5e
52
Makefile
52
Makefile
@ -3,14 +3,17 @@
|
||||
# global helper variables
|
||||
T := $(CURDIR)
|
||||
|
||||
# $(TARGET_DIR) must be relative path under $(T)
|
||||
TARGET_DIR ?=
|
||||
|
||||
# BOARD/SCENARIO/BOARD_FILE/SCENARIO_FILE/KCONFIG_FILE parameters sanity check:
|
||||
#
|
||||
# Only below usages are VALID: (target = all | hypervisor)
|
||||
# 1. make <target>
|
||||
# 2. make <target> KCONFIG_FILE=xxx
|
||||
# 3. make <target> BOARD=xxx SCENARIO=xxx
|
||||
# 4. make <target> BOARD_FILE=xxx SCENARIO_FILE=xxx
|
||||
# 5. make <target> KCONFIG_FILE=xxx BOARD_FILE=xxx SCENARIO_FILE=xxx
|
||||
# 2. make <target> KCONFIG_FILE=xxx [TARGET_DIR=xxx]
|
||||
# 3. make <target> BOARD=xxx SCENARIO=xxx [TARGET_DIR=xxx]
|
||||
# 4. make <target> BOARD_FILE=xxx SCENARIO_FILE=xxx [TARGET_DIR=xxx]
|
||||
# 5. make <target> KCONFIG_FILE=xxx BOARD_FILE=xxx SCENARIO_FILE=xxx [TARGET_DIR=xxx]
|
||||
#
|
||||
# Especially for case 1 that no any parameters are specified:
|
||||
# a. If hypervisor/build/.config file which generated by "make menuconfig" exist,
|
||||
@ -21,6 +24,9 @@ T := $(CURDIR)
|
||||
# the default BOARD/SCENARIO will be loaded:
|
||||
# i.e. equal: make <target> BOARD=$(BOARD) SCENARIO=$(SCENARIO)
|
||||
#
|
||||
# For case 2/3, configurations are imported from TARGET_DIR when TARGET_DIR is specified;
|
||||
# For case 4/5, configurations are from XML files and saved to TARGET_DIR if it is specified;
|
||||
#
|
||||
# The grep process did not handle corner case when '#' is manually put right after config value as comments,
|
||||
# i.e. it will be failed in the case of "CONFIG_XXX=y # some comments here "
|
||||
|
||||
@ -39,6 +45,14 @@ ifneq ($(BOARD)$(SCENARIO),)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD_FILE)$(SCENARIO_FILE),)
|
||||
ifneq ($(TARGET_DIR),)
|
||||
ifneq ($(TARGET_DIR), $(wildcard $(TARGET_DIR)))
|
||||
$(error TARGET_DIR $(TARGET_DIR) does not exist)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(BOARD_FILE)$(SCENARIO_FILE),)
|
||||
ifneq ($(BOARD_FILE), $(wildcard $(BOARD_FILE)))
|
||||
$(error BOARD_FILE: $(BOARD_FILE) does not exist)
|
||||
@ -99,6 +113,7 @@ BUILD_VERSION ?=
|
||||
BUILD_TAG ?=
|
||||
GENED_ACPI_INFO_HEADER = $(T)/hypervisor/arch/x86/configs/$(BOARD)/$(BOARD)_acpi_info.h
|
||||
HV_CFG_LOG = $(HV_OUT)/cfg.log
|
||||
DEFAULT_DEFCONFIG_DIR = $(T)/hypervisor/arch/x86/configs
|
||||
|
||||
export TOOLS_OUT BOARD SCENARIO FIRMWARE RELEASE
|
||||
|
||||
@ -146,18 +161,19 @@ hypervisor:
|
||||
&& [ "$(SCENARIO)" != "logical_partition" ] && [ "$(SCENARIO)" != "hybrid" ]; then \
|
||||
echo "SCENARIO <$(SCENARIO)> is not supported. "; exit 1; \
|
||||
fi
|
||||
@if [ "$(BOARD_FILE)" != "" ] && [ -f $(BOARD_FILE) ] && [ "$(SCENARIO_FILE)" != "" ] && [ -f $(SCENARIO_FILE) ] && [ "$(TARGET_DIR)" = "" ]; then \
|
||||
echo "No TARGET_DIR parameter is specified, the original configuration source is overwritten!";\
|
||||
fi
|
||||
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) clean;
|
||||
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) defconfig;
|
||||
@if [ -f $(KCONFIG_FILE) ]; then \
|
||||
cp $(KCONFIG_FILE) $(HV_OUT)/.config; \
|
||||
elif [ "$(CONFIG_XML_ENABLED)" != "true" ]; then \
|
||||
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) TARGET_DIR=$(abspath $(TARGET_DIR)) defconfig;
|
||||
@if [ "$(CONFIG_XML_ENABLED)" != "true" ] && [ ! -f $(KCONFIG_FILE) ]; then \
|
||||
echo "CONFIG_$(shell echo $(SCENARIO) | tr a-z A-Z)=y" >> $(HV_OUT)/.config; \
|
||||
if [ "$(SCENARIO)" != "sdc" ]; then \
|
||||
echo "CONFIG_MAX_KATA_VM_NUM=0" >> $(HV_OUT)/.config; \
|
||||
fi; \
|
||||
fi; \
|
||||
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) oldconfig;
|
||||
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE)
|
||||
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) TARGET_DIR=$(abspath $(TARGET_DIR)) oldconfig;
|
||||
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) TARGET_DIR=$(abspath $(TARGET_DIR))
|
||||
#ifeq ($(FIRMWARE),uefi)
|
||||
@if [ "$(SCENARIO)" != "logical_partition" ] && [ "$(SCENARIO)" != "hybrid" ]; then \
|
||||
echo "building hypervisor as EFI executable..."; \
|
||||
@ -167,17 +183,24 @@ hypervisor:
|
||||
@echo -e "\n\033[47;30mACRN Configuration Summary:\033[0m \nBOARD = $(BOARD)\t SCENARIO = $(SCENARIO)" > $(HV_CFG_LOG); \
|
||||
if [ -f $(KCONFIG_FILE) ]; then \
|
||||
echo -e "Hypervisor configuration is based on:\n\tKconfig file:\t$(KCONFIG_FILE);" >> $(HV_CFG_LOG); \
|
||||
else \
|
||||
echo -e "Hypervisor configuration is based on:\n\t$(BOARD) defconfig file:\t$(T)/hypervisor/arch/x86/configs/$(BOARD).config;" \
|
||||
"\n\tOthers are set by default in:\t$(T)/hypervisor/arch/x86/Kconfig;" >> $(HV_CFG_LOG); \
|
||||
fi; \
|
||||
if [ "$(TARGET_DIR)" = "" ]; then \
|
||||
if [ ! -f $(KCONFIG_FILE) ]; then \
|
||||
echo -e "Hypervisor configuration is based on:\n\t$(BOARD) " \
|
||||
"defconfig file:\t$(DEFAULT_DEFCONFIG_DIR)/$(BOARD).config;" >> $(HV_CFG_LOG); \
|
||||
fi; \
|
||||
elif [ ! -f $(KCONFIG_FILE) ]; then \
|
||||
echo -e "Hypervisor configuration is based on:\n\t$(BOARD) " \
|
||||
"defconfig file:\t$(abspath $(TARGET_DIR))/$(BOARD).config;" >> $(HV_CFG_LOG); \
|
||||
fi; \
|
||||
echo -e "\tOthers are set by default in:\t$(T)/hypervisor/arch/x86/Kconfig;" >> $(HV_CFG_LOG); \
|
||||
if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \
|
||||
echo -e "VM configuration is based on:\n\tBOARD File:\t$(BOARD_FILE);" \
|
||||
"\n\tSCENARIO File:\t$(SCENARIO_FILE);" >> $(HV_CFG_LOG); \
|
||||
else \
|
||||
echo "VM configuration is based on current code base;" >> $(HV_CFG_LOG); \
|
||||
fi; \
|
||||
if [ -f $(GENED_ACPI_INFO_HEADER) ] && [ "$(CONFIG_XML_ENABLED)" != "true" ]; then \
|
||||
if [ -f $(GENED_ACPI_INFO_HEADER) ] && [ "$(CONFIG_XML_ENABLED)" != "true" ] && [ "TARGET_DIR" = "" ]; then \
|
||||
echo -e "\033[33mWarning: The platform ACPI info is based on acrn-config generated $(GENED_ACPI_INFO_HEADER), please make sure its validity.\033[0m" >> $(HV_CFG_LOG); \
|
||||
fi
|
||||
@cat $(HV_CFG_LOG)
|
||||
@ -198,6 +221,7 @@ clean:
|
||||
$(MAKE) -C $(T)/misc OUT_DIR=$(TOOLS_OUT) clean
|
||||
$(MAKE) -C $(T)/doc BUILDDIR=$(DOC_OUT) clean
|
||||
rm -rf $(ROOT_OUT)
|
||||
rm -rf $(TARGET_DIR)
|
||||
|
||||
.PHONY: install
|
||||
install: hypervisor-install devicemodel-install tools-install
|
||||
|
@ -76,6 +76,14 @@ ifeq ($(SCENARIO),)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_DIR),)
|
||||
BOARD_CFG_DIR := arch/x86/configs/$(BOARD)
|
||||
SCENARIO_CFG_DIR := scenarios/$(SCENARIO)
|
||||
else
|
||||
BOARD_CFG_DIR := $(TARGET_DIR)/$(BOARD)
|
||||
SCENARIO_CFG_DIR := $(TARGET_DIR)/$(SCENARIO)
|
||||
endif
|
||||
|
||||
LD_IN_TOOL = scripts/genld.sh
|
||||
BASH = $(shell which bash)
|
||||
|
||||
@ -170,8 +178,8 @@ INCLUDE_PATH += include/hw
|
||||
INCLUDE_PATH += boot/include
|
||||
INCLUDE_PATH += boot/include/guest
|
||||
INCLUDE_PATH += $(HV_OBJDIR)/include
|
||||
INCLUDE_PATH += arch/x86/configs/$(BOARD)
|
||||
INCLUDE_PATH += scenarios/$(SCENARIO)
|
||||
INCLUDE_PATH += $(BOARD_CFG_DIR)
|
||||
INCLUDE_PATH += $(SCENARIO_CFG_DIR)
|
||||
|
||||
CC ?= gcc
|
||||
AS ?= as
|
||||
@ -257,10 +265,10 @@ HW_C_SRCS += common/sched_bvt.c
|
||||
endif
|
||||
HW_C_SRCS += hw/pci.c
|
||||
HW_C_SRCS += arch/x86/configs/vm_config.c
|
||||
HW_C_SRCS += arch/x86/configs/$(BOARD)/board.c
|
||||
HW_C_SRCS += scenarios/$(SCENARIO)/vm_configurations.c
|
||||
ifneq (,$(wildcard scenarios/$(SCENARIO)/pci_dev.c))
|
||||
HW_C_SRCS += scenarios/$(SCENARIO)/pci_dev.c
|
||||
HW_C_SRCS += $(BOARD_CFG_DIR)/board.c
|
||||
HW_C_SRCS += $(SCENARIO_CFG_DIR)/vm_configurations.c
|
||||
ifneq (,$(wildcard $(SCENARIO_CFG_DIR)/pci_dev.c))
|
||||
HW_C_SRCS += $(SCENARIO_CFG_DIR)/pci_dev.c
|
||||
endif
|
||||
HW_C_SRCS += boot/acpi_base.c
|
||||
HW_C_SRCS += boot/cmdline.c
|
||||
@ -378,7 +386,7 @@ VERSION := $(HV_OBJDIR)/include/version.h
|
||||
# Create platform_acpi_info.h
|
||||
TEMPLATE_ACPI_INFO_HEADER := arch/x86/configs/platform_acpi_info.h
|
||||
BOARDTEMPLATE_ACPI_INFO_HEADER := arch/x86/configs/$(BOARD)/platform_acpi_info.h
|
||||
SOURCE_ACPI_INFO_HEADER := arch/x86/configs/$(BOARD)/$(BOARD)_acpi_info.h
|
||||
SOURCE_ACPI_INFO_HEADER := $(BOARD_CFG_DIR)/$(BOARD)_acpi_info.h
|
||||
TARGET_ACPI_INFO_HEADER := $(HV_OBJDIR)/include/platform_acpi_info.h
|
||||
|
||||
$(TARGET_ACPI_INFO_HEADER): $(HV_OBJDIR)/$(HV_CONFIG)
|
||||
@ -388,7 +396,7 @@ ifeq ($(CONFIG_ENFORCE_VALIDATED_ACPI_INFO),y)
|
||||
echo "Expected ACPI info header at $(SOURCE_ACPI_INFO_HEADER)" && \
|
||||
echo "" && \
|
||||
echo "The ACPI info header for this board is not available. Please use" && \
|
||||
echo "acrn-config tool for the target board to generate a validated one." \
|
||||
echo "acrn-config tool for the target board to generate a validated one." && \
|
||||
echo "If you want to build the hypervisor with the template ACPI info," && \
|
||||
echo "unset ENFORCE_VALIDATED_ACPI_INFO using 'make menuconfig'." && \
|
||||
false; \
|
||||
@ -506,6 +514,16 @@ distclean:
|
||||
PHONY: (VERSION)
|
||||
$(VERSION):
|
||||
@echo "SCENARIO <$(SCENARIO)> for BOARD <$(BOARD)> is specified."
|
||||
@if [ ! -d $(BOARD_CFG_DIR) ]; then \
|
||||
echo "Configurations for BOARD $(BOARD) is not found."; exit 1; \
|
||||
else \
|
||||
echo "Found BOARD configurations under $(BOARD_CFG_DIR)"; \
|
||||
fi;
|
||||
@if [ ! -d $(SCENARIO_CFG_DIR) ]; then \
|
||||
echo "Configurations for SCENARIO $(SCENARIO) is not found."; exit 1; \
|
||||
else \
|
||||
echo "Found SCENARIO configurations under $(SCENARIO_CFG_DIR)"; \
|
||||
fi;
|
||||
touch $(VERSION)
|
||||
@COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\
|
||||
DIRTY=`git diff-index --name-only HEAD`;\
|
||||
|
@ -37,10 +37,18 @@ update_config:
|
||||
ifeq ($(CONFIG_XML_ENABLED),true)
|
||||
@if [ ! -f $(UPDATE_RESULT) ]; then \
|
||||
mkdir -p $(dir $(UPDATE_RESULT));\
|
||||
python3 ../misc/acrn-config/board_config/board_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(UPDATE_RESULT);\
|
||||
if [ "$(TARGET_DIR)" = "" ]; then \
|
||||
python3 ../misc/acrn-config/board_config/board_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(UPDATE_RESULT);\
|
||||
else \
|
||||
python3 ../misc/acrn-config/board_config/board_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) --out $(TARGET_DIR) > $(UPDATE_RESULT);\
|
||||
fi;\
|
||||
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);\
|
||||
if [ "$(TARGET_DIR)" = "" ]; then \
|
||||
python3 ../misc/acrn-config/scenario_config/scenario_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(UPDATE_RESULT);\
|
||||
else \
|
||||
python3 ../misc/acrn-config/scenario_config/scenario_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) --out $(TARGET_DIR) > $(UPDATE_RESULT);\
|
||||
fi;\
|
||||
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!";\
|
||||
|
@ -72,9 +72,18 @@ $(HV_OBJDIR)/$(HV_CONFIG_H): $(HV_OBJDIR)/$(HV_CONFIG)
|
||||
.PHONY: defconfig
|
||||
defconfig: $(KCONFIG_DEPS)
|
||||
@mkdir -p $(HV_OBJDIR)
|
||||
@BOARD=$(TARGET_BOARD) \
|
||||
python3 $(KCONFIG_DIR)/defconfig.py Kconfig \
|
||||
$(HV_OBJDIR)/$(HV_CONFIG)
|
||||
@if [ ! -f $(KCONFIG_FILE) ] && [ "$(CONFIG_XML_ENABLED)" != "true" ]; then \
|
||||
BOARD=$(TARGET_BOARD) python3 $(KCONFIG_DIR)/defconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG); \
|
||||
else \
|
||||
if [ "$(KCONFIG_FILE)" != "" ] && [ -f $(KCONFIG_FILE) ]; then \
|
||||
echo "Writing $(HV_OBJDIR)/$(HV_CONFIG) with $(KCONFIG_FILE)"; \
|
||||
cp $(KCONFIG_FILE) $(HV_OBJDIR)/$(HV_CONFIG); \
|
||||
elif [ "$(CONFIG_XML_ENABLED)" = "true" ] && [ "$(TARGET_DIR)" != "" ] && [ -d $(TARGET_DIR) ]; then \
|
||||
echo "Writing $(HV_OBJDIR)/$(HV_CONFIG) with $(TARGET_DIR)/$(BOARD).config"; \
|
||||
cp $(TARGET_DIR)/$(BOARD).config $(HV_OBJDIR)/$(HV_CONFIG); \
|
||||
fi; \
|
||||
python3 $(KCONFIG_DIR)/silentoldconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) RELEASE=$(RELEASE); \
|
||||
fi
|
||||
|
||||
# Use silentoldconfig to forcefully update the current .config, or generate a
|
||||
# new one if no previous .config exists. This target can be used as a
|
||||
@ -98,7 +107,7 @@ savedefconfig: $(HV_OBJDIR)/$(HV_CONFIG)
|
||||
|
||||
$(eval $(call check_dep_exec,menuconfig,MENUCONFIG_DEPS))
|
||||
export KCONFIG_CONFIG := $(HV_OBJDIR)/$(HV_CONFIG)
|
||||
menuconfig: $(MENUCONFIG_DEPS) $(HV_OBJDIR)/$(HV_CONFIG)
|
||||
menuconfig: $(MENUCONFIG_DEPS) defconfig
|
||||
@python3 $(shell which menuconfig) Kconfig
|
||||
|
||||
CFLAGS += -include $(HV_OBJDIR)/$(HV_CONFIG_H)
|
||||
|
Loading…
Reference in New Issue
Block a user