blob: bd3f130d611f5a2266105c66cbccebd3ab913183 (
plain) (
blame)
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
|
#!/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
|