mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-14 19:02:02 +00:00
ACRN config tools generate source files, scripts and binaries based on
users' inputs in the configurations files, i.e., board and scenario
XMLs. Those generation activities all assume that users' inputs are
properly validated, so that all assumptions they have on such inputs are
hold.
Unfortunately, not all dependencies on validated user inputs are explicitly
stated in the Makefiles today. That will cause random error messages
(typically a Python stack trace) to be printed along with validation errors
when an invalid scenario XML is given, and such messages confuse users
about the root causes of the failure.
This patch decouples scenario validation from genconf.sh and make that step
as a separate target that depends on the board and scenario XMLs. One
timestamp file is generated only when the validation succeeds so that
targets requiring validated XMLs can refer that file in its dependency list
to make it explicit.
Dependencies of the following targets are also updated accordingly:
* $(HV_ALLOCATION_XML), which is the allocation XML including static
allocation results, now also depends on validated XMLs.
* $(HV_CONFIG_TIMESTAMP), which records when the config source files are
generated, now also depends on validated XMLs.
* $(SERIAL_CONF), which is the serial conf for the service VM, depends on
the allocation XML.
By the way, the missing dependency on HV_CONFIG_DIR for touching
HV_DIFFCONFIG_LIST is added to fix the "file not found" issue.
Tracked-On: #8259
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
91 lines
2.7 KiB
Bash
91 lines
2.7 KiB
Bash
#!/bin/sh
|
|
# Copyright (C) 2021-2022 Intel Corporation.
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
base_dir=$1
|
|
board_xml=$2
|
|
scenario_xml=$3
|
|
out=$4
|
|
unified_xml=$5
|
|
scenario=$(xmllint --xpath "string(//@scenario)" --xinclude $unified_xml)
|
|
year=$(date +'%Y')
|
|
|
|
apply_patch () {
|
|
echo "Applying patch ${1}:"
|
|
patch -p1 < ${1}
|
|
if [ $? -ne 0 ]; then
|
|
echo "Applying patch ${1} failed."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
tool_dir=${base_dir}/../misc/config_tools
|
|
diffconfig_list=${out}/.diffconfig
|
|
|
|
python3 ${tool_dir}/board_config/board_cfg_gen.py --board ${board_xml} --scenario ${scenario_xml} --out ${out} &&
|
|
python3 ${tool_dir}/acpi_gen/asl_gen.py --board ${board_xml} --scenario ${scenario_xml} --out ${out}
|
|
exitcode=$?
|
|
if [ $exitcode -ne 0 ]; then
|
|
exit $exitcode
|
|
fi
|
|
|
|
if ! which xsltproc ; then
|
|
echo "xsltproc cannot be found, please install it and make sure it is in your PATH."
|
|
exit 1
|
|
fi
|
|
|
|
transform() {
|
|
echo "Generating ${1}:"
|
|
xsltproc -o ${out}/scenarios/${scenario}/${1} --xinclude --xincludestyle ${tool_dir}/xforms/${1}.xsl ${unified_xml}
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to generate ${1} with xsltproc!"
|
|
exit 1
|
|
fi
|
|
sed -i -e "s/YEAR/$year/" ${out}/scenarios/${scenario}/${1}
|
|
echo "${1} was generated using xsltproc successfully."
|
|
}
|
|
|
|
transform_board() {
|
|
echo "Generating ${1}:"
|
|
xsltproc -o ${out}/boards/${1} --xinclude --xincludestyle ${tool_dir}/xforms/${1}.xsl ${unified_xml}
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to generate ${1} with xsltproc!"
|
|
exit 1
|
|
fi
|
|
sed -i -e "s/YEAR/$year/" ${out}/boards/${1}
|
|
echo "${1} was generated using xsltproc successfully."
|
|
}
|
|
|
|
transform vm_configurations.c
|
|
transform vm_configurations.h
|
|
transform pt_intx.c
|
|
transform ivshmem_cfg.h
|
|
transform misc_cfg.h
|
|
transform pci_dev.c
|
|
transform_board board_info.h
|
|
|
|
if which clang-format ; then
|
|
find ${out}/scenarios/${scenario} -iname *.h -o -iname *.c \
|
|
| xargs clang-format --style=file -i --fallback-style=none
|
|
else
|
|
echo "clang-format cannot be found. The generated files under ${out}/scenarios/${scenario} are not formatted."
|
|
echo "clang-format is a tool to format the C code automatically and improve the code readability."
|
|
echo "Please install clang-format and format the generated files if those need to be included and reviewed."
|
|
fi
|
|
|
|
if [ -f ${diffconfig_list} ]; then
|
|
cd ${out} &&
|
|
cat ${diffconfig_list} | while read line; do
|
|
if [ -f ${line} ]; then
|
|
apply_patch ${line}
|
|
elif [ -d ${line} ]; then
|
|
find ${line} -maxdepth 1 -name '*.patch' | while read f; do
|
|
apply_patch ${f}
|
|
done
|
|
else
|
|
echo "${line}: No such file or directory"
|
|
exit 1
|
|
fi
|
|
done
|
|
fi
|