Update build-script to be directory-independent
This commit is contained in:
parent
76c2fbb344
commit
2b9bdf568a
49
build.sh
49
build.sh
@ -1,9 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
MODULE_PATH=$(realpath $PWD/${0%build\.sh})
|
||||||
|
|
||||||
|
# JARs
|
||||||
|
UCOMP=microcompiler.jar
|
||||||
|
COMP=compiler.jar
|
||||||
|
WEAVER=weaver.jar
|
||||||
|
|
||||||
|
# Main classes
|
||||||
|
UCOMPMAIN=MicrocompilerKt
|
||||||
|
COMPMAIN=CompilerKt
|
||||||
|
WEAVERMAIN=WeaverKt
|
||||||
|
|
||||||
|
# Random number generator
|
||||||
|
RGEN=rand_gen.py
|
||||||
|
|
||||||
|
# Intermediate file
|
||||||
|
INTER=comp.out
|
||||||
|
|
||||||
|
|
||||||
usage(){
|
usage(){
|
||||||
echo -e "Usage:\n\t$0 [TARGET] {TYPE | OUTFILE}\n\t$0 [TARGET] [MICROTARGET] [OUTFILE]\n\t$0 [TARGET] [TYPE] [OUTFILE] [COMBINE]\n\t$0 [TARGET] asm [OUTFILE] [COMBINE] [MICROTARGET]\n\nWhere:\n\tTARGET: main compilation target file\n\tTYPE: either \"asm\" or \"micro\"\n\tOUTFILE: output .mia file\n\tCOMBINE: existing .mia file to combine compilation output with\n\tMICROTARGET: explicit microinstruction target"
|
echo -e "Usage:\n\t$0 [TARGET] {TYPE | OUTFILE}\n\t$0 [TARGET] [MICROTARGET] [OUTFILE]\n\t$0 [TARGET] [TYPE] [OUTFILE] [COMBINE]\n\t$0 [TARGET] asm [OUTFILE] [COMBINE] [MICROTARGET]\n\nWhere:\n\tTARGET: main compilation target file\n\tTYPE: either \"asm\" or \"micro\"\n\tOUTFILE: output .mia file\n\tCOMBINE: existing .mia file to combine compilation output with\n\tMICROTARGET: explicit microinstruction target"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path_of(){
|
||||||
|
echo "$MODULE_PATH/$1"
|
||||||
|
}
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
>&2 echo "Not enough arguments!"
|
>&2 echo "Not enough arguments!"
|
||||||
usage
|
usage
|
||||||
@ -66,29 +89,33 @@ case $# in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
make all
|
(cd $MODULE_PATH && make all)
|
||||||
|
|
||||||
if [ "$TYPE" = "asm" ]; then
|
if [ "$TYPE" = "asm" ]; then
|
||||||
KJAR="compiler.jar"
|
KJAR=$COMP
|
||||||
KCLASS="CompilerKt"
|
KCLASS=$COMPMAIN
|
||||||
else
|
else
|
||||||
KJAR="microcompiler.jar"
|
KJAR=$UCOMP
|
||||||
KCLASS="MicrocompilerKt"
|
KCLASS=$UCOMPMAIN
|
||||||
fi
|
fi
|
||||||
kotlin -classpath $KJAR $KCLASS $TARGET > comp.out || exit
|
|
||||||
python rand_gen.py >> comp.out
|
kotlin -classpath $(path_of $KJAR) $KCLASS $TARGET > $INTER || exit
|
||||||
|
python "$(path_of $RGEN)" >> $INTER
|
||||||
|
|
||||||
if [ "$COMBINE" = "" ]; then
|
if [ "$COMBINE" = "" ]; then
|
||||||
if [ "$MICRO" != "" ]; then
|
if [ "$MICRO" != "" ]; then
|
||||||
kotlin -classpath microcompiler.jar MicrocompilerKt $MICRO >> comp.out || exit
|
kotlin -classpath $(path_of $UCOMP) $UCOMPMAIN $MICRO >> $INTER || exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kotlin -classpath weaver.jar WeaverKt comp.out $OUTPUT || exit
|
kotlin -classpath $(path_of $WEAVER) $WEAVERMAIN $INTER $OUTPUT || exit
|
||||||
else
|
else
|
||||||
if [ "$MICRO" != "" ]; then
|
if [ "$MICRO" != "" ]; then
|
||||||
kotlin -classpath microcompiler.jar MicrocompilerKt $MICRO >> comp.out || exit
|
kotlin -classpath $(path_of $UCOMP) $UCOMPMAIN $MICRO >> $INTER || exit
|
||||||
fi
|
fi
|
||||||
kotlin -classpath weaver.jar WeaverKt comp.out $COMBINE $OUTPUT || exit
|
kotlin -classpath $(path_of $WEAVERJAR) $WEAVERMAIN $INTER $COMBINE $OUTPUT || exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Remove intermediate compilation file
|
||||||
|
rm -f $INTER
|
||||||
|
|
||||||
echo "Compiled successfully to $OUTPUT"
|
echo "Compiled successfully to $OUTPUT"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user