aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/lazres-UltraStar.sh
diff options
context:
space:
mode:
authorjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-12-03 00:57:22 +0000
committerjaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-12-03 00:57:22 +0000
commit0785f09a42a52f77b1c6d4683edd18385006e1eb (patch)
treef7e936028942d9962abf50281e838616f4070ab1 /Game/Code/lazres-UltraStar.sh
parent758a9f2a8ee94b7e3f20695ede89b6fb71bd7f5b (diff)
downloadusdx-0785f09a42a52f77b1c6d4683edd18385006e1eb.tar.gz
usdx-0785f09a42a52f77b1c6d4683edd18385006e1eb.tar.xz
usdx-0785f09a42a52f77b1c6d4683edd18385006e1eb.zip
Added Makefile and lazres script from
hennymcc ( on IRC ) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@657 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/lazres-UltraStar.sh')
-rwxr-xr-xGame/Code/lazres-UltraStar.sh94
1 files changed, 94 insertions, 0 deletions
diff --git a/Game/Code/lazres-UltraStar.sh b/Game/Code/lazres-UltraStar.sh
new file mode 100755
index 00000000..1f5adb78
--- /dev/null
+++ b/Game/Code/lazres-UltraStar.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+##
+# Creates an .lrs resource-file.
+# This script reads an rc resource definition file
+# and uses lazres to compile it into an lrs-file.
+##
+
+RCFILE=UltraStar.rc
+OUTFILE=UltraStar.lrs
+# set this to your lazarus directory if autodetection fails
+LAZDIR_DEFAULT=/usr/local/share/lazarus
+
+LAZDIR=`whereis -b lazarus | cut -s -d ' ' -f2`
+if [ ! -d "${LAZDIR}" ]; then
+ if [ ! -d "${LAZDIR_DEFAULT}" ]; then
+ echo "Autodetecting Lazarus-directory failed!"
+ echo "Set LAZDIR_DEFAULT to your Lazarus directory in this script."
+ exit 1
+ fi
+ LAZDIR="${LAZDIR_DEFAULT}"
+fi
+
+LAZRES="${LAZDIR}/tools/lazres"
+LAZRES_SRC="${LAZRES}.pp"
+LAZRES_PROJ="${LAZRES}.lpi"
+LAZBUILD="${LAZDIR}/lazbuild"
+UNIT_PATH=-Fu${LAZDIR}/lcl/units/i386-linux
+
+# check if lazres is available
+if [ ! -x "${LAZRES}" ]; then
+ # lazres not available -> build it
+ echo -e "Building of lazres required...\n"
+ # check if lazres project-file exists
+ if [ ! -f "${LAZRES_SRC}" ]; then
+ echo -e "\n${LAZRES_SRC} not found!"
+ exit 1
+ fi
+ # build lazres
+ fpc -dRELEASE "${UNIT_PATH}" "${LAZRES_SRC}"
+ #"${LAZBUILD}" "${LAZRES_PROJ}"
+ # did it fail?
+ if [ $? -ne 0 ]; then
+ echo -e "\nBuilding lazres failed!"
+ exit 1
+ fi
+ echo -e "\nBuilding lazres finished!"
+fi
+
+# create temp-dir for file renaming (do not use varname TMPDIR!)
+RENAME_DIR=`mktemp -t -d usdxresXXXXXXXXXX` || exit 1
+echo "Temporary directory for file-renaming created! (${RENAME_DIR})"
+
+# read each line of RC-file and add resource-path to parameter-list
+LAZRES_PARAMS=""
+echo "Reading RC-file..."
+{
+while read -r res_name res_type res_path; do
+ # check if line is commented out
+ if (echo ${res_name} | grep "^//" >/dev/null) ; then
+ echo "Skip resource: ${res_name}"
+ continue
+ fi
+ # add non-empty paths to parameter-list
+ if [ ! -z "${res_path}" ]; then
+ # replace backslashes (\\) and carriage return (\r) (MS-DOS line-ending)
+ RES_PATH=`echo "${res_path}" | tr '\r\\' '\0/'`
+ RES_NEW_PATH="${RENAME_DIR}/${res_name}.${res_type}"
+ eval cp "${RES_PATH}" "${RES_NEW_PATH}"
+ # append to parameter-list
+ LAZRES_PARAMS="${LAZRES_PARAMS} ${RES_NEW_PATH}"
+ fi
+done
+} < "${RCFILE}"
+
+# create resource file
+rm -f ${OUTFILE}
+echo "Creating resource file..."
+"${LAZRES}" "${OUTFILE}" ${LAZRES_PARAMS}
+RES=0
+if [ -f "${OUTFILE}" ]; then
+ echo -e "\nResource file successfully created!"
+ RES=1
+else
+ echo -e "\nCreation of resource file failed!"
+fi
+
+# remove temp-directory
+echo "Removing temporary directory..."
+rm -rf "${RENAME_DIR}"
+
+if [ $RES -eq 1 ]; then
+ echo -e "\nReady."
+fi