
This patch significantly reduces time needed to prepare config file. Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
74 lines
1.7 KiB
Bash
Executable File
74 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright(c) 2012-2019 Intel Corporation
|
|
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
|
#
|
|
|
|
check_util() {
|
|
which $1 2>&1 > /dev/null || { echo >&2 "Error: missing '$1' utility"; exit 1; }
|
|
}
|
|
|
|
check_util dirname
|
|
check_util realpath
|
|
check_util basename
|
|
check_util awk
|
|
|
|
SCRIPTPATH=`dirname $0`
|
|
SCRIPTPATH=`realpath $SCRIPTPATH`
|
|
|
|
CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf | sort`
|
|
FILES_COUNT=`echo $CONFIG_FILES | wc -w`
|
|
|
|
CONFIG_FILE="config.out"
|
|
|
|
generate_config() {
|
|
rm -f ${CONFIG_FILE}
|
|
touch ${CONFIG_FILE}
|
|
declare -a pid_list
|
|
progress=0
|
|
|
|
# Compile each test module in backgorund
|
|
echo "Preparing configuration"
|
|
for file in $CONFIG_FILES; do
|
|
progress=$((progress+1))
|
|
# $1 - Action to be performed
|
|
# $2 - File with stored configuration
|
|
# $3 - Name of called script (since script is running as subprocess
|
|
# it has to be passed explicitly
|
|
source $file "check" "${SCRIPTPATH}/${CONFIG_FILE}" "$file" &
|
|
pid_list+=($!)
|
|
done
|
|
|
|
# Wait for all compilation processes to finish
|
|
for i in "${pid_list[@]}"; do
|
|
wait $i &> /dev/null
|
|
done
|
|
|
|
grep "X" ${SCRIPTPATH}/${CONFIG_FILE} &> /dev/null
|
|
if [ $? -eq 0 ] ; then
|
|
echo "ERROR! Following steps failed while preparing config:"
|
|
grep "X" ${SCRIPTPATH}/${CONFIG_FILE} | cut -f1 -d ' '
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
generate_header() {
|
|
rm -f $SCRIPTPATH/modules/generated_defines.h
|
|
progress=0
|
|
for file in $CONFIG_FILES; do
|
|
progress=$((progress+1))
|
|
echo -ne "Configuring OpenCAS: $progress/$FILES_COUNT\033[0K\r"
|
|
CONF=$(cat ${CONFIG_FILE} | awk -v file=$(basename $file) '{ if ($1 == file) print $2 }')
|
|
/bin/bash $file "apply" "$CONF" "$file"
|
|
done
|
|
echo ""
|
|
}
|
|
|
|
if [ -z "$1" ]; then
|
|
generate_config
|
|
else
|
|
CONFIG_FILE="$1"
|
|
fi
|
|
|
|
generate_header
|