Skip to content
Merged
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
73 changes: 28 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,36 @@ on:
required: false
default: false
type: boolean
build_riscv64:
description: 'Build riscv64 debug binary'
required: false
default: false
type: boolean

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Check & Build
name: Check & Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
libglib2.0-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev \
Expand Down Expand Up @@ -78,9 +79,6 @@ jobs:
- name: Run tests
run: just test

- name: Build release
run: just build-release

# Cross-compiled debug builds to verify compilation on all target architectures
# x86_64 and aarch64 always run; riscv64 runs on main or manual trigger
build-x86_64:
Expand All @@ -91,18 +89,20 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
libglib2.0-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev \
Expand All @@ -123,12 +123,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: aarch64-unknown-linux-gnu

- name: Install cross
Expand All @@ -137,22 +137,21 @@ jobs:
- name: Build debug binary
run: cross build --target aarch64-unknown-linux-gnu


build-riscv64:
name: Build (riscv64)
runs-on: ubuntu-latest
needs: check
# Run on push to main, or on manual trigger with build_riscv64=true
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.build_riscv64)
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: riscv64gc-unknown-linux-gnu

- name: Install cross
Expand All @@ -161,24 +160,6 @@ jobs:
- name: Build debug binary
run: cross build --target riscv64gc-unknown-linux-gnu

# Flatpak build times (using QEMU emulation for non-x86_64):
#
# | Architecture | Duration |
# |--------------|---------------------|
# | x86_64 | ~20 minutes |
# | aarch64 | ~5 hours 47 minutes |
# | riscv64 | failed immediately |
#
# The aarch64 build uses QEMU emulation on an x86_64 runner, which is extremely
# slow (compiling Rust under emulation).
#
# Options for native ARM64 runners:
# 1. GitHub's ARM runners (runs-on: ubuntu-24.04-arm64) - requires GitHub Team/Enterprise or larger runners (paid)
# 2. Self-hosted runner - free, but you need your own ARM hardware
# 3. Disable aarch64 for now - build locally when needed
#
# aarch64: Runs on push to main, but on PRs only when manually triggered via workflow_dispatch
# riscv64 disabled: Flathub doesn't provide org.freedesktop.Platform runtime for riscv64
flatpak-x86_64:
name: Flatpak (x86_64)
runs-on: ubuntu-latest
Expand All @@ -187,7 +168,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install Flatpak and flatpak-builder
Expand All @@ -201,9 +181,10 @@ jobs:

- name: Install Flatpak SDK and runtime
run: |
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//24.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk//24.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//24.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//25.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk//25.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//25.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub com.system76.Cosmic.BaseApp//stable --arch=x86_64

- name: Install just
uses: extractions/setup-just@v2
Expand All @@ -220,6 +201,7 @@ jobs:
with:
name: cosmic-camera-x86_64.flatpak
path: cosmic-camera-x86_64.flatpak
if-no-files-found: error
retention-days: 7

flatpak-aarch64:
Expand All @@ -232,7 +214,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install Flatpak and flatpak-builder
Expand All @@ -251,9 +232,10 @@ jobs:

- name: Install Flatpak SDK and runtime
run: |
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//24.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk//24.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//24.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//25.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk//25.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//25.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub com.system76.Cosmic.BaseApp//stable --arch=aarch64

- name: Install just
uses: extractions/setup-just@v2
Expand All @@ -270,4 +252,5 @@ jobs:
with:
name: cosmic-camera-aarch64.flatpak
path: cosmic-camera-aarch64.flatpak
if-no-files-found: error
retention-days: 7
19 changes: 12 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ jobs:
fetch-tags: true

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.target }}

- name: Install cross-compilation tools
Expand Down Expand Up @@ -103,9 +104,10 @@ jobs:

- name: Install Flatpak SDK and runtime
run: |
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//24.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk//24.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//24.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//25.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk//25.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//25.08 --arch=x86_64
sudo flatpak install -y --noninteractive flathub com.system76.Cosmic.BaseApp//stable --arch=x86_64

- name: Install just
uses: extractions/setup-just@v2
Expand All @@ -121,6 +123,7 @@ jobs:
with:
name: flatpak-x86_64
path: cosmic-camera-x86_64.flatpak
if-no-files-found: error
retention-days: 1

# Build Flatpak for aarch64 (QEMU emulation, slow but necessary for releases)
Expand Down Expand Up @@ -150,9 +153,10 @@ jobs:

- name: Install Flatpak SDK and runtime
run: |
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//24.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk//24.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//24.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//25.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk//25.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//25.08 --arch=aarch64
sudo flatpak install -y --noninteractive flathub com.system76.Cosmic.BaseApp//stable --arch=aarch64

- name: Install just
uses: extractions/setup-just@v2
Expand All @@ -168,6 +172,7 @@ jobs:
with:
name: flatpak-aarch64
path: cosmic-camera-aarch64.flatpak
if-no-files-found: error
retention-days: 1

# Create the GitHub release with all artifacts
Expand Down
20 changes: 20 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Cross-compilation configuration
# https://github.com/cross-rs/cross

[target.aarch64-unknown-linux-gnu]
# Use custom Dockerfile based on Ubuntu 22.04 (which has libseat-dev)
dockerfile = "docker/Dockerfile.aarch64"

[target.aarch64-unknown-linux-gnu.env]
passthrough = [
"RUST_BACKTRACE"
]

[target.riscv64gc-unknown-linux-gnu]
# Use custom Dockerfile based on Ubuntu 22.04 (which has libseat-dev)
dockerfile = "docker/Dockerfile.riscv64"

[target.riscv64gc-unknown-linux-gnu.env]
passthrough = [
"RUST_BACKTRACE"
]
46 changes: 46 additions & 0 deletions docker/Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Cross-compilation image for aarch64-unknown-linux-gnu
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

# Configure apt sources: amd64 from archive.ubuntu.com, arm64 from ports.ubuntu.com
RUN rm -f /etc/apt/sources.list /etc/apt/sources.list.d/ubuntu.sources && \
echo 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu noble main universe' > /etc/apt/sources.list && \
echo 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu noble-updates main universe' >> /etc/apt/sources.list && \
echo 'deb [arch=amd64] http://security.ubuntu.com/ubuntu noble-security main universe' >> /etc/apt/sources.list && \
echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports noble main universe' >> /etc/apt/sources.list && \
echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports noble-updates main universe' >> /etc/apt/sources.list && \
echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports noble-security main universe' >> /etc/apt/sources.list

# Install base tools (before adding arm64 architecture)
RUN apt-get update && apt-get install -y \
curl \
build-essential \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

# Add arm64 architecture
RUN dpkg --add-architecture arm64

# Install cross-compilation toolchain and dependencies
RUN apt-get update && apt-get install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
libglib2.0-dev:arm64 \
libgstreamer1.0-dev:arm64 \
libgstreamer-plugins-base1.0-dev:arm64 \
libgstreamer-plugins-bad1.0-dev:arm64 \
libwayland-dev:arm64 \
libxkbcommon-dev:arm64 \
libinput-dev:arm64 \
libudev-dev:arm64 \
libseat-dev:arm64 \
&& rm -rf /var/lib/apt/lists/*

# Set up environment for cross-compilation
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \
PKG_CONFIG_ALLOW_CROSS=1 \
PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig \
PKG_CONFIG_SYSROOT_DIR=/
46 changes: 46 additions & 0 deletions docker/Dockerfile.riscv64
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Cross-compilation image for riscv64gc-unknown-linux-gnu
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

# Configure apt sources: amd64 from archive.ubuntu.com, riscv64 from ports.ubuntu.com
RUN rm -f /etc/apt/sources.list /etc/apt/sources.list.d/ubuntu.sources && \
echo 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu noble main universe' > /etc/apt/sources.list && \
echo 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu noble-updates main universe' >> /etc/apt/sources.list && \
echo 'deb [arch=amd64] http://security.ubuntu.com/ubuntu noble-security main universe' >> /etc/apt/sources.list && \
echo 'deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports noble main universe' >> /etc/apt/sources.list && \
echo 'deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports noble-updates main universe' >> /etc/apt/sources.list && \
echo 'deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports noble-security main universe' >> /etc/apt/sources.list

# Install base tools (before adding riscv64 architecture)
RUN apt-get update && apt-get install -y \
curl \
build-essential \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

# Add riscv64 architecture
RUN dpkg --add-architecture riscv64

# Install cross-compilation toolchain and dependencies
RUN apt-get update && apt-get install -y \
gcc-riscv64-linux-gnu \
g++-riscv64-linux-gnu \
libglib2.0-dev:riscv64 \
libgstreamer1.0-dev:riscv64 \
libgstreamer-plugins-base1.0-dev:riscv64 \
libgstreamer-plugins-bad1.0-dev:riscv64 \
libwayland-dev:riscv64 \
libxkbcommon-dev:riscv64 \
libinput-dev:riscv64 \
libudev-dev:riscv64 \
libseat-dev:riscv64 \
&& rm -rf /var/lib/apt/lists/*

# Set up environment for cross-compilation
ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc \
CC_riscv64gc_unknown_linux_gnu=riscv64-linux-gnu-gcc \
CXX_riscv64gc_unknown_linux_gnu=riscv64-linux-gnu-g++ \
PKG_CONFIG_ALLOW_CROSS=1 \
PKG_CONFIG_PATH=/usr/lib/riscv64-linux-gnu/pkgconfig:/usr/share/pkgconfig \
PKG_CONFIG_SYSROOT_DIR=/
1 change: 1 addition & 0 deletions io.github.freddyfunk.CosmicCamera.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ modules:
- type: dir
path: .
- cargo-sources.json

# Note: No additional GStreamer plugins needed - app uses pipewiresrc which is
# included in org.freedesktop.Platform via PipeWire's gst-plugin-pipewire
Loading