-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
95 lines (84 loc) · 1.72 KB
/
build.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
#!/bin/bash
set -e
NGRF_DIRS=(/mnt/c/Users/bigyi/Documents/OpenTTD/newgrf /mnt/c/Users/bigyi/OneDrive/Documents/OpenTTD/newgrf)
USAGE="usage: ./build.sh (default | install | bundle | sprites | compile | clean)"
BAD_ARGS=85
GRF_PATH=./dist/cass2.grf
LINE() {
echo "--------"
}
default() {
clean
compile
bundle
install
}
sprites() {
echo "Generating sprites..."
python3 src/generateSpritesets.py | sed '/^\/\/!SPRITES!\/\//{
r /dev/stdin
d
}' src/cass2_template.nml > out/cass2.nml
echo "Sprites generated."
}
compile() {
echo "Compiling GRF..."
mkdir -v -p out
sprites
./nml/nmlc --custom-tags=lang/custom_tags.txt --palette=DOS --nfo=out/cass2.nfo --grf=out/cass2.grf out/cass2.nml
echo "Compiling GRF complete."
LINE
}
bundle() {
echo "Bundling GRF..."
rm -v cass2.tar
rm -v -r dist
mkdir -v -p dist
cp -v out/cass2.grf dist
cp -v README.md dist/readme.txt
cp -v LICENSE dist/license.txt
cp -v changelog.md dist/changelog.txt
tar cvf cass2.tar dist
echo "GRF bundled."
LINE
}
install() {
echo "Installing GRF..."
if [[ -e $GRF_PATH ]]; then
for dir in "${NGRF_DIRS[@]}"; do
cp -v $GRF_PATH $dir
done
echo "Successfully installed."
else
echo "GRF path '$GRF_PATH' does not exist."
fi
LINE
}
clean() {
echo "Cleaning installation dir..."
for dir in "${NGRF_DIRS[@]}"; do
[ -e "$dir/cass2.grf" ] && rm -v "$dir/cass2.grf"
done
echo "Cleaning complete."
LINE
}
if [[ "$#" -eq 0 ]]; then
default
exit 0
fi
if [[ "$1" = "sprites" ]]; then
sprites
elif [[ "$1" = "default" ]]; then
default
elif [[ "$1" = "install" ]]; then
install
elif [[ "$1" = "bundle" ]]; then
bundle
elif [[ "$1" = "compile" ]]; then
compile
elif [[ "$1" = "clean" ]]; then
clean
else
echo $USAGE
exit $BAD_ARGS
fi