Path: blob/master/Tools/gittools/path-nonlibraries.sh
9594 views
#!/usr/bin/env bash12usage() {3cat >&$1 <<EOF4Usage: $0 [OPTIONS]56Read a list of files relative to ardupilot's root directory and output the7non-libraries subsystems they belong to.89Options:10--show-paths, -p Print also file paths after the library name.11--help, -h Show this help message.12EOF13}1415show_paths=false1617while [[ -n $1 ]]; do18case "$1" in19--show-paths|-p)20show_paths=true21;;22--help|-h)23usage 124exit 025;;26*)27usage 228exit 129;;30esac3132shift33done3435SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))36ROOT=$(dirname $(git -C $SCRIPT_DIR rev-parse --git-dir))3738if $show_paths; then39sedcmd="s,\([^/]\+\).*,\1\t\0,"40else41sedcmd="s,\([^/]\+\).*,\1,"42fi4344grep -v "^libraries" | \45sed $sedcmd | \46sort | \47uniq | \48if $show_paths; then49while read d f; do50[[ -d "$ROOT/$d" ]] && printf "%s\t%s\n" "$d" "$f"51done52else53while read d; do54[[ -d "$ROOT/$d" ]] && echo "$d"55done56fi575859