Merge pull request #1806 from nghttp2/update-android-build-doc
Update android build documentation
This commit is contained in:
commit
0363606924
|
@ -32,7 +32,7 @@ ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
dist_doc_DATA = README.rst
|
dist_doc_DATA = README.rst
|
||||||
|
|
||||||
EXTRA_DIST = nghttpx.conf.sample proxy.pac.sample android-config android-make \
|
EXTRA_DIST = nghttpx.conf.sample proxy.pac.sample android-config android-env \
|
||||||
Dockerfile.android \
|
Dockerfile.android \
|
||||||
cmakeconfig.h.in \
|
cmakeconfig.h.in \
|
||||||
CMakeLists.txt \
|
CMakeLists.txt \
|
||||||
|
|
|
@ -23,25 +23,16 @@
|
||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
if [ -z "$ANDROID_HOME" ]; then
|
. ./android-env
|
||||||
echo 'No $ANDROID_HOME specified.'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PREFIX="$ANDROID_HOME"/usr/local
|
|
||||||
TOOLCHAIN="$ANDROID_HOME"/toolchain
|
|
||||||
PATH="$TOOLCHAIN"/bin:"$PATH"
|
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
--disable-shared \
|
--disable-shared \
|
||||||
--host=arm-linux-androideabi \
|
--host=$TARGET \
|
||||||
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
||||||
--with-xml-prefix="$PREFIX" \
|
|
||||||
--without-libxml2 \
|
--without-libxml2 \
|
||||||
--disable-python-bindings \
|
--disable-python-bindings \
|
||||||
--disable-examples \
|
--disable-examples \
|
||||||
--disable-threads \
|
--disable-threads \
|
||||||
CC="$TOOLCHAIN"/bin/arm-linux-androideabi-clang \
|
|
||||||
CXX="$TOOLCHAIN"/bin/arm-linux-androideabi-clang++ \
|
|
||||||
CPPFLAGS="-fPIE -I$PREFIX/include" \
|
CPPFLAGS="-fPIE -I$PREFIX/include" \
|
||||||
PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
|
PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
|
||||||
LDFLAGS="-fPIE -pie -L$PREFIX/lib"
|
LDFLAGS="-fPIE -pie -L$PREFIX/lib"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# nghttp2 - HTTP/2 C Library
|
# nghttp2 - HTTP/2 C Library
|
||||||
#
|
#
|
||||||
# Copyright (c) 2013 Tatsuhiro Tsujikawa
|
# Copyright (c) 2022 nghttp2 contributors
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
# a copy of this software and associated documentation files (the
|
# a copy of this software and associated documentation files (the
|
||||||
|
@ -23,11 +23,18 @@
|
||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
if [ -z "$ANDROID_HOME" ]; then
|
if [ -z "$NDK" ]; then
|
||||||
echo 'No $ANDROID_HOME specified.'
|
echo 'No $NDK specified.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
TOOLCHAIN=$ANDROID_HOME/toolchain
|
|
||||||
PATH=$TOOLCHAIN/bin:$PATH
|
|
||||||
|
|
||||||
make "$@"
|
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
|
||||||
|
export TARGET=aarch64-linux-android
|
||||||
|
export API=33
|
||||||
|
export AR=$TOOLCHAIN/bin/llvm-ar
|
||||||
|
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
|
||||||
|
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
|
||||||
|
export LD=$TOOLCHAIN/bin/ld
|
||||||
|
export RANDLIB=$TOOLCHAIN/bin/llvm-ranlib
|
||||||
|
export STRIP=$TOOLCHAIN/bin/llvm-strip
|
||||||
|
export PREFIX=$NDK/usr/local
|
|
@ -2,49 +2,39 @@ Building Android binary
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
In this article, we briefly describe how to build Android binary using
|
In this article, we briefly describe how to build Android binary using
|
||||||
`Android NDK <https://developer.android.com/ndk/index.html>`_
|
`Android NDK <https://developer.android.com/ndk>`_ cross-compiler on
|
||||||
cross-compiler on Debian Linux.
|
Debian Linux.
|
||||||
|
|
||||||
The easiest way to build android binary is use Dockerfile.android.
|
The easiest way to build android binary is use Dockerfile.android.
|
||||||
See Dockerfile.android for more details. If you cannot use
|
See Dockerfile.android for more details. If you cannot use
|
||||||
Dockerfile.android for whatever reason, continue to read the rest of
|
Dockerfile.android for whatever reason, continue to read the rest of
|
||||||
this article.
|
this article.
|
||||||
|
|
||||||
We offer ``android-config`` and ``android-make`` scripts to make the
|
We offer ``android-config`` script to make the build easier. To make
|
||||||
build easier. To make these script work, NDK toolchain must be
|
the script work, NDK directory must be set to ``NDK`` environment
|
||||||
installed in the following way. First, let us introduce
|
variable. NDK directory is the directory where NDK is unpacked:
|
||||||
``ANDROID_HOME`` environment variable. We need to install toolchain
|
|
||||||
under ``$ANDROID_HOME/toolchain``. An user can freely choose the path
|
|
||||||
for ``ANDROID_HOME``. For example, to install toolchain under
|
|
||||||
``$ANDROID_HOME/toolchain``, do this in the the directory where NDK is
|
|
||||||
unpacked:
|
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
$ build/tools/make_standalone_toolchain.py \
|
$ unzip android-ndk-$NDK_VERSION-linux.zip
|
||||||
--arch arm --api 16 --stl gnustl \
|
$ cd android-ndk-$NDK_VERSION
|
||||||
--install-dir $ANDROID_HOME/toolchain
|
$ export NDK=$PWD
|
||||||
|
|
||||||
The API level (``--api``) is not important here because we don't use
|
|
||||||
Android specific C/C++ API.
|
|
||||||
|
|
||||||
The dependent libraries, such as OpenSSL, libev, and c-ares should be
|
The dependent libraries, such as OpenSSL, libev, and c-ares should be
|
||||||
built with the toolchain and installed under
|
built with the same NDK toolchain and installed under
|
||||||
``$ANDROID_HOME/usr/local``. We recommend to build these libraries as
|
``$NDK/usr/local``. We recommend to build these libraries as static
|
||||||
static library to make the deployment easier. libxml2 support is
|
library to make the deployment easier. libxml2 support is currently
|
||||||
currently disabled.
|
disabled.
|
||||||
|
|
||||||
Although zlib comes with Android NDK, it seems not to be a part of
|
Although zlib comes with Android NDK, it seems not to be a part of
|
||||||
public API, so we have to built it for our own. That also provides us
|
public API, so we have to built it for our own. That also provides us
|
||||||
proper .pc file as a bonus.
|
proper .pc file as a bonus.
|
||||||
|
|
||||||
Before running ``android-config`` and ``android-make``,
|
Before running ``android-config``, ``NDK`` environment variable must
|
||||||
``ANDROID_HOME`` environment variable must be set to point to the
|
be set to point to the correct path.
|
||||||
correct path. Also add ``$ANDROID_HOME/toolchain/bin`` to ``PATH``:
|
|
||||||
|
|
||||||
.. code-block:: text
|
You need to set ``NGHTTP2`` environment variable to the absolute path
|
||||||
|
to the source directory of nghttp2.
|
||||||
$ export PATH=$PATH:$ANDROID_HOME/toolchain/bin
|
|
||||||
|
|
||||||
To configure OpenSSL, use the following script:
|
To configure OpenSSL, use the following script:
|
||||||
|
|
||||||
|
@ -52,39 +42,36 @@ To configure OpenSSL, use the following script:
|
||||||
|
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -z "$ANDROID_HOME" ]; then
|
. $NGHTTP2/android-env
|
||||||
echo 'No $ANDROID_HOME specified.'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PREFIX=$ANDROID_HOME/usr/local
|
|
||||||
TOOLCHAIN=$ANDROID_HOME/toolchain
|
|
||||||
PATH=$TOOLCHAIN/bin:$PATH
|
|
||||||
|
|
||||||
export CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi-
|
export ANDROID_NDK_HOME=$NDK
|
||||||
./Configure --prefix=$PREFIX android
|
export PATH=$TOOLCHAIN/bin:$PATH
|
||||||
|
|
||||||
And run ``make install_sw`` to build and install without
|
./Configure no-shared --prefix=$PREFIX android-arm64
|
||||||
documentation.
|
|
||||||
|
|
||||||
We cannot compile libev without modification. Apply `this patch
|
And run the following script to build and install without
|
||||||
<https://gist.github.com/tatsuhiro-t/48c45f08950f587180ed>`_ before
|
documentation:
|
||||||
configuring libev. This patch is for libev-4.19. After applying the
|
|
||||||
patch, to configure libev, use the following script:
|
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -z "$ANDROID_HOME" ]; then
|
. $NGHTTP2/android-env
|
||||||
echo 'No $ANDROID_HOME specified.'
|
|
||||||
exit 1
|
export PATH=$TOOLCHAIN/bin:$PATH
|
||||||
fi
|
|
||||||
PREFIX=$ANDROID_HOME/usr/local
|
make install_sw
|
||||||
TOOLCHAIN=$ANDROID_HOME/toolchain
|
|
||||||
PATH=$TOOLCHAIN/bin:$PATH
|
To configure libev, use the following script:
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. $NGHTTP2/android-env
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
--host=arm-linux-androideabi \
|
--host=$TARGET \
|
||||||
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
||||||
--prefix=$PREFIX \
|
--prefix=$PREFIX \
|
||||||
--disable-shared \
|
--disable-shared \
|
||||||
|
@ -100,41 +87,26 @@ To configure c-ares, use the following script:
|
||||||
|
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
if [ -z "$ANDROID_HOME" ]; then
|
. $NGHTTP2/android-env
|
||||||
echo 'No $ANDROID_HOME specified.'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PREFIX=$ANDROID_HOME/usr/local
|
|
||||||
TOOLCHAIN=$ANDROID_HOME/toolchain
|
|
||||||
PATH=$TOOLCHAIN/bin:$PATH
|
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
--host=arm-linux-androideabi \
|
--host=$TARGET \
|
||||||
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
||||||
--prefix=$PREFIX \
|
--prefix=$PREFIX \
|
||||||
--disable-shared
|
--disable-shared
|
||||||
|
|
||||||
|
And run ``make install`` to build and install.
|
||||||
|
|
||||||
To configure zlib, use the following script:
|
To configure zlib, use the following script:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
if [ -z "$ANDROID_HOME" ]; then
|
. $NGHTTP2/android-env
|
||||||
echo 'No $ANDROID_HOME specified.'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PREFIX=$ANDROID_HOME/usr/local
|
|
||||||
TOOLCHAIN=$ANDROID_HOME/toolchain
|
|
||||||
PATH=$TOOLCHAIN/bin:$PATH
|
|
||||||
|
|
||||||
HOST=arm-linux-androideabi
|
export HOST=$TARGET
|
||||||
|
|
||||||
CC=$HOST-gcc \
|
|
||||||
AR=$HOST-ar \
|
|
||||||
LD=$HOST-ld \
|
|
||||||
RANLIB=$HOST-ranlib \
|
|
||||||
STRIP=$HOST-strip \
|
|
||||||
./configure \
|
./configure \
|
||||||
--prefix=$PREFIX \
|
--prefix=$PREFIX \
|
||||||
--libdir=$PREFIX/lib \
|
--libdir=$PREFIX/lib \
|
||||||
|
@ -144,7 +116,7 @@ To configure zlib, use the following script:
|
||||||
And run ``make install`` to build and install.
|
And run ``make install`` to build and install.
|
||||||
|
|
||||||
After prerequisite libraries are prepared, run ``android-config`` and
|
After prerequisite libraries are prepared, run ``android-config`` and
|
||||||
then ``android-make`` to compile nghttp2 source files.
|
then ``make`` to compile nghttp2 source files.
|
||||||
|
|
||||||
If all went well, application binaries, such as nghttpx, are created
|
If all went well, application binaries, such as nghttpx, are created
|
||||||
under src directory. Strip debugging information from the binary
|
under src directory. Strip debugging information from the binary
|
||||||
|
@ -152,4 +124,4 @@ using the following command:
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
$ arm-linux-androideabi-strip src/nghttpx
|
$ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip src/nghttpx
|
||||||
|
|
Loading…
Reference in New Issue