From 593414e9c2a1271cde456d4c48a8fb2b9b2b9b3a Mon Sep 17 00:00:00 2001 From: Conghui Date: Sat, 23 Apr 2022 04:46:28 +0800 Subject: [PATCH] config-tools: support absolute path 1. Support absolute path for scenario file. 2. Use the scenario xml file name as scenario name, but if it is 'scenario.xml', use the upper level directory name. e.g. SCENARIO=/shared/scenario.xml Then scenario name would be 'shared'. 3. Change 'realpath' to 'abspath' as we should keep the original path for scenario file even it is a link file. This will make sure the scenario name is always consistent with file set in 'SCENARIO='. Tracked-On: #7345 Signed-off-by: Conghui Reviewed-by: Junjie Mao --- Makefile | 4 ++-- hypervisor/scripts/makefile/config.mk | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2a961d9b2..94e94ac37 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ ifneq ($(BOARD_FILE)$(SCENARIO_FILE),) endif override BOARD := $(realpath $(BOARD_FILE)) - override SCENARIO := $(realpath $(SCENARIO_FILE)) + override SCENARIO := $(abspath $(SCENARIO_FILE)) else # BOARD/SCENARIO pointing to XML files must be converted to absolute paths before being passed to hypervisor/Makefile # because paths relative to acrn-hypervisor/ are typically invalid when relative to acrn-hypervisor/Makefile @@ -54,7 +54,7 @@ else override BOARD := $(realpath $(BOARD)) endif ifneq ($(realpath $(SCENARIO)),) - override SCENARIO := $(realpath $(SCENARIO)) + override SCENARIO := $(abspath $(SCENARIO)) endif endif diff --git a/hypervisor/scripts/makefile/config.mk b/hypervisor/scripts/makefile/config.mk index d31e8a426..8caed0627 100644 --- a/hypervisor/scripts/makefile/config.mk +++ b/hypervisor/scripts/makefile/config.mk @@ -54,7 +54,12 @@ define determine_config = ifneq ($($(1)),) ifneq ($(realpath $($(1))),) override $(1)_FILE := $($(1)) - override $(1) := $$(shell xmllint --xpath 'string(/acrn-config/@$(shell echo $(1) | tr A-Z a-z))' $$($(1)_FILE)) + ifneq (SCENARIO, $(1)) + override $(1) := $$(shell xmllint --xpath 'string(/acrn-config/@$(shell echo $(1) | tr A-Z a-z))' $$($(1)_FILE)) + else + scenario_name := $(subst .xml,,$(notdir $($(1)))) + override $(1) := $$(if $$(subst scenario,,$$(scenario_name)),$$(scenario_name),$(notdir $(abspath $(dir $($(1)))))) + endif else override $(1)_FILE := $(HV_PREDEFINED_DATA_DIR)/$$(BOARD)/$$($(1)).xml ifeq ($$(realpath $$($(1)_FILE)),) @@ -201,11 +206,11 @@ $(HV_BOARD_XML): $(HV_SCENARIO_XML): @if [ ! -f $(HV_SCENARIO_XML) ]; then \ if [ -f $(SCENARIO_FILE) ]; then \ - echo "Scenario XML is being fetched from $(realpath $(SCENARIO_FILE))"; \ + echo "Scenario XML is being fetched from $(abspath $(SCENARIO_FILE))"; \ mkdir -p $(dir $(HV_SCENARIO_XML)); \ python3 $(HV_CONFIG_TOOL_DIR)/scenario_config/default_populator.py $(SCENARIO_FILE) $(HV_SCENARIO_XML); \ if [ -z $$(xmllint --xpath 'string(//@scenario)' $(HV_SCENARIO_XML)) ]; then \ - sed "s#