On compiling a mixture of HEXAGON (qurt) and non-HEXAGON

While chatting with David I made the remark that I was using something that might (ever) be a reason why things would work for me, but not for others. In case that would be relevant I wanted to post it here, for other devs to take notice of :).

HEXAGON requires to set a PATH in your environment. But in that path are executables that also exist for other targets. So, I think that one should not set that PATH when not compiling for HEXAGON.

Therefore I turned my ‘make’ into a bash function:


function make
{
VARS=“j=8”
while true
do
case $1 in
j=)
VARS="$1"
;;
=)
VARS+=" $1"
;;
)
break
;;
esac
shift
done
case $1 in
excelsior|
sdflight
|eagle|eagle_|qurt_)
export HEXAGON_SDK_ROOT=/usr/src/px4/snapdragon/Qualcomm/Hexagon_SDK/3.0
export HEXAGON_TOOLS_ROOT=/usr/src/px4/snapdragon/Qualcomm/HEXAGON_Tools/7.2.12/Tools
export HEXAGON_ARM_SYSROOT=/usr/src/px4/snapdragon/Qualcomm/qrlinux_v3.1.1_sysroot
export FC_ADDON=/usr/src/px4/snapdragon/cross_toolchain/downloads/sdk_add_on
pre_path “$HEXAGON_SDK_ROOT/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf_linux/bin”
trap : HUP INT QUIT PIPE TERM
/usr/bin/make $VARS $*
retval=$?
del_path “$HEXAGON_SDK_ROOT/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf_linux/bin”
unset HEXAGON_SDK_ROOT
unset HEXAGON_TOOLS_ROOT
unset HEXAGON_ARM_SYSROOT
unset FC_ADDON
trap - HUP INT QUIT PIPE TERM
;;
)
unset HEXAGON_SDK_ROOT
unset HEXAGON_TOOLS_ROOT
unset HEXAGON_ARM_SYSROOT
unset FC_ADDON
/usr/bin/make $VARS $

retval=$?
;;
esac
return $retval
}

where pre_path and del_path are something that I have in my environment by default:


no_path ()
{
eval “case :$${2-PATH}: in :$1:) return 1;; *) return 0;; esac”
}

pre_path ()
{
[ -d ${1:-.} ] && no_path $* && eval ${2:-PATH}="$1:$${2:-PATH}"
}

del_path ()
{
no_path $* || eval ${2:-PATH}=eval echo :'$'${2:-PATH}: | sed -e "s;:$1:;:;g" -e "s;^:;;" -e "s;:\$;;"
}


Edited to reflect what I’m currently using…