mirror of
https://github.com/jeremysrand/Apple2GSBuildPipeline.git
synced 2024-12-01 14:50:19 +00:00
86 lines
1.5 KiB
Bash
Executable File
86 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
STDOUTPUT=/tmp/orca-cc-std.$$
|
|
ERROUTPUT=/tmp/orca-cc-errs.$$
|
|
|
|
FILENAME="$1"
|
|
shift
|
|
|
|
if echo $FILENAME | grep -v '\.c$' > /dev/null
|
|
then
|
|
echo Expected first argument to be a *.c file but got $FILENAME
|
|
exit 1
|
|
fi
|
|
|
|
CCARGS=""
|
|
COMPILEARGS=""
|
|
for ARG in $*
|
|
do
|
|
if echo $ARG | grep '^-[id]' > /dev/null
|
|
then
|
|
CCARGS="$CCARGS cc=$ARG"
|
|
else
|
|
COMPILEARGS="$COMPILEARGS $ARG"
|
|
fi
|
|
done
|
|
|
|
BASENAME=`echo $FILENAME | sed 's/\.c$//'`
|
|
DEPSNAME="${BASENAME}.d"
|
|
OBJSNAME="${BASENAME}.a"
|
|
ROOTNAME="${BASENAME}.root"
|
|
|
|
$ORCA --trace-gsos compile $COMPILEARGS "$FILENAME" keep="${BASENAME}" $CCARGS > $STDOUTPUT 2> $ERROUTPUT
|
|
RESULT=$?
|
|
|
|
awk '
|
|
{
|
|
print $0
|
|
}
|
|
|
|
$1 ~ /^[0-9][0-9]*$/ {
|
|
LINENO=$1
|
|
}
|
|
|
|
/^ *\^/ {
|
|
sub(/^ *\^/, "", $0)
|
|
printf("%s/%s:%d:0:%s\n", PWD, FILE, LINENO, $0)
|
|
}
|
|
' "PWD=`pwd`" "FILE=$FILENAME" $STDOUTPUT
|
|
|
|
|
|
sed '/^[A-Za-z][A-Za-z]*(.*)$/d' $ERROUTPUT >&2
|
|
|
|
if [ "$RESULT" -ne 0 ]
|
|
then
|
|
rm -f $ERROUTPUT
|
|
rm -f $STDOUTPUT
|
|
rm -f $OBJSNAME
|
|
rm -f $ROOTNAME
|
|
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 | tr '\012' ' '`
|
|
|
|
rm -f $ERROUTPUT
|
|
rm -f $STDOUTPUT
|
|
|
|
# We add a dependency for both the .o and the .root file. If this is the
|
|
# main.c file being compiled, we need the dependency on the .root file.
|
|
cat > $DEPSNAME << EOF
|
|
$OBJSNAME: $DEPS
|
|
|
|
$ROOTNAME: $DEPS
|
|
EOF
|
|
|
|
exit 0
|