diff --git a/webview/README.md b/webview/README.md index 69bd1ae96..b68ca0f1a 100644 --- a/webview/README.md +++ b/webview/README.md @@ -3,7 +3,7 @@ > [!WARNING] > To build this, you need **very** beefy hardware. We are building this on a VM with 32 vCPUs and 128GB RAM. If you're trying to build it locally, you likely need to tweak [MAKE_CORES](https://github.com/Screenly/screenly-ose/blob/master/webview/build_qt5.sh#L12) to something lower, but you would still need a powerful workstation (32GB RAM minimum) to make this build. -### Building for Raspberry Pi +### Building for Raspberry Pi (1-4) Since our entire build environment resides inside a Docker container, you don't need to install any packages on the host system. Everything is confined to the Docker image. Do however note that as of this writing, the multi-platform support is still in beta so, you need to enable this. Instructions for how to get started with multi-platform builds can be found [here](https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408). @@ -69,6 +69,10 @@ When you're done, you can stop and remove the container with the following comma docker compose -f docker-compose.x86.yml down ``` +### Building for Raspberry Pi 5 + +See this [documentation](/webview/docs/build_webview_for_pi5.md) for details + ## Usage DBus is used for communication. diff --git a/webview/docker-compose.pi5.yml b/webview/docker-compose.pi5.yml new file mode 100644 index 000000000..a8ac6bdb8 --- /dev/null +++ b/webview/docker-compose.pi5.yml @@ -0,0 +1,14 @@ +services: + builder: + build: + context: . + dockerfile: docker/Dockerfile.pi5 + environment: + - GIT_HASH=${GIT_HASH} + tty: true + stdin_open: true + volumes: + - "~/tmp-pi5/build:/build:Z" + - "./examples:/src/examples" + - "./:/webview:ro" + - "./scripts/build_pi5_webview.sh:/scripts/build_pi5_webview.sh" diff --git a/webview/docker/Dockerfile.pi5 b/webview/docker/Dockerfile.pi5 new file mode 100644 index 000000000..f716f8b3c --- /dev/null +++ b/webview/docker/Dockerfile.pi5 @@ -0,0 +1,18 @@ +# vim:ft=dockerfile + +FROM balenalib/raspberrypi5-debian:bookworm + +ENV DEBIAN_FRONTEND=noninteractive + +# Build dependencies for the Qt 6 app +RUN apt-get -y update && apt-get install -y \ + build-essential \ + cmake \ + qt6-base-dev \ + qt6-webengine-dev + +RUN mkdir -p /scripts /src + +WORKDIR /build + +CMD ["bash"] diff --git a/webview/docs/build_webview_for_pi5.md b/webview/docs/build_webview_for_pi5.md new file mode 100644 index 000000000..3d8ba1324 --- /dev/null +++ b/webview/docs/build_webview_for_pi5.md @@ -0,0 +1,50 @@ +# Building WebView for Raspberry Pi 5 + +## Prerequisites + +> [!NOTE] +> At this time, you can only build the WebView from a Raspberry Pi 5 device. +> You need to have the following installed and set up on your Raspberry Pi 5: +> - Docker (arm64) +> - Code editor of your choice (e.g., Visual Studio Code, Neovim, etc.) + +## Building the WebView + +Clone the repository: + +```bash +$ git clone https://github.com/Screenly/Anthias.git +``` + +Navigate to the `webview` directory: + +```bash +$ cd /path/to/Anthias/webview +``` + +Start the builder container with the following command: + +```bash +docker compose -f docker-compose.pi5.yml up -d --build +``` + +You should now be able to invoke a run executing either of the following commands: + +```bash +$ docker compose -f docker-compose.pi5.yml exec builder /webview/build_pi5.sh +``` + +```bash +$ docker compose -f docker-compose.pi5.yml exec builder bash + +# Once you're in the container, run the following command: +$ /scripts/build_pi5_webview.sh +``` + +The resulting files will be placed in `~/tmp-pi5/build/release`. + +When you're done, you can stop and remove the container with the following commands: + +```bash +$ docker compose -f docker-compose.pi5.yml down +``` \ No newline at end of file diff --git a/webview/scripts/build_pi5_webview.sh b/webview/scripts/build_pi5_webview.sh new file mode 100755 index 000000000..477e8d474 --- /dev/null +++ b/webview/scripts/build_pi5_webview.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -euo pipefail + +DEBIAN_VERSION='bookworm' +QT_MAJOR='6' +QT_MINOR='4' +QT_PATCH='2' +QT_VERSION="${QT_MAJOR}.${QT_MINOR}.${QT_PATCH}" +CORE_COUNT="$(expr $(nproc) - 2)" + +function create_webview_archive() { + local ARCHIVE_NAME="webview-${QT_VERSION}-${DEBIAN_VERSION}-pi5-$GIT_HASH.tar.gz" + local ARCHIVE_DESTINATION="/build/release/${ARCHIVE_NAME}" + + mkdir -p /build/release + + cp -rf /webview /build + cd /build/webview + qmake6 + make -j${CORE_COUNT} + make install + + mkdir -p fakeroot/bin fakeroot/share/ScreenlyWebview + mv ScreenlyWebview fakeroot/bin/ + cp -rf /webview/res fakeroot/share/ScreenlyWebview/ + + cd fakeroot + + tar cfz ${ARCHIVE_DESTINATION} . + cd /build/release + sha256sum ${ARCHIVE_NAME} > ${ARCHIVE_DESTINATION}.sha256 +} + +create_webview_archive