forked from Archive/PX4-Autopilot
Tools: fix style consistency in shell scripts "if [...]; then"
This commit is contained in:
parent
c21849b9b5
commit
bee1835831
|
@ -25,7 +25,7 @@ else
|
|||
if [ "$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_1" -a \
|
||||
"$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_2" -a \
|
||||
"$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_3" -a \
|
||||
"$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_4" ];
|
||||
"$ASTYLE_VER" != "$ASTYLE_VER_REQUIRED_4" ]
|
||||
then
|
||||
echo "Error: you're using ${ASTYLE_VER}"
|
||||
echo "but should be using ${ASTYLE_VER_REQUIRED_1}, ${ASTYLE_VER_REQUIRED_2}, ${ASTYLE_VER_REQUIRED_3}, or ${ASTYLE_VER_REQUIRED_4} instead"
|
||||
|
@ -36,8 +36,7 @@ fi
|
|||
CI="${CI:-false}"
|
||||
DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
|
||||
|
||||
if [[ "$@" == "--fix" ]]
|
||||
then
|
||||
if [[ "$@" == "--fix" ]]; then
|
||||
export PX4_ASTYLE_FIX=1
|
||||
fi
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ set -eu
|
|||
|
||||
PATTERN="-e ."
|
||||
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
if [ $# -gt 0 ]; then
|
||||
PATTERN="$1"
|
||||
fi
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ fi
|
|||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
git diff-index --check --cached $against --
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
function check_git_submodule {
|
||||
|
||||
# The .git exists in a submodule if init and update have been done.
|
||||
if [[ -f $1"/.git" || -d $1"/.git" ]];
|
||||
then
|
||||
if [[ -f $1"/.git" || -d $1"/.git" ]]; then
|
||||
|
||||
# CI environment always update
|
||||
if [ "$CI" == "true" ];
|
||||
then
|
||||
if [ "$CI" == "true" ]; then
|
||||
git submodule --quiet sync --recursive -- $1
|
||||
git submodule --quiet update --init --recursive -- $1 || true
|
||||
git submodule --quiet update --init --recursive -- $1
|
||||
|
@ -17,8 +15,7 @@ then
|
|||
|
||||
SUBMODULE_STATUS=$(git submodule summary "$1")
|
||||
STATUSRETVAL=$(echo $SUBMODULE_STATUS | grep -A20 -i "$1")
|
||||
if ! [[ -z "$STATUSRETVAL" ]];
|
||||
then
|
||||
if ! [[ -z "$STATUSRETVAL" ]]; then
|
||||
echo -e "\033[31mChecked $1 submodule, ACTION REQUIRED:\033[0m"
|
||||
echo ""
|
||||
echo -e "Different commits:"
|
||||
|
@ -39,11 +36,9 @@ then
|
|||
echo -e " Use \033[94mgit add $1 && git commit -m 'Updated $1'\033[0m to choose this version (careful!)"
|
||||
echo ""
|
||||
read user_cmd
|
||||
if [ "$user_cmd" == "y" ]
|
||||
then
|
||||
if [ "$user_cmd" == "y" ]; then
|
||||
echo "Continuing build with manually overridden submodule.."
|
||||
elif [ "$user_cmd" == "u" ]
|
||||
then
|
||||
elif [ "$user_cmd" == "u" ]; then
|
||||
git submodule sync --recursive -- $1
|
||||
git submodule update --init --recursive -- $1 || true
|
||||
git submodule update --init --recursive --force -- $1
|
||||
|
@ -62,8 +57,7 @@ fi
|
|||
}
|
||||
|
||||
# If called with a path then respect $GIT_SUBMODULES_ARE_EVIL but do normal processing
|
||||
if [ "$#" != "0" ];
|
||||
then
|
||||
if [ "$#" != "0" ]; then
|
||||
# called with a path then process only that path but respect $GIT_SUBMODULES_ARE_EVIL
|
||||
[ -n "$GIT_SUBMODULES_ARE_EVIL" ] && {
|
||||
# GIT_SUBMODULES_ARE_EVIL is set, meaning user doesn't want submodules updated
|
||||
|
|
|
@ -12,8 +12,7 @@ set i {{ command.instance }}
|
|||
{% endif -%}
|
||||
# get the device & baudrate
|
||||
sh $PRT_F
|
||||
if [ $SERIAL_DEV != none ]
|
||||
then
|
||||
if [ $SERIAL_DEV != none ]; then
|
||||
{% if not constrained_flash -%}
|
||||
echo "Starting {{ command.label }} on $SERIAL_DEV"
|
||||
{% endif -%}
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
|
||||
set SERIAL_DEV none
|
||||
{% for serial_device in serial_devices -%}
|
||||
if param compare "$PRT" {{ serial_device.index }}
|
||||
then
|
||||
if [ "x$PRT_{{ serial_device.tag }}_" = "x" ]
|
||||
then
|
||||
if param compare "$PRT" {{ serial_device.index }}; then
|
||||
if [ "x$PRT_{{ serial_device.tag }}_" = "x" ]; then
|
||||
set SERIAL_DEV {{ serial_device.device }}
|
||||
set BAUD_PARAM SER_{{ serial_device.tag }}_BAUD
|
||||
set PRT_{{ serial_device.tag }}_ 1
|
||||
|
|
|
@ -23,15 +23,12 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|||
# otherwise warn and point to docker?
|
||||
UBUNTU_RELEASE=`lsb_release -rs`
|
||||
|
||||
if [[ "${UBUNTU_RELEASE}" == "14.04" ]]
|
||||
then
|
||||
if [[ "${UBUNTU_RELEASE}" == "14.04" ]]; then
|
||||
echo "Ubuntu 14.04 unsupported, see docker px4io/px4-dev-base"
|
||||
exit 1
|
||||
elif [[ "${UBUNTU_RELEASE}" == "16.04" ]]
|
||||
then
|
||||
elif [[ "${UBUNTU_RELEASE}" == "16.04" ]]; then
|
||||
echo "Ubuntu 16.04"
|
||||
elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]
|
||||
then
|
||||
elif [[ "${UBUNTU_RELEASE}" == "18.04" ]]; then
|
||||
echo "Ubuntu 18.04"
|
||||
fi
|
||||
|
||||
|
|
|
@ -31,20 +31,17 @@ fi
|
|||
|
||||
if [ "$model" != none ]; then
|
||||
jmavsim_pid=`ps aux | grep java | grep "\-jar jmavsim_run.jar" | awk '{ print $2 }'`
|
||||
if [ -n "$jmavsim_pid" ]
|
||||
then
|
||||
if [ -n "$jmavsim_pid" ]; then
|
||||
kill $jmavsim_pid
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$model" == "" ] || [ "$model" == "none" ]
|
||||
then
|
||||
if [ "$model" == "" ] || [ "$model" == "none" ]; then
|
||||
echo "empty model, setting iris as default"
|
||||
model="iris"
|
||||
fi
|
||||
|
||||
if [ "$#" -lt 6 ]
|
||||
then
|
||||
if [ "$#" -lt 6 ]; then
|
||||
echo usage: sitl_run.sh sitl_bin debugger program model src_path build_path
|
||||
echo ""
|
||||
exit 1
|
||||
|
@ -67,24 +64,19 @@ done
|
|||
SIM_PID=0
|
||||
|
||||
# Allow speed factor to bet set from environment.
|
||||
if [[ -n "$PX4_SIM_SPEED_FACTOR" ]];
|
||||
then
|
||||
if [[ -n "$PX4_SIM_SPEED_FACTOR" ]]; then
|
||||
speed_factor=$PX4_SIM_SPEED_FACTOR
|
||||
else
|
||||
speed_factor=1
|
||||
fi
|
||||
|
||||
if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ]
|
||||
then
|
||||
if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ]; then
|
||||
# Start Java simulator
|
||||
"$src_path"/Tools/jmavsim_run.sh -r 250 -f $speed_factor &
|
||||
SIM_PID=`echo $!`
|
||||
elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]
|
||||
then
|
||||
if [ -x "$(command -v gazebo)" ]
|
||||
then
|
||||
if [[ -z "$DONT_RUN" ]]
|
||||
then
|
||||
elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
|
||||
if [ -x "$(command -v gazebo)" ]; then
|
||||
if [[ -z "$DONT_RUN" ]]; then
|
||||
# Set the plugin path so Gazebo finds our model and sim
|
||||
source "$src_path/Tools/setup_gazebo.bash" "${src_path}" "${build_path}"
|
||||
|
||||
|
@ -123,26 +115,19 @@ echo SITL COMMAND: $sitl_command
|
|||
export PX4_SIM_MODEL=${model}
|
||||
|
||||
|
||||
if [[ -n "$DONT_RUN" ]]
|
||||
then
|
||||
if [[ -n "$DONT_RUN" ]]; then
|
||||
echo "Not running simulation (\$DONT_RUN is set)."
|
||||
elif [ "$debugger" == "lldb" ]
|
||||
then
|
||||
elif [ "$debugger" == "lldb" ]; then
|
||||
eval lldb -- $sitl_command
|
||||
elif [ "$debugger" == "gdb" ]
|
||||
then
|
||||
elif [ "$debugger" == "gdb" ]; then
|
||||
eval gdb --args $sitl_command
|
||||
elif [ "$debugger" == "ddd" ]
|
||||
then
|
||||
elif [ "$debugger" == "ddd" ]; then
|
||||
eval ddd --debugger gdb --args $sitl_command
|
||||
elif [ "$debugger" == "valgrind" ]
|
||||
then
|
||||
elif [ "$debugger" == "valgrind" ]; then
|
||||
eval valgrind --track-origins=yes --leak-check=full -v $sitl_command
|
||||
elif [ "$debugger" == "callgrind" ]
|
||||
then
|
||||
elif [ "$debugger" == "callgrind" ]; then
|
||||
eval valgrind --tool=callgrind -v $sitl_command
|
||||
elif [ "$debugger" == "ide" ]
|
||||
then
|
||||
elif [ "$debugger" == "ide" ]; then
|
||||
echo "######################################################################"
|
||||
echo
|
||||
echo "PX4 simulator not started, use your IDE to start PX4_${model} target."
|
||||
|
@ -156,14 +141,11 @@ fi
|
|||
|
||||
popd >/dev/null
|
||||
|
||||
if [[ -z "$DONT_RUN" ]]
|
||||
then
|
||||
if [ "$program" == "jmavsim" ]
|
||||
then
|
||||
if [[ -z "$DONT_RUN" ]]; then
|
||||
if [ "$program" == "jmavsim" ]; then
|
||||
pkill -9 -P $SIM_PID
|
||||
kill -9 $SIM_PID
|
||||
elif [ "$program" == "gazebo" ]
|
||||
then
|
||||
elif [ "$program" == "gazebo" ]; then
|
||||
kill -9 $SIM_PID
|
||||
if [[ ! -n "$HEADLESS" ]]; then
|
||||
kill -9 $GUI_PID
|
||||
|
|
|
@ -10,23 +10,19 @@ SYSTYPE=`uname -s`
|
|||
#
|
||||
# XXX The uploader should be smarter than this.
|
||||
#
|
||||
if [ $SYSTYPE = "Darwin" ];
|
||||
then
|
||||
if [ $SYSTYPE = "Darwin" ]; then
|
||||
SERIAL_PORTS="/dev/tty.usbmodemPX*,/dev/tty.usbmodem*"
|
||||
fi
|
||||
|
||||
if [ $SYSTYPE = "Linux" ];
|
||||
then
|
||||
if [ $SYSTYPE = "Linux" ]; then
|
||||
SERIAL_PORTS="/dev/serial/by-id/*_PX4_*,/dev/serial/by-id/usb-3D_Robotics*,/dev/serial/by-id/usb-The_Autopilot*,/dev/serial/by-id/usb-Bitcraze*,/dev/serial/by-id/pci-Bitcraze*,/dev/serial/by-id/usb-Gumstix*,"
|
||||
fi
|
||||
|
||||
if [[ $SYSTYPE = *"CYGWIN"* ]];
|
||||
then
|
||||
if [[ $SYSTYPE = *"CYGWIN"* ]]; then
|
||||
SERIAL_PORTS="/dev/ttyS*"
|
||||
fi
|
||||
|
||||
if [ $SYSTYPE = "" ];
|
||||
then
|
||||
if [ $SYSTYPE = "" ]; then
|
||||
SERIAL_PORTS="COM32,COM31,COM30,COM29,COM28,COM27,COM26,COM25,COM24,COM23,COM22,COM21,COM20,COM19,COM18,COM17,COM16,COM15,COM14,COM13,COM12,COM11,COM10,COM9,COM8,COM7,COM6,COM5,COM4,COM3,COM2,COM1,COM0"
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue