forked from ChaoticOnyx/OnyxBay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdm.sh
executable file
·57 lines (44 loc) · 1.26 KB
/
dm.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
#!/bin/bash
set -o pipefail
dmepath=""
retval=1
for var; do
if [[ $var != -* && $var == *.dme ]]; then
dmepath=$(echo $var | sed -r 's/.{4}$//')
break
fi
done
if [[ $dmepath == "" ]]; then
echo "No .dme file specified, aborting."
exit 1
fi
if [[ -a $dmepath.mdme ]]; then
rm $dmepath.mdme
fi
cp $dmepath.dme $dmepath.mdme
if [[ $? != 0 ]]; then
echo "Failed to make modified dme, aborting."
exit 2
fi
for var; do
arg=$(echo $var | sed -r 's/^.{2}//')
if [[ $var == -D* ]]; then
sed -i '1s!^!#define '$arg'\n!' $dmepath.mdme
elif [[ $var == -I* ]]; then
sed -i 's!// BEGIN_INCLUDE!// BEGIN_INCLUDE\n#include "'$arg'"!' $dmepath.mdme
elif [[ $var == -M* ]]; then
sed -i '1s/^/#define MAP_OVERRIDE\n/' $dmepath.mdme
sed -i 's!#include "maps\\_map_include.dm"!#include "maps\\'$arg'\\'$arg'.dm"!' $dmepath.mdme
fi
done
source "$( dirname "${BASH_SOURCE[0]}" )/sourcedm.sh"
if [[ $DM == "" ]]; then
echo "Couldn't find the DreamMaker executable, aborting."
exit 3
fi
"$DM" $dmepath.mdme | tee build_log.txt
retval=$?
[[ -e $dmepath.mdme.dmb ]] && mv $dmepath.mdme.dmb $dmepath.dmb
[[ -e $dmepath.mdme.rsc ]] && mv $dmepath.mdme.rsc $dmepath.rsc
rm $dmepath.mdme
exit $retval