Created
March 24, 2019 21:21
-
-
Save DominicMaas/b37b5320c21bcf01cf0a5ebcab6dd2b1 to your computer and use it in GitHub Desktop.
Build script for COMPX203. Assumes that the requires files in a bin folder next to the script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "x$1" = "x" ]; then | |
echo "Arguments: ./build.sh <name of source file without the .s> <library file>" | |
else | |
echo "Starting super awesome compiling script!" | |
# Export the path so the libs exist, located on the bin path | |
export PATH=$PWD/bin:$PATH | |
# Set our variables | |
FILE=$1 | |
DIR=$(dirname "${FILE}") | |
LIBS="" | |
# Needed for the arguments | |
shift | |
for i in "$@"; do | |
LIBS="$LIBS $i" | |
done | |
# Check if a C file exists, if it does | |
# use WCC | |
if [ -f "$FILE.c" ]; then | |
echo "Compiling $FILE.c using wcc..." | |
wcc -S "$FILE.c" -o "$FILE.s" | |
if [ ! $? -eq 0 ]; then | |
exit $? | |
fi | |
fi | |
# Check that the source file exists | |
if [ ! -f "$FILE.s" ]; then | |
echo "The file $FILE.s could not be found!" | |
exit -1 | |
fi | |
# Assemble the file | |
echo "Assembling $FILE.s using wasm..." | |
wasm "$FILE.s" | |
if [ ! $? -eq 0 ]; then | |
exit $? | |
fi | |
# Run wlink | |
echo "Linking $FILE.o using wlink..." | |
wlink -o $FILE.srec $FILE.o $LIBS | |
if [ ! $? -eq 0 ]; then | |
exit $? | |
fi | |
# Delete old .o files | |
echo "Deleting old *.o files..." | |
find $DIR -name "*.o" -type f -delete | |
# Run the marker program | |
mono bin/COMP200Marker.exe "$FILE.srec" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment