diff --git a/README.md b/README.md
index 53d5e1fc..78c6921a 100644
--- a/README.md
+++ b/README.md
@@ -140,6 +140,25 @@ meson setup build-phone -Dprofile_automotive=false
meson setup build-rk3588 --cross-file cross/rk3588.ini
```
+### Packaging
+
+Each optional part has a Meson feature option of its name: `wayland`, `skia`, `vulkan`, `gl`,
+`dmabuf_codec`, `gstreamer`, `ffmpeg`, `drm_cxx`, `alsa`, `pipewire`, `libcamera`, `sdbus`,
+`secret`, `crypto`. The default, `auto`, builds a part when its dependencies are found;
+`enabled` makes a missing dependency a configure error, and `disabled` leaves the part out
+whatever is installed. `meson configure build` lists them.
+
+`jni.h` is required. It comes from the JDK whose `java` is on `PATH`, and a4l records that
+JDK's `javac` and `libjvm.so` paths for `--vm=jvm`. A build with no JDK, or one whose
+build machine is not where a4l will run, gives the headers and the paths itself, and can
+turn off the search for an AOSP checkout's `android.jar`:
+
+```sh
+meson setup build --buildtype=plain \
+ -Djni_include=/path/to/jni-headers -Dlibjvm=libjvm.so -Dandroid_jar=none \
+ -Dskia=enabled -Dskia_prefix=/path/to/skia -Dvulkan=enabled -Dwayland=enabled
+```
+
## On an ivi-shell compositor
An ivi-shell compositor (Weston's `ivi-shell.so` with a layer-manager controller) shows a
diff --git a/framework/meson.build b/framework/meson.build
index 5dc74d66..74c5c53b 100644
--- a/framework/meson.build
+++ b/framework/meson.build
@@ -14,8 +14,8 @@
framework_boot_classes = disabler()
framework_default_dir = ''
-javac_prog = have_jni ? find_program(java_home / 'bin' / 'javac', required : false) \
- : disabler()
+javac_prog = (have_jni and java_home != '') \
+ ? find_program(java_home / 'bin' / 'javac', required : false) : disabler()
if javac_prog.found()
# Discover every .java across both layers (absolute paths). Adding or removing a
@@ -56,7 +56,11 @@ endif
framework_android_jar = ''
fs = import('fs')
android_jar_src = get_option('android_jar')
-if android_jar_src == ''
+# `none`: look for no android.jar, in no AOSP checkout. For a build that must not pick up
+# what happens to be on the build machine.
+if android_jar_src == 'none'
+ android_jar_src = '/nonexistent/android.jar'
+elif android_jar_src == ''
aosp_root = run_command('sh', '-c', 'echo -n "${ACL_AOSP_ROOT:-/mnt/dev/aosp}"',
check : false).stdout()
android_jar_src = aosp_root / 'prebuilts' / 'sdk' / '33' / 'public' / 'android.jar'
diff --git a/meson.build b/meson.build
index 533ff092..b22d9e5f 100644
--- a/meson.build
+++ b/meson.build
@@ -31,8 +31,23 @@ jni_dep = declare_dependency() # jni.h headers only (no libjvm link)
jvm_link_dep = declare_dependency() # actual -ljvm link, for standalone JVM tools only
have_libjvm = false
java_home = ''
+# -Djni_include=
: take jni.h (and jni_md.h, in or /linux) from there and
+# look for no JDK. That is all the ART backend needs of one, and what a build with no JDK
+# on the build machine, or a cross build, can give. No javac is found this way, so the
+# JVM-side framework classes are not built.
+jni_include = get_option('jni_include')
+if jni_include != ''
+ if not import('fs').exists(jni_include / 'jni.h')
+ error('-Djni_include=' + jni_include + ': no jni.h there')
+ endif
+ jni_dep = declare_dependency(
+ compile_args : ['-I' + jni_include, '-I' + jni_include / 'linux'],
+ )
+ have_jni = true
+ message('JNI headers from -Djni_include=' + jni_include + ' (no JDK looked for)')
+endif
java_prog = find_program('java', required : false)
-if java_prog.found()
+if jni_include == '' and java_prog.found()
jprops = run_command(java_prog, '-XshowSettings:properties', '-version',
check : false).stderr()
parts = jprops.split('java.home = ')
@@ -70,17 +85,28 @@ if java_home != '' and import('fs').exists(java_home / 'include' / 'jni.h')
endif
endif
+# Not optional, whatever the comments above say of the JVM backend alone: the service
+# bridges and the ART backend include jni.h, and a build without it stops at the first of
+# them. Say so here.
+if not have_jni
+ error('a4l needs jni.h: a JDK whose `java` is on PATH (with lib/server/libjvm.so), or -Djni_include=')
+endif
+
+# What follows is optional, and each part has a feature option of its name (meson.options):
+# `auto` builds it when its dependencies are found, `enabled` makes a missing dependency an
+# error, `disabled` leaves it out whatever is installed.
+#
# audio/ backend: PipeWire when present (the AudioTrack sink actually plays);
# otherwise audio/ builds with only the counting/null sink (headless, deterministic).
-pw_dep = dependency('libpipewire-0.3', required : false)
+pw_dep = dependency('libpipewire-0.3', required : get_option('pipewire'))
have_pipewire = pw_dep.found()
# ALSA: the device backend for a system with no PipeWire (an embedded board). alsa-lib is
# LGPL-2.1, linked dynamically. Chosen at run time; see make_device_sink() in audio/audio.cpp.
-alsa_dep = dependency('alsa', required : false)
+alsa_dep = dependency('alsa', required : get_option('alsa'))
have_alsa = alsa_dep.found()
# libcamera: the host's cameras behind android.hardware.Camera (svc/camera). LGPL-2.1, linked
# dynamically. Without it a4l reports no camera.
-libcamera_dep = dependency('libcamera', required : false)
+libcamera_dep = dependency('libcamera', required : get_option('libcamera'))
have_libcamera = libcamera_dep.found()
# FFmpeg (LGPL, dynamic link — permitted per plan.md license policy): decodes SoundPool
@@ -89,20 +115,20 @@ have_libcamera = libcamera_dep.found()
# FFmpeg's transitive system OpenSSL never enters the global symbol scope (it would otherwise
# interpose on AOSP conscrypt's BoringSSL and crash NativeCrypto.).
ff_full = [
- dependency('libavcodec', required : false),
- dependency('libavformat', required : false),
- dependency('libavutil', required : false),
- dependency('libswresample', required : false),
+ dependency('libavcodec', required : get_option('ffmpeg')),
+ dependency('libavformat', required : get_option('ffmpeg')),
+ dependency('libavutil', required : get_option('ffmpeg')),
+ dependency('libswresample', required : get_option('ffmpeg')),
]
have_ffmpeg = ff_full[0].found() and ff_full[1].found() and ff_full[2].found() and ff_full[3].found()
# GStreamer (LGPL-2.1-or-later, dynamic link): the video decoder where FFmpeg has no hardware
# one. The highest-ranked installed decoder for the codec is used, so the SoC vendor's
# decoder is reached with no vendor code here. Built only when all four libs are present.
gst_full = [
- dependency('gstreamer-1.0', version : '>=1.16', required : false),
- dependency('gstreamer-app-1.0', required : false),
- dependency('gstreamer-video-1.0', required : false),
- dependency('gstreamer-allocators-1.0', required : false),
+ dependency('gstreamer-1.0', version : '>=1.16', required : get_option('gstreamer')),
+ dependency('gstreamer-app-1.0', required : get_option('gstreamer')),
+ dependency('gstreamer-video-1.0', required : get_option('gstreamer')),
+ dependency('gstreamer-allocators-1.0', required : get_option('gstreamer')),
]
have_gst = gst_full[0].found() and gst_full[1].found() and gst_full[2].found() and gst_full[3].found()
# dmabuf-codec (MIT): hardware decode engines behind one interface, each handing out its
@@ -112,7 +138,7 @@ have_gst = gst_full[0].found() and gst_full[1].found() and gst_full[2].found() a
# without it the GStreamer and FFmpeg engines remain.
dmabuf_codec_dep = dependency('dmabuf-codec',
fallback : ['dmabuf-codec', 'dmabuf_codec_dep'],
- required : false,
+ required : get_option('dmabuf_codec'),
default_options : ['tests=disabled', 'werror=false'])
have_dmabuf_codec = dmabuf_codec_dep.found()
ff_dep = []
@@ -131,12 +157,14 @@ endif
have_wcs = false
wcs_scanner = disabler()
wcs_dep = declare_dependency() # empty no-op placeholder (wl/ header include added below)
-wayland_dep = dependency('wayland-client', required : false)
-wayland_cursor_dep = dependency('wayland-cursor', required : false) # wl::CursorManager (set_cursor)
-wayland_server_dep = dependency('wayland-server', required : false) # test compositor only
-xkbcommon_dep = dependency('xkbcommon', required : false) # wcs KeyboardHandler (keymap + keysyms)
-wl_scanner_dep = dependency('wayland-scanner', required : false)
-wp_dep = dependency('wayland-protocols', required : false)
+wayland_opt = get_option('wayland')
+wayland_dep = dependency('wayland-client', required : wayland_opt)
+wayland_cursor_dep = dependency('wayland-cursor', required : wayland_opt) # wl::CursorManager (set_cursor)
+# The test compositor only: never required, and left out with the presenter.
+wayland_server_dep = dependency(wayland_opt.disabled() ? '' : 'wayland-server', required : false)
+xkbcommon_dep = dependency('xkbcommon', required : wayland_opt) # wcs KeyboardHandler (keymap + keysyms)
+wl_scanner_dep = dependency('wayland-scanner', required : wayland_opt)
+wp_dep = dependency('wayland-protocols', required : wayland_opt)
fs = import('fs')
# wcs is resolved in three steps, first hit wins:
# 1. -Dwcs_root= an out-of-tree checkout
@@ -190,6 +218,9 @@ if wayland_dep.found() and wl_scanner_dep.found() and wp_dep.found() and xkbcomm
endif
endif
endif
+if wayland_opt.enabled() and not have_wcs
+ error('-Dwayland=enabled: no wayland-cxx-scanner (a built checkout at -Dwcs_root, or the wrap)')
+endif
if have_wcs
# wcs's wl/ framework is header-only; pass its include dir as a -I compile arg (like
# jni_dep for the external JDK) — an absolute out-of-tree path can't go through
@@ -212,8 +243,9 @@ endif
# wcs's examples do. skia_prefix option, else auto-detect the pinned standalone install.
have_skia = false
skia_dep = declare_dependency() # empty no-op placeholder
-skia_prefix = get_option('skia_prefix')
-if skia_prefix == ''
+skia_opt = get_option('skia')
+skia_prefix = skia_opt.disabled() ? '' : get_option('skia_prefix')
+if skia_prefix == '' and not skia_opt.disabled()
# No vendored Skia and no pkg-config for it, so the prefix is searched for. Order:
# $ACL_SKIA_PREFIX, then the conventional install locations. Build one with wcs's
# scripts/build-skia.sh (chrome/m150 — the shared pin, see third_party/skia/METADATA).
@@ -275,6 +307,10 @@ if skia_prefix != '' and fs.exists(skia_prefix / 'include' / 'core' / 'SkCanvas.
endif
endif
+if skia_opt.enabled() and not have_skia
+ error('-Dskia=enabled: no Skia prefix with include/core/SkCanvas.h and lib/*.a (-Dskia_prefix)')
+endif
+
# gfx/ GPU present path (P2.4): Skia's Ganesh Vulkan backend rendering into dma-buf-
# exported VkImages, patterned after wcs's skia-vulkan-dmabuf example (ADR-4). The pinned
# Skia is built skia_use_vulkan=true, so this needs the system Vulkan + vulkan-hpp, plus
@@ -287,7 +323,7 @@ endif
# heavy/irrelevant features off.
drm_cxx_dep = dependency('drm-cxx',
fallback : ['drm-cxx', 'drm_cxx_dep'],
- required : false,
+ required : get_option('drm_cxx'),
default_options : ['tests=false', 'vulkan=false', 'examples=false', 'benchmarks=false'])
have_drm_cxx = drm_cxx_dep.found()
if have_drm_cxx
@@ -297,13 +333,19 @@ endif
have_vulkan = false
vulkan_dep = declare_dependency()
libdrm_dep = declare_dependency()
+vulkan_opt = get_option('vulkan')
+if vulkan_opt.enabled() and not have_skia
+ error('-Dvulkan=enabled: the Vulkan present path is Skia\'s, and there is no Skia (-Dskia_prefix)')
+endif
if have_skia
- vulkan_dep = dependency('vulkan', required : false)
- libdrm_dep = dependency('libdrm', required : false) # drm_fourcc.h format/modifier fourccs
+ vulkan_dep = dependency('vulkan', required : vulkan_opt)
+ libdrm_dep = dependency('libdrm', required : vulkan_opt) # drm_fourcc.h format/modifier fourccs
# vulkan-hpp (vulkan/vulkan.hpp) rides on the same package but isn't always installed.
if vulkan_dep.found() and libdrm_dep.found() and cxx.has_header('vulkan/vulkan.hpp', dependencies : vulkan_dep)
have_vulkan = true
message('gfx/ Ganesh Vulkan present path enabled (vulkan + vulkan-hpp + libdrm)')
+ elif vulkan_opt.enabled()
+ error('-Dvulkan=enabled: vulkan/vulkan.hpp (vulkan-hpp) is not installed')
endif
endif
@@ -317,12 +359,13 @@ egl_dep = declare_dependency()
glesv2_dep = declare_dependency()
gbm_dep = declare_dependency()
wl_egl_dep = declare_dependency()
-gl_libdrm_dep = dependency('libdrm', required : false)
+gl_opt = get_option('gl')
+gl_libdrm_dep = dependency('libdrm', required : gl_opt)
if gl_libdrm_dep.found()
- egl_dep = dependency('egl', required : false)
- glesv2_dep = dependency('glesv2', required : false)
- gbm_dep = dependency('gbm', required : false)
- wl_egl_dep = dependency('wayland-egl', required : false) # wl_egl_window (Wayland backend)
+ egl_dep = dependency('egl', required : gl_opt)
+ glesv2_dep = dependency('glesv2', required : gl_opt)
+ gbm_dep = dependency('gbm', required : gl_opt)
+ wl_egl_dep = dependency('wayland-egl', required : gl_opt) # wl_egl_window (Wayland backend)
if egl_dep.found() and glesv2_dep.found() and gbm_dep.found() and wl_egl_dep.found()
have_gl = true
message('gfx/ host GL device enabled (EGL + GLESv2 + gbm + wayland-egl — GLSurfaceView path)')
@@ -333,7 +376,8 @@ endif
# ConnMan on device, NetworkManager elsewhere) is translated to android.net.
# ConnectivityManager state. sdbus-c++ (LGPL-2.1, dynamically linked = policy-OK)
# is the D-Bus client. When absent, svc/net is the Null backend (offline default).
-sdbus_dep = dependency('sdbus-c++', required : false)
+# The code uses the strong types of the 2.x API (sdbus::ServiceName and the like).
+sdbus_dep = dependency('sdbus-c++', version : '>= 2.0.0', required : get_option('sdbus'))
have_sdbus = sdbus_dep.found()
net_backend = get_option('net_backend')
if have_sdbus
@@ -344,7 +388,7 @@ endif
# (libsecret -> gnome-keyring / KWallet, LGPL-2.1 dynamic = policy-OK). Key MATERIAL persists in the
# login keyring (encrypted at rest, keyring-unlock as the user-auth gate); the crypto itself runs
# in-process via conscrypt. GObject/glib based (not sdbus). Absent -> in-memory Null backend.
-secret_dep = dependency('libsecret-1', required : false)
+secret_dep = dependency('libsecret-1', required : get_option('secret'))
have_secret = secret_dep.found()
if have_secret
message('svc/keystore Secret Service backend enabled (libsecret ' + secret_dep.version() + ')')
@@ -355,7 +399,7 @@ endif
# loaded privately at run time (src/pkg/crypto_dl.cpp), because linking it would shadow the
# BoringSSL that host ART loads into the same process. Absent at either time -> the verifier
# reports "unavailable" and checks nothing, which `--verify=require` treats as a refusal.
-crypto_dep = dependency('libcrypto', version : '>= 3.0', required : false)
+crypto_dep = dependency('libcrypto', version : '>= 3.0', required : get_option('crypto'))
have_libcrypto = crypto_dep.found()
if have_libcrypto
message('pkg APK signature verification enabled (libcrypto ' + crypto_dep.version() + ')')
@@ -400,12 +444,20 @@ conf.set10('ACL_NET_NETWORKMANAGER', have_sdbus and (net_backend == 'auto' or ne
conf.set10('ACL_NET_CONNMAN', have_sdbus and (net_backend == 'auto' or net_backend == 'connman'))
# javac matched to the detected libjvm (same java_home), for the DEX->JVM
# converter. Empty when no JDK; the converter then needs an explicit path.
-conf.set('ACL_JAVAC',
- have_jni ? '"' + java_home / 'bin' / 'javac' + '"' : '""')
+# -Djavac= and -Dlibjvm= name them instead: what is detected is a path on the build
+# machine, which is not where a packaged a4l runs. `libjvm.so` leaves it to the loader.
+baked_javac = get_option('javac')
+if baked_javac == '' and have_jni and java_home != ''
+ baked_javac = java_home / 'bin' / 'javac'
+endif
+conf.set('ACL_JAVAC', '"' + baked_javac + '"')
# Path to the host libjvm.so, dlopen()ed with RTLD_LOCAL by the --vm=jvm backend so its
# HotSpot symbols stay out of the global scope. Empty when no JDK.
-conf.set('ACL_JVM_LIBJVM',
- jvm_libjvm_path != '' ? '"' + jvm_libjvm_path + '"' : '""')
+baked_libjvm = get_option('libjvm')
+if baked_libjvm == ''
+ baked_libjvm = jvm_libjvm_path
+endif
+conf.set('ACL_JVM_LIBJVM', '"' + baked_libjvm + '"')
# Public config header consumed across modules.
configure_file(
diff --git a/meson.options b/meson.options
index 17433e8c..b8898baf 100644
--- a/meson.options
+++ b/meson.options
@@ -34,7 +34,7 @@ option(
'android_jar',
type : 'string',
value : '',
- description : 'Path to the api-33 public android.jar (stub API, ADR-0002 base boot-classpath layer beneath the acl shims). Empty tries $ACL_AOSP_ROOT/prebuilts/sdk/33/public/android.jar (default /mnt/dev/aosp). When present it is staged and baked in as the default framework, so `acl run ` resolves the whole android.* surface (stub bodies throw on call = demand-driven).',
+ description : 'Path to the api-33 public android.jar (stub API, ADR-0002 base boot-classpath layer beneath the acl shims). Empty tries $ACL_AOSP_ROOT/prebuilts/sdk/33/public/android.jar (default /mnt/dev/aosp); `none` looks nowhere. When present it is staged and baked in as the default framework, so `acl run ` resolves the whole android.* surface (stub bodies throw on call = demand-driven).',
)
option(
@@ -47,3 +47,40 @@ option(
# libFuzzer harnesses (tests/fuzz). Needs clang; see tests/fuzz/meson.build for the setup line.
option('fuzzers', type : 'boolean', value : false,
description : 'Build the libFuzzer harnesses in tests/fuzz (clang only)')
+
+# The JNI headers and the two JDK paths a4l records. With none of these set, the JDK of the
+# `java` on PATH supplies all three.
+option('jni_include', type : 'string', value : '',
+ description : 'Directory with jni.h (jni_md.h there or in linux/). Set, no JDK is looked for: the headers are all the ART backend needs. For a build machine with no JDK, and for a cross build.')
+option('javac', type : 'string', value : '',
+ description : 'Path of javac to record for the DEX-to-JVM converter (--vm=jvm). Empty records the detected JDK\'s, which is a build-machine path.')
+option('libjvm', type : 'string', value : '',
+ description : 'libjvm.so to record for --vm=jvm, which dlopen()s it. Empty records the detected JDK\'s path; `libjvm.so` leaves it to the loader on the target.')
+
+# One per optional part. auto: built when its dependencies are found. enabled: a missing
+# dependency is an error. disabled: left out whatever is installed.
+option('wayland', type : 'feature', value : 'auto',
+ description : 'The Wayland presenter (wayland-client, wayland-protocols, xkbcommon, wayland-cxx-scanner). Without it wm/ is a stub.')
+option('skia', type : 'feature', value : 'auto',
+ description : 'The Skia-backed gfx surface, from the prefix at -Dskia_prefix.')
+option('vulkan', type : 'feature', value : 'auto',
+ description : 'The Ganesh Vulkan present path (vulkan, vulkan-hpp, libdrm). Needs skia.')
+option('gl', type : 'feature', value : 'auto',
+ description : 'The host GL device for GLSurfaceView (egl, glesv2, gbm, wayland-egl, libdrm).')
+option('dmabuf_codec', type : 'feature', value : 'auto',
+ description : 'Hardware video decode through dmabuf-codec (V4L2, OpenMAX, VA-API).')
+option('gstreamer', type : 'feature', value : 'auto',
+ description : 'Video decode through GStreamer.')
+option('ffmpeg', type : 'feature', value : 'auto',
+ description : 'Software decode and SoundPool through FFmpeg (libsoundpool.so).')
+option('drm_cxx', type : 'feature', value : 'auto',
+ description : 'KMS scanout sink of the split-process path (drm-cxx).')
+option('alsa', type : 'feature', value : 'auto', description : 'ALSA audio output.')
+option('pipewire', type : 'feature', value : 'auto', description : 'PipeWire audio output.')
+option('libcamera', type : 'feature', value : 'auto', description : 'Cameras through libcamera.')
+option('sdbus', type : 'feature', value : 'auto',
+ description : 'Every D-Bus service backend (sdbus-c++ 2.x): network, Bluetooth, battery, storage, location, notifications, portals.')
+option('secret', type : 'feature', value : 'auto',
+ description : 'AndroidKeyStore on the Secret Service (libsecret).')
+option('crypto', type : 'feature', value : 'auto',
+ description : 'APK signature verification (libcrypto 3 headers).')
diff --git a/tests/unit/apk_stage_test.cpp b/tests/unit/apk_stage_test.cpp
index 547b6f28..08d12583 100644
--- a/tests/unit/apk_stage_test.cpp
+++ b/tests/unit/apk_stage_test.cpp
@@ -37,7 +37,7 @@ bool have_fixtures() {
fs::exists(fixture("ok-v3.apk"));
}
-std::vector slurp(const std::string& path) {
+[[maybe_unused]] std::vector slurp(const std::string& path) {
std::ifstream in(path, std::ios::binary);
return {std::istreambuf_iterator(in), {}};
}
diff --git a/tests/unit/apk_verify_test.cpp b/tests/unit/apk_verify_test.cpp
index 433a20e5..6c069488 100644
--- a/tests/unit/apk_verify_test.cpp
+++ b/tests/unit/apk_verify_test.cpp
@@ -30,7 +30,7 @@ std::string env(const char* name) {
return p ? p : std::string{};
}
-std::vector load_manifest() {
+[[maybe_unused]] std::vector load_manifest() {
std::vector out;
std::ifstream in(env("ACL_SIGNED_APKS_MANIFEST"));
for (std::string line; std::getline(in, line);) {
@@ -49,7 +49,7 @@ std::vector load_manifest() {
return out;
}
-SigResult verify_file(const std::string& file) {
+[[maybe_unused]] SigResult verify_file(const std::string& file) {
ZipError err;
auto apk = Apk::open(env("ACL_SIGNED_APKS_DIR") + "/" + file, err);
REQUIRE(apk.has_value());
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index cbaaa0f8..1ab6e484 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -154,8 +154,8 @@ if catch2_dep.found()
# JDK (have_jni) and javac are available; otherwise it SKIPs at runtime.
# Use the javac from the SAME java_home as the detected libjvm — a javac from a
# newer JDK on PATH would emit class files the embedded (older) VM cannot load.
- javac = have_jni ? find_program(java_home / 'bin' / 'javac', required : false) \
- : disabler()
+ javac = (have_jni and java_home != '') \
+ ? find_program(java_home / 'bin' / 'javac', required : false) : disabler()
if have_jni and javac.found()
jvm_classes = custom_target(
'jvm-fixture-classes',