acrn-hypervisor/misc/hv_prebuild/Makefile

56 lines
1.9 KiB
Makefile
Raw Normal View History

HV_OBJDIR ?= $(CURDIR)/build
HV_CONFIG_H := $(HV_OBJDIR)/include/config.h
HV_SRC_DIR := ../../hypervisor
ifneq ($(HV_CONFIG_H), $(wildcard $(HV_CONFIG_H)))
$(error $(HV_CONFIG_H) does not exist)
endif
ifeq ($(BOARD),)
$(error please specify BOARD for the build!)
endif
ifeq ($(SCENARIO),)
$(error please specify SCENARIO for the build!)
endif
ifeq ($(TARGET_DIR),)
$(error please specify VM configs directory! )
endif
Makefile: generate C configuration files at build time This patch makes the build system of the hypervisor to cache the board and scenario XML files in the build directory and generate C configuration files from them at build time. The C configuration files that are cached in the git repo is no longer used or updated. Paths to these generated files in the prebuild Makefile is updated accordingly. The following targets are introduced or modified. * defconfig: Copy default configuration XMLs to the build directory and generate C configuration files. * oldconfig: No action. * menuconfig: Print a message to redirect users to use the config app and exit. * showconfig: Print the BOARD, SCENARIO and RELEASE configured for the current build. * update_config: No action. * (default): Build the hypervisor with defined configurations. The following variables can be set on the command line to specify the default configuration to be used. * BOARD: Either a name of the target board or a path to a customized board XML. When a board name is specified, the board XML file is expected to be available under misc/acrn-config/xmls/board-xmls. * SCENARIO: Either a name of the scenario of a path to a customized scenario XML. When a scenario name is specified, the scenario XML file is expected to be available under misc/acrn-config/xmls/config-xmls/$(BOARD). * BOARD_FILE: Path to the board XML file to be used. This is now obsoleted as BOARD provides the same functionality. * SCENARIO_FILE: Path to the scenario XML file to be used. This is now obsoleted as BOARD provides the same functionality. BOARD/SCENARIO or BOARD_FILE/SCENARIO_FILE shall be used in pair, and BOARD_FILE/SCENARIO_FILE shall point to valid files when specified. Any violation to those constraints will stop the build with error messages. When BOARD/SCENARIO and BOARD_FILE/SCENARIO_FILE are both defined on the command line, the former takes precedence as the latter are to be obsoleted. Additionally, users can define the RELEASE variable to specify a debug or release build. In case a previous build exists but is configured for a different build type, the build system will automatically update the scenario XML and rebuild the sources. This patch also includes the following tweaks: 1. Do not use `realpath` to process search paths for generated headers. `realpath` only accepts paths of existing files, while the directories for generated headers may not be created at the time the search paths are calculated. 2. Always expect `pci_dev.c` to be in place. 3. HV_CONFIG_* series now encodes absolute paths. v3: * Do not validate BOARD_FILE/SCENARIO_FILE if BOARD/SCENARIO are given. v2: * `defconfig` now also generates the C configuration files. * BOARD/SCENARIO now accept either board/scenario names or XML file paths. * Adapt to the new allocation.xml & unified.xml. * Cleanup names of internal variables in config.mk for brevity. Tracked-On: #5644 Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-01-06 11:48:18 +08:00
BOARD_INFO_DIR := $(HV_OBJDIR)/configs/boards/$(BOARD)
SCENARIO_CFG_DIR := $(HV_OBJDIR)/configs/scenarios/$(SCENARIO)
BOARD_CFG_DIR := $(SCENARIO_CFG_DIR)/$(BOARD)
PRE_BUILD_SRCS += main.c
PRE_BUILD_SRCS += static_checks.c
PRE_BUILD_SRCS += vm_cfg_checks.c
PRE_BUILD_SRCS += $(HV_SRC_DIR)/arch/x86/configs/vm_config.c
PRE_BUILD_SRCS += $(SCENARIO_CFG_DIR)/vm_configurations.c
PRE_BUILD_SRCS += $(BOARD_CFG_DIR)/pt_intx.c
ifneq (,$(wildcard $(BOARD_CFG_DIR)/pci_dev.c))
PRE_BUILD_SRCS += $(BOARD_CFG_DIR)/pci_dev.c
endif
PRE_BUILD_CFLAGS += -fno-stack-protector -fno-builtin -W -Wall
PRE_BUILD_INCLUDE := $(patsubst %, -I %, $(INCLUDE_PATH)) -include $(HV_CONFIG_H) -I .
.PHONY: default
default: $(PRE_BUILD_SRCS)
@echo "SCENARIO <$(SCENARIO)> for BOARD <$(BOARD)> is specified."
@if [ ! -d $(BOARD_INFO_DIR) ]; then \
echo "Information of BOARD $(BOARD) is not found."; exit 1; \
else \
echo "Found BOARD $(BOARD) information under $(BOARD_INFO_DIR)"; \
fi;
@if [ ! -d $(SCENARIO_CFG_DIR) ]; then \
echo "Configurations for SCENARIO $(SCENARIO) is not found."; exit 1; \
else \
echo "Found SCENARIO $(SCENARIO) configurations under $(SCENARIO_CFG_DIR)"; \
fi;
@if [ ! -d $(BOARD_CFG_DIR) ]; then \
echo "$(BOARD) configuration for SCENARIO $(SCENARIO) is not found."; exit 1; \
else \
echo "Found $(BOARD) configuration for SCENARIO $(SCENARIO) under $(BOARD_CFG_DIR)"; \
fi;
$(CC) $(PRE_BUILD_SRCS) $(PRE_BUILD_INCLUDE) $(PRE_BUILD_CFLAGS) -o $(HV_OBJDIR)/hv_prebuild_check.out