Skip to content

Commit c51f5e7

Browse files
committed
better path quoting, start to support verbose script reporting
1 parent 5d067d6 commit c51f5e7

3 files changed

Lines changed: 75 additions & 14 deletions

File tree

sduino/hardware/sduino/tools/wrapper/sdar.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
#!/bin/dash
1+
#!/bin/bash
22

3+
VERBOSE=0
4+
USE_COLOR=0
5+
if [ "$1" == "-v" ]; then
6+
VERBOSE=1;
7+
shift
8+
elif [ "$1" == "-vv" ]; then
9+
VERBOSE=2
10+
# USE_COLOR=1
11+
set -x
12+
shift
13+
fi
14+
15+
16+
if [ $USE_COLOR -gt 0 ]; then
317
# ANSI color codes to beautify the output:
418
BLACK='\033[0;30m'
519
RED='\033[0;31m'
@@ -18,10 +32,13 @@ LPURPLE='\033[1;35m'
1832
LCYAN='\033[1;36m'
1933
WHITE='\033[1;37m'
2034
OFF='\033[0m'
35+
fi
2136

2237

2338
# echo the full command line in cyan:
24-
>&2 echo "${CYAN}${@}${OFF}"
39+
>&2 echo -ne "${CYAN}"
40+
>&2 echo -n "${@}"
41+
>&2 echo -e "${OFF}"
2542

2643
# echo the mark id in green and the compiler call in white:
2744
SDAR=$1
@@ -30,7 +47,9 @@ OBJ=${3%.o}.rel
3047
MARK=$4
3148
shift 4
3249

33-
>&2 echo "${GREEN}Mark $MARK:${OFF}" "$SDAR" "$@" "$LIB" "$OBJ"
50+
>&2 echo -ne "${GREEN}Mark $MARK:${OFF}"
51+
>&2 echo "$SDAR" "$@" "$LIB" "$OBJ"
52+
3453
"$SDAR" "$@" "$LIB" "$OBJ"
3554
ERR=$?
3655
cp -a "$LIB" "${LIB%.a}.lib"

sduino/hardware/sduino/tools/wrapper/sdcc-link.sh

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
# usage: sdcc-link [.lib and .rel files] re5 [other flags and files]
44

5+
VERBOSE=0
6+
USE_COLOR=0
7+
if [ "$1" == "-v" ]; then
8+
VERBOSE=1;
9+
shift
10+
elif [ "$1" == "-vv" ]; then
11+
VERBOSE=2
12+
# USE_COLOR=1
13+
set -x
14+
shift
15+
fi
16+
17+
18+
if [ $USE_COLOR -gt 0 ]; then
519
# ANSI color codes to beautify the output:
620
BLACK='\033[0;30m'
721
RED='\033[0;31m'
@@ -20,28 +34,38 @@ LPURPLE='\033[1;35m'
2034
LCYAN='\033[1;36m'
2135
WHITE='\033[1;37m'
2236
OFF='\033[0m'
37+
fi
2338

2439
SDCC="$1"
2540
shift
2641

27-
# echo the full command line in cyan:
28-
>&2 echo -e "${CYAN}${@}${OFF}"
42+
if [ $VERBOSE ]; then
43+
# echo the full command line in cyan:
44+
>&2 echo -ne "${CYAN}"
45+
>&2 echo -n "${@}"
46+
>&2 echo -e "${OFF}"
47+
fi
2948

3049
declare -a OBJS
3150
while [ $# -gt 0 ]; do
3251
echo $1
3352
FILE=$1
34-
if [[ $FILE == *.a ]]; then
53+
if [[ "$FILE" == *.a ]]; then
3554
FILE=${FILE%.a}.lib
3655
cp -a "$1" "$FILE"
3756
fi
38-
if [[ $FILE == *.o ]]; then
57+
if [[ "$FILE" == *.o ]]; then
3958
FILE=${FILE%.o}.rel
4059
fi
41-
OBJS+=(${FILE})
60+
OBJS+=("${FILE}")
4261
shift
4362
done
44-
echo "$SDCC" "${OBJS[@]}"
63+
64+
if [ $VERBOSE ]; then
65+
echo -ne "cmd: ${ORANGE}"
66+
echo -n "$SDCC" "${OBJS[@]}"
67+
echo -e "${OFF}"
68+
fi
4569
"$SDCC" "${OBJS[@]}"
4670

4771
# propagate the sdcc exit code

sduino/hardware/sduino/tools/wrapper/sdcc.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/dash
1+
#!/bin/bash
22

33
# wrapper around SDCC to let the external interface look more gcc-alike
44
#
@@ -11,6 +11,20 @@
1111
# dependency checker on following builds
1212

1313

14+
VERBOSE=0
15+
USE_COLOR=0
16+
if [ "$1" == "-v" ]; then
17+
VERBOSE=1;
18+
shift
19+
elif [ "$1" == "-vv" ]; then
20+
VERBOSE=2
21+
# USE_COLOR=1
22+
set -x
23+
shift
24+
fi
25+
26+
27+
if [ $USE_COLOR -gt 0 ]; then
1428
# ANSI color codes to beautify the output:
1529
BLACK='\033[0;30m'
1630
RED='\033[0;31m'
@@ -29,10 +43,13 @@ LPURPLE='\033[1;35m'
2943
LCYAN='\033[1;36m'
3044
WHITE='\033[1;37m'
3145
OFF='\033[0m'
46+
fi
3247

3348

3449
# echo the full command line in cyan:
35-
>&2 echo "${CYAN}${@}${OFF}"
50+
>&2 echo -ne "${CYAN}"
51+
>&2 echo -n "${@}"
52+
>&2 echo -e "${OFF}"
3653

3754
# echo the mark id in green and the compiler call in white:
3855
SDCC=$1
@@ -41,14 +58,15 @@ OBJ=$3
4158
REL=${OBJ%.o}.rel
4259
MARK=$4
4360
shift 4
44-
>&2 echo "${GREEN}Mark $MARK:${OFF}" "$SDCC" "$@" "$SRC" -o "$OBJ"
61+
>&2 echo -ne "${GREEN}Mark $MARK:${OFF}"
62+
>&2 echo "$SDCC" "$@" "$SRC" -o "$OBJ"
4563

4664
case "$SRC" in
4765
*.cpp)
4866
# rename .cpp to .c and compile
49-
>&2 echo "${RED}cpp gefunden${OFF}";
67+
>&2 echo -e "${RED}cpp gefunden${OFF}";
5068
CSRC="${SRC%pp}"
51-
cp -av "$SRC" "$CSRC"
69+
cp -a "$SRC" "$CSRC"
5270
"$SDCC" "$@" "$CSRC" -o "$OBJ"
5371
ERR=$?
5472
rm -f "$CSRC"

0 commit comments

Comments
 (0)