Commit 80eaebd7 authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'basop-ci/prepare-instrumentation-basop' into 'main'

[BASOP-CI]add arguments to prepare_instrumentation for BASOP measurements

See merge request !1718
parents 96ab8134 0beb1e08
Loading
Loading
Loading
Loading
Loading
+74 −47
Original line number Diff line number Diff line
@@ -33,31 +33,48 @@
function usage {
    echo
    echo "Usage:"
    echo "      prepare_instrumentation.sh [MODE]"
    echo "      $(basename $0) [OPTIONS]"
    echo 
    echo "      MODE - full (default) or mem_only"
    echo "      -m MODE    one of [FULL|MEM_ONLY]"
    echo "      -p PROJECT one of [FLOAT|BASOP]"
    exit
}

wmc_opt=""
if [ $# -eq 1 ]; then
    mode=$1
    if [ "$mode" = "full" ]; then
        wmc_opt=""
    elif [ "$mode" = "mem_only" ]; then
        wmc_opt="-s"
    else
        echo "Invalid input for MODE"

# default values
MODE="FULL"
PROJECT="FLOAT"

while getopts "m:p:h" OPTIONS; do
    case ${OPTIONS} in
    m)
        MODE=${OPTARG^^}
        if [ "$MODE" != "FULL" && "$MODE" != "MEM_ONLY" ]; then
            usage
        exit 1
        fi
elif [ $# -ge 2 ]; then
        ;;
    p)
        PROJECT=${OPTARG^^}
        if [ "$PROJECT" != "FLOAT" && "$PROJECT" != "BASOP" ]; then
            usage
    exit 1
        fi
        ;;
    h | *)
        usage
        ;;
    esac
done
shift $((OPTIND-1))


wmc_opt=""
if [ "$MODE" = "MEM_ONLY" ]; then
    wmc_opt="-s"
fi


system=`uname -s`
if [[ ($system == "Linux") && (`uname -a` =~ (microsoft|Microsoft|wsl|WSL) ) ]]; then
if [[ ($system = "Linux") && (`uname -a` =~ (microsoft|Microsoft|wsl|WSL) ) ]]; then
    system="Linux"
fi

@@ -98,6 +115,8 @@ cp -R ../Workspace_msvc $targetdir
rm -f $ifdef_list
touch $ifdef_list

# LC3plus-related stuff -> only in float code
if [ "$PROJECT" = "FLOAT" ]; then
    # Add LC3plus feature defines to options.h so that they are stripped correctly
    # Generate list of active defines in LC3plus defines.h
    lc3plus_defines=$(
@@ -124,6 +143,7 @@ echo "
    $lc3plus_defines_filtered
    #endif /* OPTIONS_H_LC3_DEFINES */
    " >>$targetdir/lib_com/options.h
fi

# get switches from options.h and append it to $ifdef_list
parse_options_opt=""
@@ -147,8 +167,10 @@ if coan_exists; then

    coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_{com,dec,enc,isar,rend,util,debug}/!(wmc_auto*).[hc]
    coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/apps/*.[hc]
    if [ "$PROJECT" = "FLOAT" ]; then
        coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/!(wmc_auto*).[hc]
        coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/fft/!(wmc_auto*).[hc]
    fi
else
    ./strip_defines_cppp.sh $targetdir $ifdef_list
fi
@@ -160,8 +182,13 @@ find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(u
# run wmc_tool
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c"  >> /dev/null
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >> /dev/null
# ISAR post-renderer and lc3plus sources only need to be instrumented in float code
if [ "$PROJECT" = "FLOAT" ]; then
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null
else
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" >> /dev/null
fi

# automatically enable #define WMOPS in options.h
sed -i.bak -e "s/\/\*[[:space:]]*\(#define[[:space:]]*WMOPS\)[[:space:]]*\*\//\1/g" $targetdir/lib_com/options.h