Skip to content
paddybyers edited this page Dec 19, 2011 · 25 revisions

NOTE: the build setup will change shortly. If you are building the master branch, then use the instructions below. If you are building the bridge branch, which includes the java bridge, then go to the build-bridge instructions.

bridge will be merged with master shortly, at which time those updated instructions will become the default.

Set up the build environment

These instructions should work on Mac and Linux. Windows/cygwin is not investigated yet. If you get this to work, please send the details and it will be added to the wiki.

Get the latest Android SDK and NDK. You need to install support for the android-9 platform.

Install a recent version of Python 2.x.

Install Git.

Create a directory, we'll refer to as <work dir> that will contain all of the repositories you need, and cd into this directory.

Prerequisites - SSL

anode depends on the openssl libraries libssl.so and libcrypto.so. These libraries are present on the phone and also on the emulator, but aren't officially part of the ndk. We prefer to use the platform-provided versions of these libraries (instead of building a copy into anode) and so you have to install a copy of each of these libraries into the ndk.

There are two ways to do this.

Download the code and build the libraries

Starting in <work dir>, clone the repo:

git clone https://github.com/paddybyers/openssl-android.git

To build it:

cd openssl-android
ndk-build

The resulting libraries need to be copied or linked to the ndk library directory of the platform you are building for. For example, for Android 4.0, platform-14):

ln -s <work_dir>/anode/libnode/libs/armeabi/libssl.so <ndk dir>/platforms/android-14/arch-arm/usr/lib/
ln -s <work_dir>/anode/libnode/libs/armeabi/libcrypto.so <ndk dir>/platforms/android-14/arch-arm/usr/lib/

If you have an ndk install earlier than platform-14, or you are specifically building for an earlier platform version (eg android-9), then put the libraries into the corresponding lib directory.

Use prebuilt binaries

Prebuilt binary versions of the libraries are here:

https://github.com/downloads/paddybyers/openssl-android/libssl.so

https://github.com/downloads/paddybyers/openssl-android/libcrypto.so

These need to be placed in the ndk library directory.

Download the code

Create a directory that will contain all of the repositories you need. Starting in <work dir>, clone each of the repositories in turn.

git clone https://github.com/paddybyers/anode.git
git clone https://github.com/paddybyers/pty.git
git clone https://github.com/paddybyers/node.git

This last repository has a number of development branches with the Android port, but use the default, v0.6-android which is derived from node.js v0.6.

There is also a master-isolate-android branch which is derived from master. To use this, you will need to cd into the node directory and git checkout master-isolate-android. This will be used to track 0.7/0.8 developments but should be expected to be unstable.

Environment variables

NODE_PATH must point to the root of the node repo just created. NDK_MODULE_PATH must point to the immediate parent directory of each native android module.

export NODE_PATH=<work dir>/node
export NDK_MODULE_PATH=<work dir>:<work dir>/anode:<work dir>/node

Build the native code

cd anode/libnode
ndk-build

Once the native library is built, this needs to be included as an asset in the top-level Android project:

ln -s <work_dir>/anode/libnode/libs/armeabi/libjninode.so ../app/assets/libjninode.so

Or if you prefer (or on Windows), edit the top-level makefile to add an install target to perform the copy.

Set up the Eclipse Android projects

Open Eclipse and do:

File->Import->General->Existing projects into workspace

Point to the <work dir>/anode directory and import both the app and libnode projects.

You are now ready to build and run.

Clone this wiki locally