Skip to content

Commit

Permalink
feat: write scripts for building a Pi 5 WebView (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomiguelino authored Dec 18, 2024
1 parent c101927 commit 389f1cc
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 1 deletion.
6 changes: 5 additions & 1 deletion webview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions webview/docker-compose.pi5.yml
Original file line number Diff line number Diff line change
@@ -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"
18 changes: 18 additions & 0 deletions webview/docker/Dockerfile.pi5
Original file line number Diff line number Diff line change
@@ -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"]
50 changes: 50 additions & 0 deletions webview/docs/build_webview_for_pi5.md
Original file line number Diff line number Diff line change
@@ -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
```
35 changes: 35 additions & 0 deletions webview/scripts/build_pi5_webview.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 389f1cc

Please sign in to comment.