Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2c93913
Add rust support
wysaid Aug 28, 2025
cd3ffe5
Clean up temporary files and fix core rust binding structure
Copilot Aug 28, 2025
6cd435c
Complete rust bindings refactoring: fix examples, add tests, update V…
Copilot Aug 28, 2025
f8046ec
Fix rust compilation errors and add GitHub workflow
Copilot Aug 28, 2025
de71868
Fix demo error
wysaid Sep 1, 2025
f9c64ad
fix(rust): enable convert module and fix lifetime issues in frame.rs
wysaid Dec 27, 2025
1615698
feat(rust): add build-source feature for distribution
wysaid Dec 27, 2025
2afc385
fix(rust): support both repo and packaged directory structures in bui…
wysaid Dec 27, 2025
ebd9343
ci(rust): add comprehensive workflow for static-link and build-source
wysaid Dec 27, 2025
3745092
fix(rust): Address PR review comments and fix critical issues
wysaid Dec 27, 2025
6b901d4
fix(rust): Fix convert module API mismatches with C library
wysaid Dec 27, 2025
ffad966
fix: Format code and fix AVX2 compilation in build-source mode
wysaid Dec 27, 2025
d0c1e3b
fix: Resolve clippy warnings
wysaid Dec 27, 2025
84bc8d6
fix: Apply cargo fmt to set_pixel_format
wysaid Dec 27, 2025
e049718
Merge remote-tracking branch 'origin/main' into feature/rust
wysaid Dec 31, 2025
f499ce2
fix: Resolve Rust CI workflow issues
wysaid Dec 31, 2025
351ab6a
fix(rust): Add file playback source files to build-source mode
wysaid Dec 31, 2025
b7b2140
fix(rust): Fix cross-platform type compatibility for error codes
wysaid Dec 31, 2025
1f01fe6
fix(rust): Resolve critical build and API issues
wysaid Dec 31, 2025
3dae4bf
fix(rust): Fix Rust bindings compilation on Windows
wysaid Dec 31, 2025
4c758d6
fix(rust): Implement Windows-specific path handling for file operations
wysaid Dec 31, 2025
f491794
fix(rust): Fix Windows build issues
wysaid Jan 4, 2026
5f57424
fix(ci): Fix Windows CI and prevent duplicate workflow runs
wysaid Jan 4, 2026
d37f746
fix(rust): Build both Debug and Release configs on Windows CI
wysaid Jan 4, 2026
72ad68b
fix(ci): Fix LIBCLANG_PATH escaping in GitHub Actions workflow
wysaid Jan 4, 2026
5e41b23
fix(ci): Add libclang-dev dependency for Ubuntu and remove refreshenv…
wysaid Jan 4, 2026
7fdaebd
ci: fix libclang setup in rust workflow
wysaid Jan 4, 2026
18a6be3
ci: skip camera-dependent rust tests in CI
wysaid Jan 4, 2026
83f93aa
fix(rust,build,core): Align Rust version to 1.5.0, improve build safe…
wysaid Jan 4, 2026
e10615d
fix(rust): Address PR review issues
wysaid Jan 4, 2026
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
164 changes: 164 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: Rust CI

on:
push:
branches: [ main, develop ]
paths:
- 'bindings/rust/**'
- 'src/**'
- 'include/**'
- 'CMakeLists.txt'
- '.github/workflows/rust.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'bindings/rust/**'
- 'src/**'
- 'include/**'
- 'CMakeLists.txt'
- '.github/workflows/rust.yml'

env:
CARGO_TERM_COLOR: always
CCAP_SKIP_CAMERA_TESTS: 1

permissions:
contents: read

jobs:
# Job 1: Static Linking (Development Mode)
# Verifies that the crate links correctly against a pre-built C++ library.
static-link:
name: Static Link (Dev)
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install system dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential pkg-config libclang-dev

- name: Install system dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install cmake llvm -y

- name: Configure LIBCLANG_PATH (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: echo "LIBCLANG_PATH=C:\\Program Files\\LLVM\\bin" >> $env:GITHUB_ENV

- name: Install system dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install cmake llvm
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: clippy, rustfmt
cache: false

# Build C++ Library (Linux/macOS)
# We build in build/Debug to match build.rs expectations for Unix Makefiles
- name: Build C library (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p build/Debug
cd build/Debug
cmake -DCMAKE_BUILD_TYPE=Debug -DCCAP_BUILD_EXAMPLES=OFF -DCCAP_BUILD_TESTS=OFF ../..
cmake --build . --config Debug --parallel

# Build C++ Library (Windows)
# Build both Debug and Release versions
# MSVC is a multi-config generator, so we build to build/ and specify config at build time
- name: Build C library (Windows)
if: runner.os == 'Windows'
run: |
mkdir build
cd build
cmake -DCCAP_BUILD_EXAMPLES=OFF -DCCAP_BUILD_TESTS=OFF ..
cmake --build . --config Debug --parallel
cmake --build . --config Release --parallel

- name: Check formatting
if: matrix.os == 'ubuntu-latest'
working-directory: bindings/rust
run: cargo fmt -- --check

- name: Run clippy
if: matrix.os == 'ubuntu-latest'
working-directory: bindings/rust
run: cargo clippy --all-targets --features static-link -- -D warnings

- name: Build Rust bindings
working-directory: bindings/rust
run: cargo build --verbose --features static-link

- name: Run tests
working-directory: bindings/rust
run: cargo test --verbose --features static-link

# Job 2: Source Build (Distribution Mode)
# Verifies that the crate builds correctly from source using the cc crate.
# This is crucial for crates.io distribution.
build-source:
name: Build Source (Dist)
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install system dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config

- name: Install system dependencies (macOS)
if: matrix.os == 'macos-latest'
run: brew install llvm

- name: Install system dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install llvm -y
refreshenv

- name: Configure LIBCLANG_PATH (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: echo "LIBCLANG_PATH=C:\\Program Files\\LLVM\\bin" >> $env:GITHUB_ENV

- name: Configure LIBCLANG_PATH (macOS)
if: matrix.os == 'macos-latest'
run: echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: false
# The build.rs script should handle it via the 'build-source' feature.

- name: Build Rust bindings (Source)
working-directory: bindings/rust
# Disable default features (static-link) and enable build-source
run: cargo build --verbose --no-default-features --features build-source

- name: Run tests (Source)
working-directory: bindings/rust
run: cargo test --verbose --no-default-features --features build-source
100 changes: 100 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,106 @@
"problemMatcher": "$msCompile"
}
},
{
"label": "Run Rust print_camera",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--example",
"print_camera"
],
"options": {
"cwd": "${workspaceFolder}/bindings/rust"
},
"group": "build",
"problemMatcher": "$rustc"
},
{
"label": "Run Rust minimal_example",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--example",
"minimal_example"
],
"options": {
"cwd": "${workspaceFolder}/bindings/rust"
},
"group": "build",
"problemMatcher": "$rustc"
},
{
"label": "Run Rust capture_grab",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--example",
"capture_grab"
],
"options": {
"cwd": "${workspaceFolder}/bindings/rust"
},
"group": "build",
"problemMatcher": "$rustc"
},
{
"label": "Run Rust capture_callback",
"type": "shell",
"command": "cargo",
"args": [
"run",
"--example",
"capture_callback"
],
"options": {
"cwd": "${workspaceFolder}/bindings/rust"
},
"group": "build",
"problemMatcher": "$rustc"
},
{
"label": "Build Rust Bindings",
"type": "shell",
"command": "cargo",
"args": [
"build"
],
"options": {
"cwd": "${workspaceFolder}/bindings/rust"
},
"group": "build",
"problemMatcher": "$rustc"
},
{
"label": "Build Rust Examples",
"type": "shell",
"command": "cargo",
"args": [
"build",
"--examples"
],
"options": {
"cwd": "${workspaceFolder}/bindings/rust"
},
"group": "build",
"problemMatcher": "$rustc"
},
{
"label": "Test Rust Bindings",
"type": "shell",
"command": "cargo",
"args": [
"test"
],
"options": {
"cwd": "${workspaceFolder}/bindings/rust"
},
"group": "build",
"problemMatcher": "$rustc"
},
{
"label": "Run ccap CLI --video test.mp4 (Debug)",
"type": "shell",
Expand Down
35 changes: 34 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,37 @@ if (CCAP_INSTALL)
message(STATUS " Libraries: ${CMAKE_INSTALL_PREFIX}/${CCAP_INSTALL_LIBDIR}")
message(STATUS " Headers: ${CMAKE_INSTALL_PREFIX}/${CCAP_INSTALL_INCLUDEDIR}")
message(STATUS " CMake: ${CMAKE_INSTALL_PREFIX}/${CCAP_INSTALL_CMAKEDIR}")
endif ()
endif ()

# ############### Rust Bindings ################
option(CCAP_BUILD_RUST "Build Rust bindings" OFF)

if (CCAP_BUILD_RUST)
message(STATUS "ccap: Building Rust bindings")
# Find Rust/Cargo
find_program(CARGO_CMD cargo)
if (NOT CARGO_CMD)
message(WARNING "cargo not found - Rust bindings disabled")
else ()
message(STATUS "ccap: Found cargo: ${CARGO_CMD}")
# Add custom target to build Rust bindings
add_custom_target(ccap-rust
COMMAND ${CARGO_CMD} build --release
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/rust
COMMENT "Building Rust bindings"
DEPENDS ccap
)
# Add custom target to test Rust bindings
add_custom_target(ccap-rust-test
COMMAND ${CARGO_CMD} test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/rust
COMMENT "Testing Rust bindings"
DEPENDS ccap-rust
)
# Rust bindings are optional, do not add to main build automatically
# Users can explicitly build with: cmake --build . --target ccap-rust
message(STATUS "ccap: Rust bindings targets added:")
message(STATUS " ccap-rust: Build Rust bindings")
message(STATUS " ccap-rust-test: Test Rust bindings")
endif ()
endif ()
2 changes: 2 additions & 0 deletions bindings/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
image_capture/
Loading
Loading