-
Notifications
You must be signed in to change notification settings - Fork 0
/
runme.sh
executable file
·86 lines (65 loc) · 1.42 KB
/
runme.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
#! /bin/bash
function build {
echo "Building and installing..."
if [[ !(-d "build") ]]; then
mkdir build
fi
if [[ !(-d "src/generated") ]]; then
mkdir -p src/generated
fi
if [[ !(-d "src/include/generated") ]]; then
mkdir -p src/include/generated
fi
cd build
$CMAKE .. -DCMAKE_INSTALL_PREFIX=""
$CMAKE --build . -j$(nproc)
make DESTDIR=$ROOT_DIR install
# For cmake v3.15+
# $CMAKE --install . --prefix $ROOT_DIR
}
function clean {
if [[ $1 = "tests" ]] && [[ -d "tests" ]]; then
echo "Cleaning tests..."
rm -f tests/*.{csv,dot,ps,asm,3ac}
return
fi
echo "Cleaning..."
if [[ -d "build" ]]; then
rm -r build
fi
if [[ -d "src/generated" ]]; then
rm -r src/generated
fi
if [[ -d "src/include/generated" ]]; then
rm -r src/include/generated
fi
}
function rebuild {
clean
build
}
function dpdf {
dot -Tpdf tests/$1.dot -o tests/$1.pdf && xdg-open tests/$1.pdf
}
function dps {
dot -Tps tests/$1.dot -o tests/$1.ps && xdg-open tests/$1.ps
}
# main
# *please run in root directory only
ROOT_DIR=$(pwd)
CMAKE="cmake"
cmd="$(tr [A-Z] [a-z] <<< $1)"
case $cmd in
build | rebuild)
$cmd
;;
clean)
$cmd $2
;;
pdf | ps)
d$1 $2
;;
*)
echo "Usage: $0 [build|clean|rebuild|ps <test#>|pdf <test#>]"
;;
esac