-
Notifications
You must be signed in to change notification settings - Fork 30
/
maintain.sh
executable file
·146 lines (126 loc) · 2.73 KB
/
maintain.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
# Maintenance script to compile Gwork on all UNIX support platforms (OSX, Linux)
set -e
case $(uname -s) in
Darwin) CM_GEN="-GXcode" ;;
*) echo "Unsupported OS"; exit 1 ;;
esac
CM_OPTS="-DWITH_TESTS=ON -DWITH_SAMPLE=ON"
CM_REFLECT="-DWITH_REFLECTION=ON"
CM_PROJ=gwork.xcodeproj
BUILD_LOG_NAME=maintain_build.txt
BUILD_LOG=../$BUILD_LOG_NAME
# Get dependencies
function get_deps
{
echo "Nothing to get"
}
function ensure_project #(renderer, build_dir)
{
local BDIR=build_$2
echo "Project: Renderer $1 in $BDIR"
if [ ! -d $BDIR ]; then
mkdir $BDIR
fi
pushd $BDIR
cmake .. $CM_GEN -DRENDER_$1=ON $CM_OPTS $CM_REFLECT
popd
}
function open_project #(renderer, build_dir)
{
pushd build_$2
open $CM_PROJ
popd
}
function build_project #(renderer, build_dir)
{
pushd build_$2
echo "===================================================================" >> $BUILD_LOG
echo "==== RENDER_${1} ====" >> $BUILD_LOG
echo "===================================================================" >> $BUILD_LOG
cmake --build . | tee -a $BUILD_LOG
popd
}
function clean_project #(renderer, build_dir)
{
pushd build_$2
echo "Cleaning $1"
cmake --build . --target clean
popd
}
function run_project #(renderer, build_dir)
{
pushd build_$2
cmake
popd
}
function apply_projects
{
$1 ALLEGRO5 al
$1 IRRLICHT irr
$1 OPENGL gl
$1 NULL null
$1 SDL2 sdl
$1 SFML2 sfml
$1 SW sw
}
function build_docs
{
pushd docs
./mkdocs.sh
popd
}
function build_all
{
local BERR=maintain_build_errors.txt
echo "Build errors:" > $BERR
echo "Maintain build log:" > $BUILD_LOG
apply_projects build_project
echo "===================================================================" >> $BERR
grep "error:" $BUILD_LOG_NAME >> $BERR
echo
echo "ERRORS:"
echo
cat maintain_build_errors.txt
}
function clean_all
{
apply_projects clean_project
}
function show_help
{
cat <<EOM
Usage: maintain.sh -hpobr [--deps] [--docs]
-d(ocs) Generate docs
-g(get) Get/build up project dependecies
-h(elp)
-p(roject) Create projects
-o(pen) Open projects in editor
-b(uild) Build all
-r(un) Run all
-c(lean) Clean all build artifacts
EOM
}
while getopts "pobcrdgh" OPT; do
case $OPT in
p) apply_projects ensure_project
;;
o) apply_projects open_project
;;
b) build_all
;;
c) clean_all
;;
r) apply_projects run_project
;;
d) build_docs
;;
g) get_deps
;;
h) show_help
;;
*) echo "Unknown argument"
show_help
;;
esac
done