Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions webview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,9 @@ When you're done, you can stop and remove the container with the following comma
$ docker compose down
```

### Building for Raspberry Pi 5
### Building for Raspberry Pi 4 and Raspberry Pi 5 Devices Running 64-Bit OS

> [!NOTE]
> At this time, you can only build the WebView for Raspberry Pi 5 devices
> 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.)

The steps are similar to that of [building for x86](#building-for-x86),
but you need to specify the set the Docker Compose profile to `pi5`:

```bash
$ cd webview/
$ export GIT_HASH=$(git rev-parse --short HEAD)
$ export COMPOSE_PROFILES=pi5
$ docker compose up -d --build
$ docker compose exec builder-pi5 /scripts/build_webview.sh
```

The resulting files will be placed in `~/tmp-pi5/build/release`.
See this [documentation](/webview/docs/build_webview_using_prebuilt_qt.md) for details

## Usage

Expand Down
17 changes: 17 additions & 0 deletions webview/docker-compose.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor common attributes.

Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,20 @@ services:
- "./examples:/src/examples"
- "./:/webview:ro"
- "./scripts/build_webview.sh:/scripts/build_webview.sh"

builder-pi4-64:
profiles:
- pi4-64
build:
context: .
dockerfile: docker/Dockerfile.pi4-64
environment:
- GIT_HASH=${GIT_HASH}
- PLATFORM=pi4-64
tty: true
stdin_open: true
volumes:
- "~/tmp/pi4-64/build:/build:Z"
- "./examples:/src/examples"
- "./:/webview:ro"
- "./scripts/build_webview.sh:/scripts/build_webview.sh"
18 changes: 18 additions & 0 deletions webview/docker/Dockerfile.pi4-64
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can maybe create a script that generates custom Dockerfiles based on the given platform (e.g., pi1, pi2, pi3, pi4, pi4-64, pi5, etc.).

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# vim:ft=dockerfile

FROM balenalib/raspberrypi4-64-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"]
70 changes: 70 additions & 0 deletions webview/docs/build_webview_using_prebuilt_qt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Building WebView via Prebuilt Qt

## Overview

This method only works on the following devices:

- Raspberry Pi 4 (64-bit)
- Raspberry Pi 5 (64-bit)

## Prerequisites

> [!NOTE]
> Cross-compilation is not yet supported.
> You need to have the following installed and set up on your Raspberry Pi 4 or Raspberry Pi 5 device:
> - 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
```

Initialize environment variables:

```bash
$ export GIT_HASH=$(git rev-parse --short HEAD)

$ export COMPOSE_PROFILES=pi5 # For Raspberry Pi 5
$ export COMPOSE_PROFILES=pi4-64 # For Raspberry Pi 4
```

Start the builder container with the following command:

```bash
$ docker compose up -d --build
```

You should now be able to invoke a run executing either of the following commands:

```bash
$ docker compose exec builder-pi5 /webview/build_webview.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ docker compose exec builder-pi5 /webview/build_webview.sh
$ docker compose exec builder-pi5 /scripts/build_webview.sh

# or
$ docker compose exec builder-pi4-64 /webview/build_webview.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ docker compose exec builder-pi4-64 /webview/build_webview.sh
$ docker compose exec builder-pi4-64 /scripts/build_webview.sh

```

```bash
$ docker compose exec builder-pi5 bash
# or
$ docker compose exec builder-pi4-64 bash

# Once you're in the container, run the following command:
$ /scripts/build_webview.sh
```

The resulting files will be placed in `~/tmp/<platform>/build/release`, where `<platform>` is either `pi5` or `pi4-64`.

When you're done, you can stop and remove the container with the following commands:

```bash
$ docker compose down
```
7 changes: 7 additions & 0 deletions webview/scripts/build_webview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ QT_MINOR='4'
QT_PATCH='2'
QT_VERSION="${QT_MAJOR}.${QT_MINOR}.${QT_PATCH}"
CORE_COUNT="$(expr $(nproc) - 2)"
PLATFORM="${PLATFORM:-pi5}"
SUPPORTED_PLATFORMS=("pi4-64" "pi5")

if [[ ! " ${SUPPORTED_PLATFORMS[@]} " =~ " ${PLATFORM} " ]]; then
echo "Unsupported platform: ${PLATFORM}"
exit 1
fi

BOARD=${BOARD:-"x86"}
if [[ ! "${BOARD}" =~ ^(x86|pi5)$ ]]; then
Expand Down
2 changes: 2 additions & 0 deletions webview/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "mainwindow.h"
#include "view.h"

#include <QGuiApplication>
#include <QScreen>

MainWindow::MainWindow() : QMainWindow()
{
Expand Down
Loading