-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathcompile_to_tmp.sh
executable file
·53 lines (45 loc) · 1.03 KB
/
compile_to_tmp.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
#!/usr/bin/env bash
set -eo pipefail
mkdir -p $T
for var in "$@"; do
if [ -z ${var##*.c} ]; then
sourcefile=$var
base=${var##*/}
base=${base%.*}
#echo "YES1: $var"
break
fi
if [ -z ${var##*.cpp} ]; then
sourcefile=$var
base=${var##*/}
base=${base%.*}
#echo "YES2: $var"
break
fi
if [ -z ${var##*.m} ]; then
sourcefile=$var
base=${var##*/}
base=${base%.*}
#echo "YES2: $var"
break
fi
if [ -z ${var##*.mm} ]; then
sourcefile=$var
base=${var##*/}
base=${base%.*}
#echo "YES2: $var"
break
fi
done
#echo "base:" $base
#echo "command:" $@ -o /tmp/$base.o
GREEN='\033[0;32m'
LIGHT_CYAN='\033[0;36m'
YELLOW='\033[0;33m'
NC='\033[0m'
printf "${GREEN}Compiling${LIGHT_CYAN} $sourcefile${NC}...\n"
start=`date +%s`
"$@" -o $T/$base.o
end=`date +%s`
runtime=$((end-start))
printf " ${LIGHT_CYAN}$sourcefile ${GREEN} compiled.${YELLOW} (${runtime}s)${NC}\n"