55# stop on most errors
66set -e
77
8- SCRIPT_DIR=$( cd " $( dirname " $0 " ) " && pwd)
9- SOF_REPO=$( dirname " $SCRIPT_DIR " )
10- TESTBENCH_DIR=" $SOF_REPO " /tools/testbench
8+ # This script can be executed from the sof firmware toplevel or workspace directory
9+ # First check for the worksapce environment variable
10+ if [ -z " $SOF_WORKSPACE " ]; then
11+ # Environment variable is empty or unset so use default
12+ BASE_DIR=" $HOME /work/sof"
13+ else
14+ # Environment variable exists and has a value
15+ BASE_DIR=" $SOF_WORKSPACE "
16+ fi
17+ cd " $BASE_DIR "
18+
19+ # check we are in the workspace directory
20+ if [ ! -d " sof" ]; then
21+ echo " Error: can't find SOF firmware directory. Please check your installation."
22+ exit 1
23+ fi
24+
25+ TESTBENCH_DIR=$BASE_DIR /sof/tools/testbench
1126
1227# Defaults
1328BUILD_BACKEND=' make'
1429BUILD_TYPE=native
15- BUILD_DIR_NAME=build_testbench
30+ BUILD_DIR_NAME=$BASE_DIR / build_testbench
1631BUILD_TARGET=install
1732: " ${SOF_AFL:= $HOME / sof/ work/ AFL/ afl-gcc} "
33+ SCRIPT_DIR=$BASE_DIR /sof/scripts
1834
1935print_usage ()
2036{
@@ -59,7 +75,7 @@ setup_xtensa_tools_build()
5975{
6076 BUILD_TYPE=xt
6177 BUILD_TARGET=
62- BUILD_DIR_NAME=build_xt_testbench
78+ BUILD_DIR_NAME=$BASE_DIR / build_xt_testbench
6379
6480 # check needed environment variables
6581 test -n " ${XTENSA_TOOLS_ROOT} " || die " XTENSA_TOOLS_ROOT need to be set.\n"
@@ -90,7 +106,7 @@ setup_xtensa_tools_build()
90106
91107export_xtensa_setup ()
92108{
93- export_dir=$TESTBENCH_DIR / $ BUILD_DIR_NAME
109+ export_dir=$BUILD_DIR_NAME
94110 export_script=$export_dir /xtrun_env.sh
95111 xtbench=$export_dir /sof-testbench4
96112 xtbench_run=" XTENSA_CORE=$XTENSA_CORE \$ XTENSA_TOOLS_ROOT/$install_bin /xt-run $xtbench "
@@ -114,14 +130,14 @@ Success!
114130
115131For temporary, interactive Kconfiguration use:
116132
117- $BUILD_BACKEND -C $TESTBENCH_DIR / $ BUILD_DIR_NAME /sof_ep/build/ menuconfig
133+ $BUILD_BACKEND -C $BUILD_DIR_NAME /sof_ep/build/ menuconfig
118134
119135Permanent configuration is "src/arch/host/configs/library_defconfig".
120136
121137For instant, incremental build:
122138
123139 $src_env_msg
124- $BUILD_BACKEND -C $TESTBENCH_DIR / $ BUILD_DIR_NAME / -j$( nproc)
140+ $BUILD_BACKEND -C $BUILD_DIR_NAME / -j$( nproc)
125141
126142EOF0
127143
0 commit comments