Last active
August 29, 2015 13:56
-
-
Save gurupras/9266104 to your computer and use it in GitHub Desktop.
script to build os/161 source code
This file contains 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 | |
#Each statement here is a blocking call, so we don't need explicit sleeping | |
#Our trusty local variables | |
ASST=ASST0 | |
INVOKE_PATH= | |
BASE_PATH= | |
#how2use | |
usage() { | |
echo -e $0 "<asst#>\n" | |
} | |
#At this point, I'm just having fun ;) | |
#The idea is to be able to place this file anywhere in the tree (hopefully either src or kern) and have it work! | |
#There's plenty of ways you can fool this function though | |
#One easy way to break it - multiple 'src' directories | |
complex_path_finder() { | |
# We first go to a path that we can 'trust' | |
INVOKE_PATH=`pwd` | |
cd ~/ | |
# This should return some analogous equivalent of ~/src/kern/arch/sys161/startup/start.S | |
PATH_TO_CONFARCH=$(find . -name start.S | head -n 1 | sed -e 's/start\.S//g') #We are now at .../startup/ | |
# We want to get to src/kern..so.. | |
cd $PATH_TO_CONFARCH/../../../ #We should be at kern now | |
# Store this path | |
BASE_PATH=`pwd` | |
# Go back to where we were | |
cd $INVOKE_PATH | |
} | |
configure() { | |
cd $BASE_PATH/conf | |
./config $ASST | |
cd - | |
} | |
compile() { | |
cd $BASE_PATH/compile/$ASST | |
#If any one of these fail, it doesn't make sense to continue..so.. | |
bmake depend && bmake && bmake install | |
cd - | |
} | |
make_asst() { | |
echo "ASST :" $ASST | |
complex_path_finder | |
configure | |
compile | |
} | |
if [ $# -lt 1 ]; then | |
echo $0 "Needs arguments" | |
usage | |
else | |
echo "running make script" | |
if [ "$1" == "asst0" ]; then | |
ASST=ASST0 | |
elif [ "$1" == "asst1" ]; then | |
ASST=ASST1 | |
elif [ "$1" == "asst2" ]; then | |
ASST=ASST2 | |
elif [ "$1" == "asst3" ]; then | |
ASST=ASST3 | |
else | |
echo "Unknown asst " $1 | |
usage | |
return | |
fi | |
make_asst | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment