Apple2GSBuildPipeline/make/orca-rez

61 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
ERROUTPUT=/tmp/orca-rez-err.$$
FILENAME="$1"
shift
if echo $FILENAME | grep -v '\.rez$' > /dev/null
then
echo Expected first argument to be a *.rez file but got $FILENAME
exit 1
fi
BASENAME=`echo $FILENAME | sed 's/\.rez$//'`
DEPSNAME="${BASENAME}.rez.d"
OBJSNAME="${BASENAME}.r"
$ORCA --trace-gsos compile $* keep="${OBJSNAME}" "$FILENAME" 2> $ERROUTPUT
RESULT=$?
awk '
/^[A-Za-z][A-Za-z]*\(.*\)$/ {
next
}
{
print
}
/^File [^ ]*; Line [0-9][0-9]*;/ {
sub(/;/,"",$4)
LINENO=$4
sub(/^File [^ ]*; Line [0-9][0-9]*/, "", $0)
printf("%s/%s:%d:0:%s\n", PWD, FILE, LINENO, $0)
}
' "PWD=`pwd`" "FILE=$FILENAME" $ERROUTPUT >&2
if [ "$RESULT" -ne 0 ]
then
rm -f $ERROUTPUT
rm -f $OBJSNAME
exit $RESULT
fi
DEPS=`awk '
/^FastFileLoad/ {
sub(/^FastFileLoad\(/, "");
sub(/\)$/, "");
print}' $ERROUTPUT | sort -u | while read FILE
do
if [ -f "$FILE" ]
then
echo $FILE
fi
done`
echo $OBJSNAME: $DEPS > $DEPSNAME
rm -f $ERROUTPUT
exit 0