-
Notifications
You must be signed in to change notification settings - Fork 2
/
make.sh
69 lines (59 loc) · 1.87 KB
/
make.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
#!/bin/sh
echo "***************************************************************"
echo "*"
echo "* OpenTTD \"Bulgarian Town Names\""
echo "* Copyright (c) 2017 Rusi Dimitrov"
echo "* This program comes with ABSOLUTELY NO WARRANTY."
echo "* This is free software, and you are welcome to redistribute it"
echo "* under certain conditions of GPL v3 license."
echo "*"
echo "***************************************************************"
# Set variables
NMLC=$(which nmlc)
TAR=$(which tar)
SRC="$PWD/src"
cp $SRC/custom_tags-base.txt $SRC/custom_tags.txt
VERSION=$(grep VERSION "${SRC}/custom_tags.txt" | cut -d':' -f2)
NAME="bg_names"
BUILD="Bulgarian_Town_Names-${VERSION}"
RELEASE="$PWD/build/${BUILD}"
# Preliminary checks
if [ -z ${NMLC} ]; then
echo "ERROR: NML not found!"
exit 1
fi
if [ -z ${VERSION} ]; then
echo "ERROR: Failed to get version!"
exit 1
fi
# Create folder
echo "\n *** Creating folder: /build/${BUILD}\n"
mkdir -p "${RELEASE}"
# Building
echo "\n *** Building from the source, please wait...\n"
${NMLC} --grf="${RELEASE}/${NAME}.grf" \
--custom-tags="${SRC}/custom_tags.txt" \
--lang-dir="${SRC}/lang" \
"${SRC}/${NAME}.nml" \
--verbosity=4
# If failed, then clean up and exit
if [ $? -eq 1 ]; then
echo "\n*********************** Building failed ***********************\n"
rm -R "${RELEASE}"
exit 1
fi
# Copy files
cp $PWD/docs/*.txt ${RELEASE}
cp $PWD/LICENSE ${RELEASE}/license.txt
# Create TAR
echo "\n *** Creating archive: ${RELEASE}.tar\n"
cd "$PWD/build/"
${TAR} -cf "${RELEASE}.tar" "${BUILD}"
# Clean up files and dirs
cd - > /dev/null
rm -R "${RELEASE}" "$PWD/.nmlcache" "$SRC/custom_tags.txt"
# Finish
echo "\n********************** Building finished **********************\n"
echo "To install copy the NewGRF archive to the OpenTTD NewGRF directory:"
echo " \$ cp ${RELEASE}.tar ~/.openttd/newgrf/\n"
exit 0