2019-11-09 11:18:58 +08:00
|
|
|
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 '/<acrn-config/p' $(1) | sed -r 's/.*board="(.*)".*/\1/g'; fi`)
|
|
|
|
SCENARIO_IN_XML := $(shell echo `if [ "$(2)" != "" ]; then sed -n '/<acrn-config/p' $(2) | sed -r 's/.*scenario="(.*)".*/\1/g'; fi`)
|
|
|
|
|
|
|
|
ifneq ($$(BOARD_IN_XML),)
|
|
|
|
ifneq ($$(SCENARIO_IN_XML),)
|
|
|
|
CONFIG_XML_ENABLED := true
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
2020-03-16 23:53:05 +08:00
|
|
|
ifeq ($(CONFIG_XML_ENABLED),)
|
2019-11-09 11:18:58 +08:00
|
|
|
$(eval $(call check_xml_enabled,$(BOARD_FILE),$(SCENARIO_FILE)))
|
|
|
|
endif
|
|
|
|
|
2020-03-16 23:53:05 +08:00
|
|
|
ifeq ($(CONFIG_XML_ENABLED),true)
|
|
|
|
override BOARD := $(BOARD_IN_XML)
|
|
|
|
override SCENARIO := $(SCENARIO_IN_XML)
|
2020-04-20 13:51:37 +08:00
|
|
|
RELEASE_IN_XML := $(shell echo `sed -n '/<RELEASE/p' $(SCENARIO_FILE) | sed -r 's/.*<RELEASE(.*)>(.*)<(.*)/\2/g'`)
|
|
|
|
ifndef RELEASE
|
|
|
|
ifeq ($(RELEASE_IN_XML),y)
|
|
|
|
override RELEASE := 1
|
|
|
|
else
|
|
|
|
override RELEASE := 0
|
|
|
|
endif
|
|
|
|
endif
|
2020-03-16 23:53:05 +08:00
|
|
|
endif
|
|
|
|
|
2019-11-09 11:18:58 +08:00
|
|
|
update_config:
|
|
|
|
ifeq ($(CONFIG_XML_ENABLED),true)
|
|
|
|
@if [ ! -f $(UPDATE_RESULT) ]; then \
|
|
|
|
mkdir -p $(dir $(UPDATE_RESULT));\
|
2021-01-23 07:24:06 +08:00
|
|
|
python3 ../misc/config_tools/board_config/board_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) --out $(TARGET_DIR) > $(UPDATE_RESULT);\
|
2019-11-09 11:18:58 +08:00
|
|
|
cat $(UPDATE_RESULT);\
|
|
|
|
if [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then rm -f $(UPDATE_RESULT); exit 1; fi;\
|
2020-03-24 10:58:52 +08:00
|
|
|
if [ "$(TARGET_DIR)" = "" ]; then \
|
2021-01-23 07:24:06 +08:00
|
|
|
python3 ../misc/config_tools/scenario_config/scenario_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(UPDATE_RESULT);\
|
2020-03-24 10:58:52 +08:00
|
|
|
else \
|
2021-01-23 07:24:06 +08:00
|
|
|
python3 ../misc/config_tools/scenario_config/scenario_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) --out $(abspath $(TARGET_DIR)) > $(UPDATE_RESULT);\
|
2020-03-24 10:58:52 +08:00
|
|
|
fi;\
|
2019-11-09 11:18:58 +08:00
|
|
|
cat $(UPDATE_RESULT);\
|
|
|
|
if [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then rm -f $(UPDATE_RESULT); exit 1; fi;\
|
2020-04-20 13:51:37 +08:00
|
|
|
echo "Import hypervisor Board/VM configuration from XMLs.";\
|
|
|
|
if [ "$(TARGET_DIR)" = "" ]; then echo "Warning: configurations in source code has been overwritten!"; fi;\
|
2019-11-09 11:18:58 +08:00
|
|
|
elif [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then \
|
2020-04-20 13:51:37 +08:00
|
|
|
echo "Problem is found on Board/VM configuration patching, please rebuild."; rm -f $(UPDATE_RESULT); exit 1; \
|
2019-11-09 11:18:58 +08:00
|
|
|
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
|