summaryrefslogtreecommitdiff
path: root/Documentation/guides/android.rst
blob: aedb6931b2ea1d8f8e61fcadc92371947aa8b217 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
.. SPDX-License-Identifier: CC-BY-SA-4.0

Android
=======

Android is quite different from a traditional Linux distribution
and comes with its own set of libraries.

This guide targets libcamera developers who want to build-test the Android support.

Cross-compilation
-----------------

.. code-block:: ini

   [constants]
   # TODO: edit these paths for your own locations
   ndk = '/mnt/work/aosp/android-ndk-r26b'

   # see: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#target-selection
   triple = 'x86_64-linux-android'
   android_api_level = '33'
   target = triple + android_api_level

   toolchain = ndk / 'toolchains/llvm/prebuilt/linux-x86_64/bin'

   [properties]
   cpp_stdlib = 'vndk'

   [built-in options]
   cpp_args = ['-target', target]

   [binaries]
   c = toolchain / target + '-clang'
   cpp = toolchain / target + '-clang++'
   ar = toolchain / 'llvm-ar'
   strip = toolchain / 'llvm-strip'
   config = toolchain / 'llvm-config'

   [host_machine]
   system = 'linux'
   cpu_family ='x86_64'
   cpu = 'amd64'
   endian = 'little'

1. Edit the ``ndk`` constant to point to your system's NDK location

2. Save the above cross file in ``~/.local/share/meson/cross/x86_64-linux-android.txt``.

.. code::

   meson setup --cross-file=x86_64-linux-android.txt --prefix=/ -Dandroid=enabled -Dandroid_platform=generic -Dpipelines=simple build; meson compile -C build