Skip to content

Commit 419e4b1

Browse files
authored
Merge pull request #77 from SoZ0/v0.6.0
Near Complete Parity with Libcamera (and support for v0.6.0)
2 parents 37d15f1 + 3f2e241 commit 419e4b1

113 files changed

Lines changed: 30106 additions & 131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: Build and test
1414
strategy:
1515
matrix:
16-
libcamera_version: ["v0.4.0", "v0.5.0", "v0.5.1"]
16+
libcamera_version: ["v0.4.0", "v0.5.0", "v0.5.1", "v0.5.2", "v0.6.0"]
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout

Cargo.lock

Lines changed: 31 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Project structure:
1212
- [libcamera-meta](./libcamera-meta/) - Scripts for generating C and Rust code from libcamera controls, properties and formats YAMLs. Mostly used by the [regenerate.sh](./regenerate.sh) script.
1313
- [libcamera](./libcamera/) - Safe libcamera Rust interface on top of `libcamera-sys`.
1414

15+
Code generation uses a cached clone under `libcamera-git`; run `cargo run --bin generate_from_git` (or `./regenerate.sh`) occasionally to fetch the latest upstream tags before regenerating `versioned_files`. These bindings intentionally track libcamera’s public, application-facing API; pipeline-handler internals aren’t surfaced.
16+
1517
Unreleased documentation for `main`: [here](https://lit-robotics.github.io/libcamera-rs/libcamera/index.html)
1618

1719
## Building
@@ -133,6 +135,21 @@ FrameBuffer metadata: Immutable(
133135
Written 4147789 bytes to target/image.jpg
134136
```
135137

138+
Inspect generated pixel format constants and layout info ([code](./libcamera/examples/formats_constants.rs)):
139+
```console
140+
$ cargo run --example formats_constants
141+
Using constant formats::NV12 => NV12 (NV12)
142+
bits_per_pixel=12 planes=2 pixels_per_group=2
143+
frame size for 640x480 (align=0): 460800 bytes
144+
```
145+
146+
Apply a generated pixel format constant to a stream configuration ([code](./libcamera/examples/configure_formats.rs)):
147+
```console
148+
$ cargo run --example configure_formats
149+
validate status: Valid
150+
configured: StreamConfigurationRef { pixel_format: NV12, size: Size { width: 640, height: 480 }, stride: 640, frame_size: 460800, buffer_count: 4, color_space: None }, stride=640 frame_size=460800
151+
```
152+
136153
## Notes on safety
137154

138155
`libcamera-rs` is intended to be a fully memory-safe wrapper, however, due to `libcamera`'s complexity and many cross-references between objects it is quite hard to ensure total safety so there is very likely to be bugs. Issues and pull requests are welcome.

docker/ci/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Minimal CI runner image that matches the GitHub Actions workflow.
2+
# Build per libcamera version:
3+
# docker build -f docker/ci/Dockerfile --build-arg LIBCAMERA_VERSION=v0.5.1 -t libcamera-ci:v0.5.1 .
4+
#
5+
# Then run against your workspace:
6+
# docker run --rm -v "$PWD:/workspace" -w /workspace libcamera-ci:v0.5.1 ./docker/ci/entrypoint.sh
7+
8+
ARG UBUNTU_VERSION=22.04
9+
FROM ubuntu:${UBUNTU_VERSION}
10+
11+
ARG LIBCAMERA_VERSION=v0.6.0
12+
ENV DEBIAN_FRONTEND=noninteractive
13+
14+
# Install build prerequisites for libcamera and Rust.
15+
RUN apt-get update && \
16+
apt-get install -y --no-install-recommends \
17+
build-essential git ninja-build pkg-config clang \
18+
python3 python3-pip python3-jinja2 python3-yaml python3-ply \
19+
libyaml-dev libssl-dev curl ca-certificates && \
20+
rm -rf /var/lib/apt/lists/*
21+
22+
# Meson from apt on 22.04 is too old for older libcamera tags; upgrade via pip.
23+
RUN pip3 install --no-cache-dir --upgrade pip meson
24+
25+
# Install libcamera (matching the workflow: only vimc pipeline for speed).
26+
RUN git clone --depth 1 --branch ${LIBCAMERA_VERSION} https://git.libcamera.org/libcamera/libcamera.git /tmp/libcamera && \
27+
cd /tmp/libcamera && \
28+
meson build -Dipas=vimc -Dpipelines=vimc && \
29+
ninja -C build install && \
30+
rm -rf /tmp/libcamera
31+
32+
# Install Rust toolchain (stable) with rustfmt/clippy.
33+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
34+
| sh -s -- -y --profile minimal --component rustfmt,clippy && \
35+
. "$HOME/.cargo/env" && \
36+
rustc --version && cargo --version
37+
38+
ENV PATH="/root/.cargo/bin:${PATH}"
39+
# Ensure pkg-config can find the installed libcamera.
40+
ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib/x86_64-linux-gnu/pkgconfig:${PKG_CONFIG_PATH}"
41+
42+
WORKDIR /workspace
43+
COPY docker/ci/entrypoint.sh /usr/local/bin/entrypoint.sh
44+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

docker/ci/entrypoint.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Allow skipping doc build for speed/debugging.
5+
: "${RUN_DOCS:=true}"
6+
7+
LIBCAMERA_VERSION=$(pkg-config --modversion libcamera || true)
8+
echo "Using libcamera from pkg-config: ${LIBCAMERA_VERSION}"
9+
10+
# Keep build artifacts separate per libcamera version to avoid cross-version cache issues.
11+
if [ -z "${CARGO_TARGET_DIR:-}" ] && [ -n "${LIBCAMERA_VERSION}" ]; then
12+
export CARGO_TARGET_DIR="target/${LIBCAMERA_VERSION}"
13+
fi
14+
echo "Using CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-target}"
15+
16+
cargo build
17+
cargo fmt --all -- --check
18+
cargo test
19+
cargo clippy --no-deps -- -D warnings
20+
21+
if [ "$RUN_DOCS" = "true" ]; then
22+
RUSTDOCFLAGS="-Dwarnings" cargo doc --no-deps --lib
23+
fi

docker/ci/run-local.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Run the CI steps locally for each libcamera version (same matrix as GitHub Actions).
5+
VERSIONS=(
6+
v0.4.0
7+
v0.5.0
8+
v0.5.1
9+
v0.5.2
10+
v0.6.0
11+
)
12+
13+
for ver in "${VERSIONS[@]}"; do
14+
echo "=== Building CI image for libcamera ${ver} ==="
15+
docker build -f docker/ci/Dockerfile --build-arg LIBCAMERA_VERSION="${ver}" -t "libcamera-ci:${ver}" .
16+
echo "=== Running CI steps for libcamera ${ver} ==="
17+
docker run --rm -v "$PWD:/workspace" -w /workspace "libcamera-ci:${ver}" ./docker/ci/entrypoint.sh
18+
done

libcamera-meta/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ prettyplease = "0.2.17"
1111
semver = "1.0.22"
1212
syn = "2.0.58"
1313
yaml-rust = "0.4"
14+
regex = "1"

0 commit comments

Comments
 (0)