Skip to content

Commit

Permalink
Create make.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
rddim authored Jan 9, 2017
1 parent b507abe commit f200f5b
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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

0 comments on commit f200f5b

Please sign in to comment.