multiple firmware configs at the same time

This commit is contained in:
2021-08-09 14:43:33 +02:00
parent 673f68d2c1
commit 8f47ce7b63
9 changed files with 1798 additions and 80 deletions

89
switchconf.sh Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/bash
[[ $_ != $0 ]] && HAS_BEEN_SOURCED=1
VALID_CONFIGS=(feedc0de comred)
function print_usage
{
echo "usage: ./switchconf.sh ${VALID_CONFIGS[@]}"
}
if [[ ! -z "${HAS_BEEN_SOURCED}" ]]
then
echo "switch.sh cannot be sourced, run in a subshell"
print_usage
return
fi
if [[ -z "$1" ]]
then
echo "ERROR: no buildconfig specified"
print_usage
exit 1
fi
if [[ ! " ${VALID_CONFIGS[@]} " =~ " $1 " ]]
then
case "$1" in
"--help")
print_usage
exit
;;
"--list")
for i in ${VALID_CONFIGS[@]}
do
echo "$i"
done
exit
;;
*)
echo "ERROR: invalid buildconfig \"$1\""
print_usage
exit 1
;;
esac
fi
if [[ -L "build" ]]
then
rm -v "build"
else
if [[ -e "build" ]]
then
echo build is not a symlink
mv "build" "build.bak" -v
fi
fi
mkdir -pv "build_$1"
if [[ -L "sdkconfig" ]]
then
rm -v "sdkconfig"
else
if [[ -e "sdkconfig" ]]
then
echo sdkconfig is not a symlink
mv "sdkconfig" "sdkconfig.bak" -v
fi
fi
if [[ -L "config.cmake" ]]
then
rm -v "config.cmake"
else
if [[ -e "config.cmake" ]]
then
echo config.cmake is not a symlink
mv "config.cmake" "config.cmake.bak" -v
fi
fi
ln -vs "build_$1" "build"
ln -vs "sdkconfig_$1" "sdkconfig"
ln -vs "config_$1.cmake" "config.cmake"
echo all ok