Skip to content
Jeff Cho edited this page Jan 21, 2018 · 1 revision

Getting Started

This will outline the steps to getting started on Swift-WALA.

Build WALA

See the WALA Getting Started guide to install WALA. If these instructions are giving you issues, below are the steps I followed to get WALA working on macOS 10.13.2 (MacBook Pro). [Last Updated: Jan 2018 - previously verified for Windows 10 (Surface Pro 4, MacBook Pro Boot Camp), and Ubuntu 16.04 (VMWare on Windows 10 on Surface Pro 4)

  • You may need Maven if you don't already have it installed. On Mac and Linux, you can check with mvn -version. If you don't have it, (Mac) brew install maven (see Homebrew for install information if you don't have brew installed) or (Ubuntu) sudo apt-get install maven.

  • Install Eclipse Oxygen for RCP and RAP Developers and from the Packages Page.

    • WALA is now Oxygen-compliant.
    • Make sure that you download the correct 32- or 64-bit version based on the Java version you have, not the architecture you are running on. If you're not sure, open a Terminal or Command Prompt and check java -d32 -version and java -d64 -version. If you are running 32 or 64-bit Java, it will tell you for -d32 or -d64, and give you an Error if it does not support that JVM.
    • If you are on Ubuntu and don't have Java installed:
      • sudo add-apt-repository ppa:webupd8team/java
      • sudo apt update; sudo apt install oracle-java8-installer
      • sudo update-alternatives --config java (check Java installs and copy the path to your preferred one)
      • sudo nano /etc/environment
      • add at the bottom of this file: export JAVA_HOME=""; save and exit
      • source /etc/environment
      • echo $JAVA_HOME to confirm that the path to the above directory prints
  • Install Eclipse Web Developer Tools (search for "JSDT" then get the first hit) in Eclipse by going into the Help Menu and opening the Eclipse Marketplace (or Install New Software) and searching for it. Sometimes, you will find it bundled in a larger package like "Web Developer Tools" that isn't named "JavaScript Developer Tools" but contains it.

    • This is optional, but will get rid of the build errors on com.ibm.wala.ide.jdst.* projects.
  • git clone https://github.com/wala/WALA.git

  • cd into your WALA directory and run mvn clean verify -DskipTests=true -q. This will build with Maven, and pull the required files. If this does not run successfully, when you import WALA into Eclipse, you will be met with a bunch of errors and missing files.

    • Confirm that "dx.jar" is in com.ibm.wala.dalvik.test
    • Confirm that com.ibm.wala.core.testdata contains "JLex.jar"
  • Open com.ibm.wala.core/dat. Copy wala.properties.sample to wala.properties. Follow the instructions there and set the settings accordingly.

    • On my Mac: java_runtime_dir = /System/Library/Frameworks/JavaVM.framework/Classes (for old Mac) (for new Mac use: /Library/Java/JavaVirtualMachines/jdk<version>.jdk/Contents/Home/jre/lib)
    • On my Windows: C:/Program Files/Java/jdk1.8.0_131
    • On my Ubuntu: /usr/lib/jvm/java-8-oracle/jre/lib
  • Open com.ibm.wala.core.tests/dat. There should be a wala.examples.properties file; if not, copy the wala.examples.properties.sample file and rename it. Set the files accordingly (you may have to download GraphViz if you don't already have dot on your machine).

    • On my Mac:
      • pdfview_exe = /Applications/Preview.app/Contents/MacOS/Preview
      • dot_exe = /usr/local/bin/dot
    • On my Windows:
      • pdfview_exe = "C:/Program Files (x86)/Adobe/Acrobat Reader DC/Reader/AcroRd32.exe"
      • dot_exe = "C:/Program Files/graphviz-2.38/release/bin/dot.exe"
    • On my Ubuntu:
      • pdfview_exe = /usr/bin/evince (default viewer)
      • dot_exe = /usr/bin/dot (after sudo apt install graphviz)
  • Import WALA into Eclipse.

    • File -> Import
    • General -> Existing Projects into Workspace. Click Next.
    • Select Root Directory -> "Browse" button. Select your WALA directory.
    • The "Projects" field should populate with all the WALA directories. Select All, and click Finish.
    • Eclipse will import and build, which may take a few minutes.
  • Test WALA

    • Run example tests by going into Run -> Run Configurations
    • You'll see a bunch of existing tests under "Java Application" and "JUnit". If you followed the above instructions, these should all run.
    • If you have issues, check the Arguments tab; some of them can have paths hardcoded which cause errors. Other things to check for are whether the target files being analyzed are accessible (sometimes they expect them to be in the workspace folder root).
  • Experiment

    • You can now run analyses in WALA. For an idea of where to get started, see the JavaScript Frontend page.

Build Swift-WALA

  • git clone https://github.com/themaplelab/swift-wala

  • export SWIFT_WALA_HOME="<path/to/swift-wala>"

  • Import com.ibm.wala.cast.swift into Eclipse to build it or run ant in the com.ibm.wala.cast.swift directory if you are running headless

Build Swift for WALA Integration

The original Apple documentation has most of the steps needed to make Swift-WALA integration work, but some of the steps are slightly different for WALA integration capability. Please see Jeff's Install Notes for the detailed instructions. You must read Jeff's Install Notes first before attempting the Swift build and follow them alongside the Apple build directions, or the build will fail!

Working with Swift-WALA

This assumes that you have successfully built IBM/WALA, the uasys/swift "wala" branch, and uasys/swift-wala as per instructions and have successfully compiled and tested them.

Clone this wiki locally