@@ -969,3 +969,60 @@ function ci_alif_ae3_build {
969969 make ${MAKEOPTS} -C ports/alif BOARD=OPENMV_AE3 MCU_CORE=M55_DUAL
970970 make ${MAKEOPTS} -C ports/alif BOARD=ALIF_ENSEMBLE MCU_CORE=M55_DUAL
971971}
972+
973+ function _ci_help {
974+ # Note: these lines must be indented with tab characters (required by bash <<-EOF)
975+ cat << -EOF
976+ ci.sh: Script fragments used during CI
977+
978+ When invoked as a script, runs a sequence of ci steps,
979+ stopping after the first error.
980+
981+ Usage:
982+ ${BASH_SOURCE} ci_foo ci_bar
983+
984+ Commands:
985+ EOF
986+ if type -path column > /dev/null 2>&1 ; then
987+ grep ' ^function ci_' $0 | awk ' {print $2}' | column
988+ else
989+ grep ' ^function ci_' $0 | awk ' {print $2}'
990+ fi
991+ exit
992+ }
993+
994+ function _ci_main {
995+ case " $1 " in
996+ (-h|-? |--help)
997+ _ci_help
998+ ;;
999+ (* )
1000+ cd $( dirname " $0 " ) /..
1001+ while [ $# -ne 0 ]; do
1002+ $1
1003+ shift
1004+ done
1005+ ;;
1006+ esac
1007+ }
1008+
1009+ # https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced
1010+ sourced=0
1011+ if [ -n " $ZSH_VERSION " ]; then
1012+ case $ZSH_EVAL_CONTEXT in * :file) sourced=1;; esac
1013+ elif [ -n " $KSH_VERSION " ]; then
1014+ [ " $( cd -- " $( dirname -- " $0 " ) " && pwd -P) /$( basename -- " $0 " ) " != " $( cd -- " $( dirname -- " ${.sh.file} " ) " && pwd -P) /$( basename -- " ${.sh.file} " ) " ] && sourced=1
1015+ elif [ -n " $BASH_VERSION " ]; then
1016+ (return 0 2> /dev/null) && sourced=1
1017+ else # All other shells: examine $0 for known shell binary filenames.
1018+ # Detects `sh` and `dash`; add additional shell filenames as needed.
1019+ case ${0##*/ } in sh|-sh|dash|-dash) sourced=1;; esac
1020+ fi
1021+
1022+ if [ $sourced -eq 0 ]; then
1023+ # invoked as a command
1024+ if [ " $# " -eq 0 ]; then
1025+ set -- --help
1026+ fi
1027+ _ci_main " $@ "
1028+ fi
0 commit comments