Skip to content

Running on the edge

dbradberry edited this page Jan 14, 2013 · 14 revisions

If you want to write Mercury modules, you may want the latest code. We work on the develop branch on Github, which is often newer than the most recent release.

Preparation

If you want to run Mercury from Github, there are a few things that you will have to set up first. In addition to the normal requirements for Mercury, you will need to install:

  • GNU Make;
  • the Android SDK (available here); and
  • the Android NDK (available here).

You should also set the following environment variables:

  • add to your PATH /path/to/mercury/bin
  • add to your PYTHONPATH /path/to/mercury/src and /path/to/mercury/test
  • set SDK to /path/to/android-sdk-linux/platforms/android-16/android.jar

You will also need javac and dx available on your path. dx can be found under platform-tools/ in the Android SDK.

Java Version

To compile Java sources for Android, you will need jdk6 installed and configured as the default version for javac. If you use jdk7, the generated class files will not be compatible with the Android dx tool.

Starting Mercury

Once you have set up your environment, you should be able to start Mercury using the normal command:

mercury console connect

Note: the behaviour is undefined if you have Mercury installed on your system from a distribution. You may want to adjust your PYTHONPATH to exclude installed Mercury or use virtualenv to create an isolated environment.

Building APKs

Some Mercury commands deliver an APK file to the Agent. These are built from the various Java source files in the src/mwr/droidhg/modules/ tree.

A Makefile is provided to automate building of these sources. To invoke it, run the apks target from the Mercury root directory:

make apks

This should be run every time you make a change to a Java file or if you have just started using the development version and these APK files have not yet been generated.

Building Native Libraries

Some Mercury commands use a small piece of Native code, to get lower level access to the underlying system than Java allows. These are typically provided with a C/C++ implementation in the src/mwr/droidhg/modules/ tree.

A Makefile is provided to automate building of these sources. To invoke it, run the native-libraries target from the Mercury root directory:

make native-libraries

This should be run every time you make a change to a native file or if you have just started using the development version and these native sources have not yet been compiled.

Clone this wiki locally