Skip to content

Instantly share code, notes, and snippets.

@mliszcz
Last active January 6, 2016 16:29
Show Gist options
  • Save mliszcz/f1ef3a56b0030c13e290 to your computer and use it in GitHub Desktop.
Save mliszcz/f1ef3a56b0030c13e290 to your computer and use it in GitHub Desktop.
CAD

This is a tool for dealing with http://home.agh.edu.pl/~paszynsk/SPCAA/.

The script:

  • downloads all the sources
  • patches Barriers and awaits
  • builds project

Usage:

./fetch.sh 3c # downloads set 3c
make 3c       # compiles into ./bin
./run.sh      # runs the app

TODO:

  • format source code
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <set-number>"
exit 1
fi
root="http://home.agh.edu.pl/~paszynsk/SPCAA/$1/Java"
dest="./lab$1/src"
files="
A.java
A1.java
A2.java
AN.java
Aroot.java
BS.java
E2.java
Eroot.java
Executor.java
Main.java
P1.java
P2.java
P3.java
Production.java
Vertex.java"
rm -rf $dest
mkdir -p $dest
for f in $files; do
wget -O "$dest/$f" "$root/$f"
done
find $dest -type f -name "*.java" -exec sed -i 's/CyclicBarrier/CountDownLatch/g' "{}" ";"
find $dest -type f -name "*.java" -exec sed -i 's/await/countDown/g' "{}" ";"
find $dest -type f -name "Executor.java" -exec sed -i 's/countDown/await/g' "{}" ";"
find $dest -type f -name "*.java" -exec sed -i \
's/InterruptedException | BrokenBarrierException/NullPointerException/g' "{}" ";"
find $dest -type f -name "Executor.java" -exec sed -i 's/NullPointerException/InterruptedException/g' "{}" ";"
BINDIR=./bin
%:
mkdir -p $(BINDIR)
javac -d $(BINDIR) ./lab$@/src/*
clean:
rm -rf $(BINDIR)/*
#!/bin/bash
java -cp ./bin Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment