Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with docker sysroot lol #8

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
43 changes: 40 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ jobs:
steps:

- uses: actions/checkout@v3
- uses: pguyot/arm-runner-action@v2

# From https://github.com/pguyot/arm-runner-action/blob/main/.github/workflows/test-cache.yml
- uses: actions/cache@v3
id: cache
with:
path: $RUNNER_TEMP/photon_libcam_builder.img
key: ${{ hashFiles('**/*.yml') }}
- uses: pguyot/arm-runner-action@HEAD
id: install_deps
if: steps.cache.outputs.cache-hit != 'true'
with:
# we don't want to optimize as it's two-stage
optimize_image: no
image_additional_mb: 1500
base_image: https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2023-12-11/2023-12-11-raspios-bookworm-arm64-lite.img.xz
commands: |
apt-get update
apt-get install -y libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk

- name: Move and rename image with dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
mv ${{ steps.install_deps.outputs.image }} $RUNNER_TEMP/photon_libcam_builder.img

- uses: pguyot/arm-runner-action@HEAD
with:
base_image: raspios_lite_arm64:latest
base_image: file://$RUNNER_TEMP/photon_libcam_builder.img
cpu: cortex-a7
image_additional_mb: 1500
bind_mount_repository: true
# Update again anyways to pull down the latest libcamera et al
commands: |
apt-get update
apt-get install -y libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk
cmake -B build-pi -DCMAKE_BUILD_TYPE=Release
cmake --build build-pi -j 4
cmake --build build-pi -- -j

- run: find .

Expand Down Expand Up @@ -54,3 +79,15 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-chroot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
sudo apt-get update && sudo apt-get install -y qemu qemu-user-static binfmt-support
docker run --mount type=bind,source=$(pwd),target=/opt/photon_sysroot/work mcm001/photon-libcamera-builder-entry:latest chroot /opt/photon_sysroot bash -c 'uname -a && cat /etc/os-release && cd /work && cmake -B build-pi -DCMAKE_BUILD_TYPE=Release && cmake --build build-pi -- -j'
- uses: actions/upload-artifact@master
with:
name: libcamera-driver-chroot
path: build-pi/*.so
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.idea/
.vscode
build
build-pi
.cache/
compile_commands.json
photon_sysroot
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.25.1)
cmake_minimum_required(VERSION 3.15)
project(libcamera_meme)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y qemu qemu-user-static binfmt-support libopencv-dev libegl1-mesa-dev libcamera-dev cmake build-essential libdrm-dev libgbm-dev default-jdk openjdk-17-jdk && apt-get clean
COPY photon_sysroot /opt/photon_sysroot
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@ This should spit out the shared library into the build directory.

Compile with `g++ -std=c++17 -o eglinfo eglinfo.c headless_opengl.cpp -lEGL -lGLESv2 -lgbm`, and then run with `./eglinfo`

## Chroot stuff

Using our docker image and run with --privileged

docker run -it --privileged --mount type=bind,source="$(pwd)",target=/opt/photon_sysroot_v2023.4.2/opt/photon-libcamera-gl-driver photon-libcamera-builder:latest
/opt/photon_sysroot_v2023.4.2/opt/photon-libcamera-gl-driver/start_chroot.sh

Or

docker run -it --privileged --mount type=bind,source="$(pwd)",target=/opt/photon_sysroot_v2023.4.2/opt/photon-libcamera-gl-driver photon-libcamera-builder-entry:latest

# git clone ${{ github.repositoryUrl }} && cd "$(basename "$_" .git)"


rm -rf /var/lib/apt/lists/*
locale-gen --purge POSTIX && echo 'Success!'