Skip to content
Snippets Groups Projects
Commit 0db27400 authored by Alberto Nidasio's avatar Alberto Nidasio
Browse files

Formatted sbs

parent 6ed2fb87
Branches
No related tags found
No related merge requests found
...@@ -43,26 +43,59 @@ for arg in "$@"; do ...@@ -43,26 +43,59 @@ for arg in "$@"; do
--list) set -- "$@" "-l" ;; --list) set -- "$@" "-l" ;;
--test) set -- "$@" "-t" ;; --test) set -- "$@" "-t" ;;
--verbose) set -- "$@" "-v" ;; --verbose) set -- "$@" "-v" ;;
*) set -- "$@" "$arg" *) set -- "$@" "$arg" ;;
esac esac
done done
while getopts b:cdef:hj:lnrt:uv opt; do while getopts b:cdef:hj:lnrt:uv opt; do
case "$opt" in case "$opt" in
b) find_deps && build "$build_default_dir" "$OPTARG"; exit;; b)
c) find_deps && clean_all; exit;; find_deps && build "$build_default_dir" "$OPTARG"
exit
;;
c)
find_deps && clean_all
exit
;;
d) set_debug ;; d) set_debug ;;
e) find_deps && lint true; exit;; e)
f) find_deps && flash "$OPTARG"; exit;; find_deps && lint true
h) usage; exit 0;; exit
;;
f)
find_deps && flash "$OPTARG"
exit
;;
h)
usage
exit 0
;;
j) set_jobs "$OPTARG" ;; j) set_jobs "$OPTARG" ;;
l) find_deps && list; exit;; l)
n) find_deps && lint false; exit;; find_deps && list
r) find_deps && boards; exit;; exit
t) find_deps && run_tests "$OPTARG"; exit;; ;;
u) find_deps && configure "$build_default_dir"; exit;; n)
find_deps && lint false
exit
;;
r)
find_deps && boards
exit
;;
t)
find_deps && run_tests "$OPTARG"
exit
;;
u)
find_deps && configure "$build_default_dir"
exit
;;
v) set_verbose ;; v) set_verbose ;;
?) usage; exit 2;; ?)
usage
exit 2
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
......
...@@ -64,19 +64,34 @@ find_deps() { ...@@ -64,19 +64,34 @@ find_deps() {
command -v st-flash >/dev/null 2>&1 && found_stflash=true command -v st-flash >/dev/null 2>&1 && found_stflash=true
command -v ST-LINK_CLI.exe >/dev/null 2>&1 && found_stlink=true command -v ST-LINK_CLI.exe >/dev/null 2>&1 && found_stlink=true
printf "Found CMake: "; [ "$found_cmake" = true ] && echo "yes" || echo "no" printf "Found CMake: "
printf "Found arm-miosix-eabi-g++: "; [ "$found_miosixgpp" = true ] && echo "yes" || echo "no" [ "$found_cmake" = true ] && echo "yes" || echo "no"
printf "Found Ccache: "; [ "$found_ccache" = true ] && echo "yes" || echo "no" printf "Found arm-miosix-eabi-g++: "
printf "Found Ninja: "; [ "$found_ninja" = true ] && echo "yes" || echo "no" [ "$found_miosixgpp" = true ] && echo "yes" || echo "no"
printf "Found Python: "; [ "$found_python" = true ] && echo "yes" || echo "no" printf "Found Ccache: "
printf "Found Cppcheck: "; [ "$found_cppcheck" = true ] && echo "yes" || echo "no" [ "$found_ccache" = true ] && echo "yes" || echo "no"
printf "Found clang-tidy: "; [ "$found_clangtidy" = true ] && echo "yes" || echo "no" printf "Found Ninja: "
printf "Found clang-format: "; [ "$found_clangformat" = true ] && echo "yes" || echo "no" [ "$found_ninja" = true ] && echo "yes" || echo "no"
printf "Found flasher: "; [ "$found_stflash" = true ] && echo "st-flash" \ printf "Found Python: "
|| { [ "$found_stlink" = true ] && echo "st-link" || echo "no"; } [ "$found_python" = true ] && echo "yes" || echo "no"
printf "Found Cppcheck: "
[ "$found_cmake" = true ] || { echo "Error: CMake must be installed"; return 1; } [ "$found_cppcheck" = true ] && echo "yes" || echo "no"
[ "$found_miosixgpp" = true ] || { echo "Error: arm-miosix-eabi-g++ must be installed"; return 1; } printf "Found clang-tidy: "
[ "$found_clangtidy" = true ] && echo "yes" || echo "no"
printf "Found clang-format: "
[ "$found_clangformat" = true ] && echo "yes" || echo "no"
printf "Found flasher: "
[ "$found_stflash" = true ] && echo "st-flash" ||
{ [ "$found_stlink" = true ] && echo "st-link" || echo "no"; }
[ "$found_cmake" = true ] || {
echo "Error: CMake must be installed"
return 1
}
[ "$found_miosixgpp" = true ] || {
echo "Error: arm-miosix-eabi-g++ must be installed"
return 1
}
} }
# Workaround: Disable tests in excluded subdirectories # Workaround: Disable tests in excluded subdirectories
...@@ -92,7 +107,10 @@ configure() { ...@@ -92,7 +107,10 @@ configure() {
ohai "Configure" ohai "Configure"
[ -f "$toolchain_file" ] || { echo "Error: CMake Toolchain File for Miosix was not found"; return 1; } if ! [[ -f "$toolchain_file" ]]; then
echo "Error: CMake Toolchain File for Miosix was not found"
return 1
fi
declare -a defs=(-DCMAKE_EXPORT_COMPILE_COMMANDS=ON) declare -a defs=(-DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
defs+=(-DCMAKE_C_FLAGS=-fdiagnostics-color=always -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always) defs+=(-DCMAKE_C_FLAGS=-fdiagnostics-color=always -DCMAKE_CXX_FLAGS=-fdiagnostics-color=always)
...@@ -122,8 +140,8 @@ check_configured() { ...@@ -122,8 +140,8 @@ check_configured() {
else else
[ -f "$build_dir/$DEBUG_FILENAME" ] && found_debug=true || found_debug=false [ -f "$build_dir/$DEBUG_FILENAME" ] && found_debug=true || found_debug=false
[ -f "$build_dir/$VERBOSE_FILENAME" ] && found_verbose=true || found_verbose=false [ -f "$build_dir/$VERBOSE_FILENAME" ] && found_verbose=true || found_verbose=false
if [ "$config_debug" != "$found_debug" ] \ if [ "$config_debug" != "$found_debug" ] ||
|| [ "$config_verbose" != "$found_verbose" ]; then [ "$config_verbose" != "$found_verbose" ]; then
to_reconfigure=true to_reconfigure=true
fi fi
fi fi
...@@ -183,7 +201,10 @@ flash() { ...@@ -183,7 +201,10 @@ flash() {
ohai "Flash" ohai "Flash"
[ -f "$build_dir/$target.bin" ] || { echo "Error: target '$target' is not flashable"; return 1; } if [ -f "$build_dir/$target.bin" ]; then
echo "Error: target '$target' is not flashable"
return 1
fi
if [ "$found_stflash" = true ]; then if [ "$found_stflash" = true ]; then
st-flash --reset write "$build_dir/$target.bin" 0x8000000 st-flash --reset write "$build_dir/$target.bin" 0x8000000
...@@ -206,7 +227,10 @@ run_tests() { ...@@ -206,7 +227,10 @@ run_tests() {
ohai "Test" ohai "Test"
cmake_disable_excluded_tests "$build_dir" cmake_disable_excluded_tests "$build_dir"
( cd "$build_dir" || return; ctest ) (
cd "$build_dir" || return
ctest
)
} }
list() { list() {
...@@ -219,8 +243,8 @@ list() { ...@@ -219,8 +243,8 @@ list() {
echo "[1/1] All SBS targets available:" echo "[1/1] All SBS targets available:"
fi fi
cmake --build "$build_dir" --target help \ cmake --build "$build_dir" --target help |
| grep -o '^[^/]*\.bin' | cut -f 1 -d '.' grep -o '^[^/]*\.bin' | cut -f 1 -d '.'
} }
boards() { boards() {
...@@ -255,11 +279,11 @@ lint_clangtidy() { ...@@ -255,11 +279,11 @@ lint_clangtidy() {
ohai "Lint (clang-tidy)" ohai "Lint (clang-tidy)"
defs=(--extra-arg=-D_MIOSIX=1 --extra-arg=-D_MIOSIX_GCC_PATCH_MINOR=1 \ defs=(--extra-arg=-D_MIOSIX=1 --extra-arg=-D_MIOSIX_GCC_PATCH_MINOR=1
--extra-arg=-D_MIOSIX_GCC_PATCH_MAJOR=3 --extra-arg=-D__LINT__) --extra-arg=-D_MIOSIX_GCC_PATCH_MAJOR=3 --extra-arg=-D__LINT__)
IFS=$'\n' read -rd '' -a incs < \ IFS=$'\n' read -rd '' -a incs < \
<(arm-miosix-eabi-g++ -E -Wp,-v -xc++ /dev/null 2>&1 \ <(arm-miosix-eabi-g++ -E -Wp,-v -xc++ /dev/null 2>&1 |
| sed -n "s/^ /--extra-arg=-isystem/p") sed -n "s/^ /--extra-arg=-isystem/p")
declare opts=() declare opts=()
[ "$to_edit" = true ] && opts+=(--fix-notes --fix-errors) [ "$to_edit" = true ] && opts+=(--fix-notes --fix-errors)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment