Enable confiugure script to generate header in parallel.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2019-07-15 06:13:23 -04:00
parent 9473cf9795
commit a32b079a8a
2 changed files with 30 additions and 18 deletions

46
configure vendored
View File

@ -19,7 +19,7 @@ SCRIPTPATH=`realpath $SCRIPTPATH`
CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf | sort` CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf | sort`
FILES_COUNT=`echo $CONFIG_FILES | wc -w` FILES_COUNT=`echo $CONFIG_FILES | wc -w`
CONFIG_FILE="config.out" CONFIG_FILE=$SCRIPTPATH/"config.out"
generate_config() { generate_config() {
rm -f ${CONFIG_FILE} rm -f ${CONFIG_FILE}
@ -27,47 +27,59 @@ generate_config() {
declare -a pid_list declare -a pid_list
progress=0 progress=0
# Compile each test module in backgorund # Compile each test module in background
echo "Preparing configuration" echo "Preparing configuration"
for file in $CONFIG_FILES; do for file in $CONFIG_FILES; do
progress=$((progress+1)) progress=$((progress+1))
# $1 - Action to be performed # $1 - Action to be performed
# $2 - File with stored configuration # $2 - File with stored configuration
# $3 - Name of called script (since script is running as subprocess # $3 - Name of called script (since script is running as subprocess
# it has to be passed explicitly # it has to be passed explicitly)
source $file "check" "${SCRIPTPATH}/${CONFIG_FILE}" "$file" & source $file "check" "$CONFIG_FILE" "$file" &
pid_list+=($!) pid_list+=($!)
done done
# Wait for all compilation processes to finish # Wait for all compilation processes to finish
for i in "${pid_list[@]}"; do wait
wait $i &> /dev/null
done
grep "X" ${SCRIPTPATH}/${CONFIG_FILE} &> /dev/null grep "X" ${CONFIG_FILE} &> /dev/null
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
echo "ERROR! Following steps failed while preparing config:" echo "ERROR! Following steps failed while preparing config:"
grep "X" ${SCRIPTPATH}/${CONFIG_FILE} | cut -f1 -d ' ' grep "X" ${CONFIG_FILE} | cut -f1 -d ' '
exit 1 exit 1
fi fi
} }
generate_header() { generate_header() {
rm -f $SCRIPTPATH/modules/generated_defines.h rm -f $SCRIPTPATH/modules/generated_defines.h
progress=0 # Configs starting with '1_' have to be put as first in header
for file in $CONFIG_FILES; do FIRST=$(echo $CONFIG_FILES | tr ' ' '\n' | grep '1_')
progress=$((progress+1)) SECOND=$(echo $CONFIG_FILES | tr ' ' '\n' | grep '2_')
echo -ne "Configuring OpenCAS: $progress/$FILES_COUNT\033[0K\r"
CONF=$(cat ${CONFIG_FILE} | awk -v file=$(basename $file) '{ if ($1 == file) print $2 }') echo "Configuring OpenCAS"
/bin/bash $file "apply" "$CONF" "$file" for file in $FIRST; do
CONF=$(cat ${CONFIG_FILE} | grep $(basename $file) | cut -d' ' -f2)
source $file "apply" "$CONF" "$file" &
done done
echo ""
wait
for file in $SECOND; do
CONF=$(cat ${CONFIG_FILE} | grep $(basename $file) | cut -d' ' -f2)
source $file "apply" "$CONF" "$file" &
done
wait
} }
if [ -z "$1" ]; then if [ -z "$1" ]; then
generate_config generate_config
else else
CONFIG_FILE="$1" CONFIG_FILE=$(realpath $1)
if [ $? -ne 0 ] ; then
echo "Invaild path to config file!"
exit 1
fi
fi fi
generate_header generate_header

View File

@ -9,7 +9,7 @@ SCRIPTPATH=`realpath $SCRIPTPATH`
KERNEL_DIR="${KERNEL_DIR:-/lib/modules/$(uname -r)/build/}" KERNEL_DIR="${KERNEL_DIR:-/lib/modules/$(uname -r)/build/}"
KERNEL_VER="$(cd $KERNEL_DIR; make kernelversion)" KERNEL_VER="$(cd $KERNEL_DIR; make kernelversion)"
NPROC=`nproc` NPROC=`nproc`
DEFINE_FILE=$SCRIPTPATH/../modules/generated_defines.h DEFINE_FILE=$SCRIPTPATH/modules/generated_defines.h
add_define() { add_define() {