You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2011/02/03 00:13:05 UTC
[Couchdb Wiki] Update of "Installing_on_Android" by MattAdams
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The "Installing_on_Android" page has been changed by MattAdams.
http://wiki.apache.org/couchdb/Installing_on_Android?action=diff&rev1=14&rev2=15
--------------------------------------------------
+ = Installing CouchDB on Android (from source) =
+
+ == Caveats ==
+
* Please note that the following instructions for Android produce a build that mostly works but is not entirely bug free. Any help tracking down and resolving problems with couchjs would be greatly appreciated. From what I can tell these probably stem from ABI incompatibility with the version of Spidermonkey that is used.
- * As alluded to below, I was unable to get Couch to agree to link with the static Spidermonkey library. It would be preferable to have this done because it would remove the need for a separate file ({{{libmozjs.so}}}) and thus one less thing to go wrong.
- ----
+ * As alluded to below, I was unable to get Couch to agree to link with the static Spidermonkey library. This is due to the fact that C++ support in more recent official releases of the Google SDK/NDK is lacking. It would be preferable to link statically because it would remove the need for a separate file ({{{libmozjs.so}}}) and thus one less thing to go wrong (there are workarounds for the fact that we need to worry about dynamic linking with regards to the default couch query server, {{{couchjs}}}).
+ == Credits ==
+
+ A lot of the credit should go to [[https://github.com/apage43|Aaron Miller]] for doing the original port upon which these instructions are based. I would also like to thank Wes and Chris C. Coulson from #jsapi and Dale Harvey, davisp and rnewson from #couchdb. Thanks to everyone else who helped, too.
+
+ == Overview & Instructions ==
+
- The following build instructions are intended for Android 2.2.2 and were run on Debian Squeeze. The "scripts" below were run with Bash from a single directory I called {{{android-build}}}.
+ The following build instructions are intended for Android 2.2.2 and were run on Debian Squeeze. The "scripts" below were run with Bash from a single directory that I called {{{android-build}}}.
I used Java 1.5.0.22 to [[http://source.android.com/source/download.html|build Android from source]]. You will also [[http://developer.android.com/sdk/index.html|need an SDK]] (I used r08).
- A lot of the credit should go to [[https://github.com/apage43|Aaron Miller]] for doing the original port upon which these instructions are based as well as the good folks in #couchdb and #jsapi for their assistance, explanations and testing along the way.
-
See [[https://github.com/couchone/couch-android-launcher|couch-android-launcher]] and [[https://github.com/couchone/libcouch-android|libcouch-android]] for the end-user Android application that will use the package produced by this build. Please note that {{{com.your.namespace}}} used throughout these instructions will need to be replaced with something appropriate.
Supporting these builds are a number of helper scripts and patches: AndroidEnv, AndroidAgcc, AndroidCouchPatch, AndroidOtpPatch, AndroidReleasePatch, AndroidSdCardPatch
- = Step 1: Build Android from Source =
+ === Step 1: Build Android from Source ===
{{{
cd ~/software/android/sdk/sources
@@ -33, +40 @@
make -s
}}}
- = Step 2: Build cURL =
+ === Step 2: Build cURL ===
{{{
VERSION=7.20.0
@@ -76, +83 @@
make -s
}}}
- = Step 3: Build Mozilla NSPR & Spidermonkey =
+ === Step 3: Build Mozilla NSPR & Spidermonkey ===
The following instructions are based on the Fennec instructions [[https://wiki.mozilla.org/Mobile/Fennec/Android#JS.2FNSPR_only|for building JS/NSPR only]]. I also used [[http://ftp.mozilla.org/pub/mozilla.org/mobile/source/android-ndk-r4c-0moz3.tar.bz2|their Android NDK package]] for the builds.
- You can probably skip NSPR; I am not sure that it is really needed.
+ ==== Retrieve mozilla-current ===
- == NSPR ==
-
{{{
- HGREV=21e90d198613
+ HGREV=bb9089ae2322
[[ -f mozilla-central-$HGREV.tar.bz2 ]] || wget http://hg.mozilla.org/mozilla-central/archive/$HGREV.tar.bz2
-
+
rm -rf mozilla-central mozilla-central-$HGREV
tar -jxf mozilla-central-$HGREV.tar.bz2
ln -s mozilla-central-$HGREV mozilla-central
+ cd mozilla-central
+
+ # Use of __android_log_print and __android_log_write requires liblog.so from our
+ # toolchain. However, llog also has a dependency on libstdc++.so which our toolchain
+ # DOES NOT have so we need to substitute for something less Androidy (apologies).
+ patch -p1 < ../mozilla-central.patch
+ }}}
+
+ ==== NSPR ====
+
+ NSPR isn't technically required but it is heavily integrated into current versions of Spidermonkey and future versions will almost certainly require it.
+
+ Also, NSPR will compile against current NDKs but I choose to use the recommended one for the sake of consistency. The next step (Spidermonkey) most certainly requires the specified NDK version.
+
+ {{{
source $HOME/software/android/scripts/env
ANDROID_NDK=$HOME/software/android/android-ndk-r4c
- ANDROID_SDK=$HOME/software/android/sdk
cd mozilla-central/nsprpub
- make clean
- autoconf2.13
./configure \
--target=arm-android-eabi \
@@ -112, +129 @@
rm dist/lib/*so
}}}
- == Spidermonkey ==
+ ==== Spidermonkey ====
Be aware that Spidermonkey '''[[https://bugzilla.mozilla.org/show_bug.cgi?id=617115|will not]]''' build against Android NDK r5.
@@ -126, +143 @@
./configure \
--target=arm-android-eabi \
--with-android-ndk=$ANDROID_NDK \
- --with-android-platform=$ANDROID_NDK/build/platforms/android-8/arch-arm \
+ --with-android-sdk=$ANDROID_NDK/build/platforms/android-8 \
- --with-nspr-cflags=-I$(pwd)/../../nsprpub/dist/include/nspr \
- --with-nspr-libs="-L$(pwd)/../../nsprpub/dist/lib -lnspr4 -lplc4 -lplds4" \
+ --with-android-version=8 \
+ --disable-tests \
--disable-shared \
--enable-debug \
--disable-optimizations \
--enable-static \
+ --enable-endian=little \
+ --with-arm-kuser \
--enable-threadsafe \
- --enable-endian=little \
- --with-arm-kuser
+ --with-nspr-cflags=-I$(pwd)/../../nsprpub/dist/include/nspr \
+ --with-nspr-libs="-L$(pwd)/../../nsprpub/dist/lib -lnspr4 -lplc4 -lplds4"
make -s
+ ##
# Remove the shared lib to force Couch to link statically
- # (Could not get this to work -- even with patches to Couch autoconf files)
+ # (this isn't working due to Android toolchain difficulties)
+ #
#rm libmozjs.so
-
- # Rename lib
- mv libjs_static.a libmozjs.a
+ #mv libjs_static.a libmozjs.a
}}}
You should remove {{{--enable-debug}}} and {{{--disable-optimizations}}} for production builds.
- = Step 4: Build Erlang/OTP =
+ === Step 4: Build Erlang/OTP ===
{{{
rm -rf otp
@@ -158, +177 @@
cd otp
git checkout origin/android
- ##
+ ##
- # Patches:
- #
# 1) Add back in support for the "beam" binary
- #
# 2) Our default autoconf is 2.67 and we need to switch back to 2.59
- # for this operation
+ # for this operation
+ # 3) Environment differences between Android and UNIX (bin/sh)
#
patch -p1 < ../otp.patch
@@ -178, +195 @@
./otp_build release -a $(pwd)/../otp_rel
}}}
- = Step 5: Compile Couch =
+ === Step 5: Compile Couch ===
{{{
rm -rf couchdb
@@ -186, +203 @@
cd couchdb
git checkout 1.0.1
+ ##
- # Android Build Support from https://github.com/apage43/couchdb/tree/0.11.x-android
+ # 1) Android Build Support from https://github.com/apage43/couchdb/tree/0.11.x-android
+ # 2) Mozilla JS compatibility by chrisccoulson from jsapi@irc.mozilla.org
+ # 3) Fixes for Android by matt.adams-couch@radicaldynamic.com
+ #
patch -p1 < ../couchdb.patch
./bootstrap
@@ -196, +217 @@
ERL=$(pwd)/../otp/bootstrap/bin/erl \
ERLC=$(pwd)/../otp/bootstrap/bin/erlc \
- LDFLAGS="-L$(pwd)/../mozilla-central/nsprpub/dist/lib -lnspr4 -lplc4 -lplds4 -L$(pwd)/../mozilla-central/js/src -lmozjs" \
CC=agcc \
./configure \
--host=arm-eabi \
- --prefix=/sdcard/couch \
+ --prefix=/sdcard/groupinform/couch \
--with-android=$ANDROID_SDK/sources \
--with-android-curl=$(pwd)/../curl-7.20.0 \
--with-erlang=$(pwd)/../otp_rel/usr/include \
--with-js-include=$(pwd)/../mozilla-central/js/src/dist/include \
- --with-js-lib=$(pwd)/../mozilla-central/js/src
+ --with-js-lib="$(pwd)/../mozilla-central/js/src"
- make
+ make -s
make install
}}}
- = Step 6: Package for use on Android =
+ === Step 6: Package for use on Android ===
A lot of the code below was written simply to package things in a manner similar to Aaron's original layout of [[http://couchdb-android.s3.amazonaws.com/couch-erl-1.0.tgz|couch-erl-1.0.tgz]]. There is no need for a separate {{{dns-fix.tgz}}} or {{{fixup-1.0.tgz}}} with this package.
{{{
+ (to be updated)
- if [ -z "$1" ]; then
- echo "Give me a release number bub!"
- exit 1
- fi
-
- DATE=$(date +"%Y-%m-%d_%H-%M-%S")
- RELEASE="release-$DATE"
-
- mkdir -p $RELEASE/data/data/com.your.namespace/bin
-
- ##
- # Configure and package Erlang/OTP
- #
-
- cp -Rdp otp_rel otp_rel.package
-
- cd otp_rel.package
-
- ./Install -cross -sasl /data/data/com.your.namespace/erlang
- rm Install
-
- rm -rf erts-5.7.5/include/* misc releases usr
-
- cd lib
-
- libs_to_keep="crypto-1.6.4 erts-5.7.5 inets-5.3 kernel-2.13.5 sasl-2.1.9 ssl-3.10.8 stdlib-1.16.5 xmerl-1.2.4"
-
- mkdir backuplib
-
- for i in $libs_to_keep
- do
- mv $i backuplib/
- done
-
- mv backuplib ../
- rm -rf *
-
- mv ../backuplib/* .
- rmdir ../backuplib
-
- # Remove vestigal files
- rm -rf crypto-1.6.4/src/*.erl
- rm -rf erts-5.7.5/src/*.erl
- rm -rf inets-5.3/examples/* inets-5.3/src/*.erl
- rm -rf kernel-2.13.5/examples/* kernel-2.13.5/include/* kernel-2.13.5/src/*.erl
- rm -rf sasl-2.1.9/src/*.erl
- rm -rf ssl-3.10.8/examples/certs ssl-3.10.8/examples/ebin ssl-3.10.8/examples/src ssl-3.10.8/include/* ssl-3.10.8/pkix/*.erl ssl-3.10.8/src/*.erl
- rm -rf stdlib-1.16.5/examples/* stdlib-1.16.5/include/* stdlib-1.16.5/src/*.erl
- rm -rf xmerl-1.2.4/include xmerl-1.2.4/src
-
- cd ..
-
- # Update path to Android sh -- replace with a nice patch at some point
- for i in bin/erl bin/start bin/start_erl erts-5.7.5/bin/erl erts-5.7.5/bin/erl.src erts-5.7.5/bin/start erts-5.7.5/bin/start_erl.src erts-5.7.5/bin/start.src lib/inets-5.3/priv/bin/runcgi.sh
- do
- sed -e "s;#!/bin/sh;#!/system/bin/sh;" $i > $i.new
- mv $i.new $i
- chmod 755 $i
- done
-
- chmod -x erts-5.7.5/bin/start_erl.src erts-5.7.5/bin/start.src
-
- cd ..
-
- ##
- # Configure and package CouchDB
- #
-
- cp -Rdp /sdcard sdcard.package
-
- mv sdcard.package/couch/lib/couchdb/erlang/lib/couch-1.0.1 otp_rel.package/lib
- mv sdcard.package/couch/lib/couchdb/bin/couchjs $RELEASE/data/data/com.your.namespace/bin
- cp mozilla-central/js/src/libmozjs.so $RELEASE/data/data/com.your.namespace/bin
-
- cd sdcard.package/couch
-
- # Reflect updated locations and the Android environment
- patch -p1 < ../../../sdcard.patch
-
- cd ../../..
-
- ##
- # Finally move things into place
- #
-
- mv otp_rel.package $RELEASE/data/data/com.your.namespace/erlang
- mv sdcard.package $RELEASE/sdcard
-
- cd $RELEASE
-
- # DNS fixes from apage43's couchdb-android.s3.amazonaws.com/dns-fix.tgz
- touch data/data/com.your.namspace/erlang/bin/erl_inetrc
- patch -p1 < ../release.patch
-
- # Build ICU for whatever version of Android was compiled in ~/software/android/sdk/sources
- source $HOME/software/android/scripts/env
-
- agcc \
- -shared \
- -o data/data/com.your.namespace/couch_icu_driver.so ../couchdb/src/couchdb/priv/.libs/libcouch_icu_driver.a \
- -licuuc \
- -licudata \
- -licui18n \
- -L$HOME/projects/couch/android-build/otp_rel/erts-5.7.5/bin \
- -lbeam
-
- ##
- # Archive the release
- #
- tar -czf ../release-$1.tgz *
-
- cd ..
}}}