Commit 68e96c49 authored by norvell's avatar norvell
Browse files

Fixes to scripts/prepare_instrumentation.sh

parent e0a9007c
Loading
Loading
Loading
Loading
Loading
+33 −7
Original line number Diff line number Diff line
@@ -140,11 +140,27 @@ if [ "$PROJECT" = "FLOAT" ]; then
    # Append LC3plus defines to options.h
    echo "
    /* LC3plus switches */
    #define ENABLE_HR_MODE
    //#define DYNMEM_COUNT
    #define CR10_A_ATTENUATION_CURVE_SELECTOR
    #define SUBSET_NB
    #define SUBSET_WB
    #define SUBSET_SSWB
    #define SUBSET_SWB
    #define SUBSET_FB
    #define SUBSET_UB
    #ifndef OPTIONS_H_LC3_DEFINES
    #define OPTIONS_H_LC3_DEFINES
    $lc3plus_defines_filtered
    #endif /* OPTIONS_H_LC3_DEFINES */
    " >>$targetdir/lib_com/options.h
    
    # Clean out memory tool which breaks wmc_tool instrumentation
    perl -i -0777 -pe 's/Dyn_Mem_Deluxe_In\s*\((.*?)\)\s*;/$1/g' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/Dyn_Mem_Deluxe_Out\s*\([^)]*\)\s*;//sg' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/Dyn_Mem_In\s*\((.*?)\)\s*;/$1/g' $targetdir/lib_lc3plus/*.c
    perl -i -0777 -pe 's/Dyn_Mem_Out\s*\([^)]*\)\s*;//sg' $targetdir/lib_lc3plus/*.c
    
fi

# get switches from options.h and append it to $ifdef_list
@@ -160,6 +176,12 @@ if [ $? -ne 0 ]; then
    exit -1
fi

# Floating point code has lib_lc3plus/fft folder while BASOP code does not
fftdir=""
if [ -d $targetdir/lib_lc3plus/fft ]; then
    fftdir="$targetdir/lib_lc3plus/fft/*.c"
fi

# strip switches, to remove the macros (turn on extended globing to allow !(pattern*) matching)
shopt -s extglob
if coan_exists; then
@@ -171,7 +193,9 @@ if coan_exists; then
    if [ "$PROJECT" = "FLOAT" ]; 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/lib_lc3plus/!(wmc_auto*).[hc]
        if [ -n "$fftdir" ];then
            coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/fft/!(wmc_auto*).[hc]
        fi
    else
        # same as first call from if, but without "isar" and "debug" to avoid coan warning
        coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_{com,dec,enc,rend,util}/!(wmc_auto*).[hc]
@@ -185,18 +209,20 @@ shopt -u extglob
find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(unsigned long\)\1\)/" \{\} \;

# 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
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c"  >> output.txt 2>&1
"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >> output.txt 2>&1
# ISAR post-renderer and lc3plus sources only need to be instrumented in float code
if [ "$PROJECT" = "FLOAT" ]; then
    for bak_file in $targetdir/lib_rend/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "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/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$fftdir" >> output.txt 2>&1
    for bak_file in $targetdir/lib_lc3plus/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    if [ -n "$fftdir" ];then
        for bak_file in $targetdir/lib_lc3plus/fft/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "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
    fi
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$fftdir" >> output.txt 2>&1
else
    for bak_file in $targetdir/lib_rend/*.bak; do mv "$bak_file" "${bak_file%.*}"; done      # restore fresh .c files to avoid time-consuming des-instrumentation of files by the WMC tool
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" >> /dev/null
    "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" >> output.txt 2>&1
fi

# automatically enable #define WMOPS in options.h