Build the service in a container, and fix what the target compiler found

The openlgtv NDK is a Linux toolchain with no macOS or Windows build, so
tools/build.sh could not produce a binary anywhere else. docker-build.sh
bakes the SDK into an image and compiles there; packaging and deploy stay
on the host, where the TV is reachable. The SDK ships aarch64 as well as
x86_64, so the image picks the one matching the daemon and Apple Silicon
builds natively rather than under emulation.

Cross-compiling for real turned up three things the host compiler did
not:

  sink_hyperhdr_viz.c  read p->width and p->height to format the error
                       message after free(p)
  sink_hyperhdr.c      an SDP connection line of 128 bytes cannot hold
                       "IN IP4 " plus a 127-byte host plus "/255", so a
                       long hostname would silently lose its TTL suffix
  common/log.c         the log body was sized to the whole ring line,
                       leaving nothing for the prefix; budget for it so
                       the bound is provable rather than left to
                       snprintf

A clean cross-compile is now warning-free, and readelf confirms the
design rule holds: luna-service2, glib, PmLogLib and libc, with no
libpulse or libasound.

Also: @webosose/ares-cli was pinned to ^3.0.0, which does not exist
(latest is 2.4.0), so npm install failed outright. build.sh now puts
node_modules/.bin on PATH so a local install is enough.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Rene Kievits
2026-08-26 10:29:09 +02:00
co-authored by Claude Opus 5
parent 7529a60650
commit 3e4d0e17bc
11 changed files with 5692 additions and 14 deletions
+29 -6
View File
@@ -4,17 +4,32 @@
| For | Install |
| --- | --- |
| the native service | the [openlgtv buildroot NDK](https://github.com/openlgtv/buildroot-nc4/releases), `arm-webos-linux-gnueabi_sdk-buildroot` |
| packaging | `npm install -g @webosose/ares-cli` |
| the native service | the [openlgtv buildroot NDK](https://github.com/openlgtv/buildroot-nc4/releases) — or Docker, see below |
| packaging | `npm install` (ares-cli), or `npm install -g @webosose/ares-cli` |
| the tests | a host C compiler, Python 3, Node (optional: `flatbuffers`, `jsdom`) |
Unpack the NDK and relocate it once:
### The toolchain
The NDK is a **Linux** toolchain — there is no macOS or Windows build of it. On
Linux, unpack and relocate it once:
```sh
tar xf arm-webos-linux-gnueabi_sdk-buildroot.tar.gz -C "$HOME"
tar xf arm-webos-linux-gnueabi_sdk-buildroot-x86_64.tar.gz -C "$HOME"
"$HOME/arm-webos-linux-gnueabi_sdk-buildroot/relocate-sdk.sh"
```
Everywhere else, build the native part in a container:
```sh
./tools/docker-build.sh # -> build/native/audiocap-service
```
That bakes the SDK into an image, so it downloads once and later builds start
immediately. There are aarch64 and x86_64 SDK builds and the image picks
whichever matches the container, so on Apple Silicon it runs natively rather
than under emulation. Only the compile happens in the container; packaging and
deployment run on the host, where the TV is reachable.
Register the TV with ares once, using the Homebrew Channel's ssh (port 9922,
root):
@@ -32,11 +47,19 @@ ares-setup-device --add tv \
./tools/build.sh logs
```
With the container toolchain it is two steps, since `build.sh` only knows how
to drive a local NDK:
```sh
./tools/docker-build.sh && ./tools/build.sh package
```
`DEVICE=livingroom ./tools/build.sh install` targets a different device;
`WEBOS_SDK=/opt/webos-sdk ./tools/build.sh` a differently placed NDK.
The same commands exist as npm scripts (`npm run build`, `npm run deploy`, …)
if that is more your habit.
if that is more your habit. `build.sh` puts `node_modules/.bin` on PATH first,
so a local `npm install` of ares-cli is enough — no global install needed.
### What the packaging step does
@@ -92,7 +115,7 @@ npm run serve # http://localhost:8000
```sh
python3 tools/make-manifest.py \
--base-url https://github.com/you/lgtv-audio-cap/releases/download/v1.0.0
--base-url https://git.crylia.de/Crylia/lgtv_audio_cap/releases/download/v1.0.0
```
5. Submit the manifest URL to [webosbrew/repo](https://github.com/webosbrew/repo).