-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-aliases.sh
executable file
·103 lines (79 loc) · 1.95 KB
/
make-aliases.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
# ---------------------------------------------------------------- CONSTANTS
# Base paths
TESTS_SUBDIR="tests"
CMSIS_SHARE="\\\${STM32L0XX_CMSIS_ALIRE_PREFIX}/share/stm32l0xx_cmsis/"
# ----------------------------------------------------------- AUTO CONSTANTS
# Directories
START_ABSDIR=$(pwd)
SCRIPT_ABSDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
TESTS_ABSDIR="${SCRIPT_ABSDIR}/${TESTS_SUBDIR}"
# ------------------------------------------------------------------- INPUTS
while getopts ":t" option
do
case "${option}"
in
#h) HELP=1;;
t) TRACE=1;;
\?) error "Invalid option"
exit;;
esac
done
# ---------------------------------------------------------------- BASH LOGS
GREEN="\e[00;32m"
GREY="\e[00;90m"
RST="\e[00m"
info() {
echo -e "${GREEN}INFO:\t$@${RST}"
}
trace() {
if [[ -n "$TRACE" ]]; then
echo -e "${GREY}TRACE:\t$@${RST}"
fi
}
# --------------------------------------------------------- HELPER FUNCTIONS
move_to_directory()
{
info "Moving working directory into '$@'"
run_cmd "cd $@"
}
move_to_script_directory()
{
if [[ "$(pwd)" != "${SCRIPT_ABSDIR}" ]] ; then
move_to_directory "$SCRIPT_ABSDIR"
fi
}
move_to_tests_directory()
{
if [[ "$(pwd)" != "${TESTS_ABSDIR}" ]] ; then
move_to_directory "$TESTS_ABSDIR"
fi
}
move_to_start_directory()
{
if [[ "$(pwd)" != "${START_ABSDIR}" ]] ; then
move_to_directory "$START_ABSDIR"
fi
echo -e "${RST}"
}
run_cmd() {
CMD="$@"
if [[ -z ${TRACE} ]] ; then
SUPPRESS=">/dev/null"
fi
trace ${CMD}
eval "${CMD} ${SUPPRESS}"
CMD="unknown"
}
# ---------------------------------------------------------------------- RUN
{
move_to_script_directory
move_to_tests_directory
# Emulation testing
run_cmd \
"alr settings --set alias.emu \
\"exec -P1 arm-eabi-gnatemu --\
-XEMU_MODE=run ./bin/tests.elf\""
move_to_start_directory
info "Done"
}