While trying to create a call graph of DrJava using Soot, I ran into some problems that were supposed to have been fixed in the Soot nightly builds already. Unfortunately, the nightly builds I could find were all many months old. So I built Soot from scratch from the Subversion repository, which wasn’t an easy task.
Here are some instructions for building Soot:
- Make sure you have Ant ant the JDK (5 or newer) installed.
- Check out and download all of these code bases in the same directory.
- Download Polyglot from http://www.sable.mcgill.ca/soot/soot_download.html:
wget http://www.sable.mcgill.ca/software/polyglotclasses-1.3.5.jar
- Check out Soot from https://svn.sable.mcgill.ca/soot/soot/trunk:
svn checkout https://svn.sable.mcgill.ca/soot/soot/trunk soot-dev
- Check out Jasmin from https://svn.sable.mcgill.ca/soot/jasmin/trunk:
svn checkout https://svn.sable.mcgill.ca/soot/jasmin/trunk jasmin-dev
- Check out JastAddJ from http://svn.jastadd.org/projects/trunk/JastAddJ:
svn co http://svn.jastadd.org/projects/trunk/JastAddJ
- Check out JastAddExtensions from http://svn.jastadd.org/projects/trunk/JastAddExtensions:
svn co http://svn.jastadd.org/projects/trunk/JastAddExtensions
- You should now have the following directory structure:
.
|-- polyglotclasses-1.3.5.jar
|-- JastAddExtensions
| |-- ...
| |-- SootJastAddJ
| `-- ...
|-- JastAddJ
| `-- ...
|-- jasmin-dev
| |-- ...
| |-- lib
| | `...
| |-- ant.settings.template
| |-- build.xml
| `-- ...
`-- soot-dev
|-- ...
|-- lib
| `...
|-- ant.settings.template
|-- build.xml
`-- ...
- Copy jasmin-dev/ant.settings.template to jasmin-dev/ant.settings:
cp jasmin-dev/ant.settings.template jasmin-dev/ant.settings
- Edit jasmin-dev/ant.settings so it contains the following lines:
java_cup.jar=../polyglotclasses-1.3.5.jar
jasmin.version=trunk
- Change into the jasmin-dev directory, build the jasminclasses-trunk.jar file, and change back out of the directory:
cd jasmin-dev
ant jasmin-jar
cd ..
- The freshly built Jasmin jar file is jasmin-dev/lib/jasminclasses-trunk.jar.
- Change into the JastAddExtensions/SootJastAddJ directory, regenerate the JastAdd-generated files for Soot, and change back out of the directory:
cd JastAddExtensions/SootJastAddJ
ant gen
cd ../..
- Copy soot-dev/ant.settings.template to soot-dev/ant.settings:
cp soot-dev/ant.settings.template soot-dev/ant.settings
- Edit soot-dev/ant.settings so it contains the following lines:
jastaddfrontend.loc=../JastAddExtensions/SootJastAddJ
polyglot.jar=../polyglotclasses-1.3.5.jar
jasmin.jar=../jasmin-dev/lib/jasminclasses-trunk.jar
- Change into the soot-dev directory and build the sootclasses-trunk.jar file, and change back out of the directory:
cd soot-dev
ant classesjar
cd ..
Note: I received a compiler error here. I had to insert the second cast into soot-dev/src/soot/jbco/bafTransformations/FindDuplicateSequences.java to make line 282
Unit jump = (Unit) units.getSuccOf(next.get(next.size() - 1));
read
Unit jump = (Unit) units.getSuccOf((Unit)(next.get(next.size() - 1)));
- The freshly built Soot jar file is soot-dev/lib/sootclasses-trunk.jar.
Have fun with fresh Soot.
Here’s a bash script that does it all (except insert the cast): build-soot.sh.zip
#!/bin/bash
# Make sure you have Ant ant the JDK (5 or newer) installed.
# Check out and download all of these code bases in the same directory.
# Download Polyglot from http://www.sable.mcgill.ca/soot/soot_download.html:
wget http://www.sable.mcgill.ca/software/polyglotclasses-1.3.5.jar
# Check out Soot from https://svn.sable.mcgill.ca/soot/soot/trunk:
svn checkout https://svn.sable.mcgill.ca/soot/soot/trunk soot-dev
# Check out Jasmin from https://svn.sable.mcgill.ca/soot/jasmin/trunk:
svn checkout https://svn.sable.mcgill.ca/soot/jasmin/trunk jasmin-dev
# Check out JastAddJ from http://svn.jastadd.org/projects/trunk/JastAddJ:
svn co http://svn.jastadd.org/projects/trunk/JastAddJ
# Check out JastAddExtensions from
# http://svn.jastadd.org/projects/trunk/JastAddExtensions:
svn co http://svn.jastadd.org/projects/trunk/JastAddExtensions
# Copy jasmin-dev/ant.settings.template to jasmin-dev/ant.settings:
# Edit jasmin-dev/ant.settings so it contains the following lines:
# java_cup.jar=../polyglotclasses-1.3.5.jar
# jasmin.version=trunk
cat jasmin-dev/ant.settings.template | sed \
-e "s/.*\(java_cup.jar=\).*/\1..\/polyglotclasses-1.3.5.jar/" \
-e "s/.*\(jasmin.version=\).*/\1trunk/" \
> jasmin-dev/ant.settings
# Change into the jasmin-dev directory, build the
# jasminclasses-trunk.jar file, and change back out of the directory:
cd jasmin-dev
ant jasmin-jar
cd ..
# The freshly built Jasmin jar file is
# jasmin-dev/lib/jasminclasses-trunk.jar. Change into the
# JastAddExtensions/SootJastAddJ directory, regenerate the
# JastAdd-generated files for Soot, and change back out of the
# directory:
cd JastAddExtensions/SootJastAddJ
ant gen
cd ../..
# Copy soot-dev/ant.settings.template to soot-dev/ant.settings:
# Edit soot-dev/ant.settings so it contains the following lines:
# jastaddfrontend.loc=../JastAddExtensions/SootJastAddJ
# polyglot.jar=../polyglotclasses-1.3.5.jar
# jasmin.jar=../jasmin-dev/lib/jasminclasses-trunk.jar
cat soot-dev/ant.settings.template | sed \
-e "s/.*\(jastaddfrontend.loc=\).*/\1..\/JastAddExtensions\/SootJastAddJ/" \
-e "s/.*\(polyglot.jar=\).*/\1..\/polyglotclasses-1.3.5.jar/" \
-e "s/.*\(jasmin.jar=\).*/\1..\/jasmin-dev\/lib\/jasminclasses-trunk.jar/" \
> soot-dev/ant.settings
# Change into the soot-dev directory and build the
# sootclasses-trunk.jar file, and change back out of the directory:
cd soot-dev
ant classesjar
cd ..
cp soot-dev/lib/sootclasses-trunk.jar .