Skip to content

Commit ff60f5a

Browse files
authored
wrap the C++ library in a -sys crate to ensure compatibility (#24)
This PR transforms the repo into a two crate workspace, one crate being a -sys wrapper crate around the c++ library, and the other being the higher level rust API you use.
1 parent 0c3875d commit ff60f5a

32 files changed

+1203
-349
lines changed

.github/workflows/rust.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Build - All Features
19-
run: cargo build --verbose --all-features
19+
run: RUSTFLAGS="-D warnings" cargo build --verbose --all-features
2020
- name: Build - Default
21-
run: cargo build --verbose
21+
run: RUSTFLAGS="-D warnings" cargo build --verbose --features="c-stubs"
2222
- name: Build - No Default Features
23-
run: cargo build --verbose --no-default-features
23+
run: RUSTFLAGS="-D warnings" cargo build --verbose --no-default-features --features="c-stubs"
2424
- name: Build - Check Examples & Tests
25-
run: cargo check --verbose --all-features --tests --examples
25+
run: RUSTFLAGS="-D warnings" cargo check --verbose --all-features --tests --examples
2626

2727
clippy:
2828
runs-on: ubuntu-latest
@@ -48,4 +48,4 @@ jobs:
4848
toolchain: nightly
4949
components: rustfmt
5050
override: true
51-
- run: rustfmt --check --edition 2018 ./src/* ./examples/*
51+
- run: rustfmt --check --edition 2018 ./*/src/* ./*/examples/* ./*/build.rs

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ Cargo.lock
99

1010
# These are backup files generated by rustfmt
1111
**/*.rs.bk
12+
13+
# mac stuff
14+
*.DS_Store

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "rpi-led-matrix-sys/cpp-library"]
2+
path = rpi-led-matrix-sys/cpp-library
3+
url = [email protected]:hzeller/rpi-rgb-led-matrix.git

.vscode/settings.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

Cargo.toml

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
1-
[package]
2-
name = "rpi-led-matrix"
3-
description = "Bindings for Hzeller's RPi-RGB-Led-Matrix"
4-
version = "0.2.2"
5-
authors = [
6-
"Vincent Pasquier <[email protected]>",
7-
"Tyler Holmes <[email protected]>",
8-
"Broderick Carlin <[email protected]>",
9-
]
10-
repository = "https://github.com/rust-rpi-led-matrix/rust-rpi-rgb-led-matrix"
11-
homepage = "https://docs.rs/rpi-led-matrix/"
12-
build = "build.rs"
13-
license = "GPL-3.0"
14-
readme = "README.md"
15-
edition = "2018"
16-
17-
[features]
18-
default = ["embeddedgraphics"]
19-
20-
embeddedgraphics = ["embedded-graphics"]
21-
args = ["clap"]
22-
23-
[build-dependencies]
24-
gcc = "0.3"
25-
26-
[dependencies]
27-
libc = "0.2"
28-
embedded-graphics = { version = "0.6.2", optional = true }
29-
clap = { version = "2.33", optional = true }
1+
[workspace]
302

31-
[[example]]
32-
name = "arguments"
33-
required-features = ["args"]
34-
35-
[[example]]
36-
name = "c-api-basic"
37-
required-features = ["args"]
38-
39-
[[example]]
40-
name = "embedded-graphics-basic"
41-
required-features = ["args", "embeddedgraphics"]
42-
43-
[package.metadata.docs.rs]
44-
all-features = true
3+
members = [
4+
"rpi-led-matrix",
5+
"rpi-led-matrix-sys",
6+
]
457

468
[profile.release]
479
codegen-units = 1

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Control RGB LED displays from Rust
22

3-
This repository contains rust bindings for the C++ library [rpi-rgb-led-matrix](https://github.com/hzeller/rpi-rgb-led-matrix),
4-
which enables controlling Hub75 based displays.
5-
In order to take advantage of the newer APIs, the minimum supported commit of the library is
6-
[55fa32f](https://github.com/hzeller/rpi-rgb-led-matrix/commit/55fa32fc2e02afb254ac834aea93589d5b891a11)
7-
(Sept. 7th, 2020), which exposes all parameters that affect how the matrix runs.
3+
This repository contains rust bindings for the C++ library
4+
[rpi-rgb-led-matrix](https://github.com/hzeller/rpi-rgb-led-matrix),
5+
which enables controlling Hub75 based displays. It includes both raw bindings
6+
to the library in [`rpi-led-matrix-sys`] as well as higher level, safe rust
7+
bindings in [`rpi-led-matrix`].
88

99
# Usage
1010

@@ -24,3 +24,6 @@ for red in 0..255 {
2424
}
2525
```
2626
Note that if you have wirings other than the libraries "default", you will need to construct arguments to the library to specify the layout. See `LedMatrixOptions` for more information.
27+
28+
[`rpi-led-matrix-sys`]: docs.rs/crate/rpi-led-matrix-sys
29+
[`rpi-led-matrix`]: docs.rs/crate/rpi-led-matrix

build.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"rust-analyzer.cargo.allFeatures": true
3+
}

rpi-led-matrix-sys/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - ???
9+
10+
- Initial release

rpi-led-matrix-sys/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "rpi-led-matrix-sys"
3+
version = "0.1.0"
4+
edition = "2018"
5+
description = "system library for the rpi-rgb-led-matrix C++ library"
6+
links = "rgbmatrixsys"
7+
build = "build.rs"
8+
license = "GPL-3.0"
9+
10+
[dependencies]
11+
libc = "0.2"
12+
13+
[build-dependencies]
14+
copy_dir = "0.1"
15+
16+
[features]
17+
default = []
18+
c-stubs = []
19+
20+
[package.metadata.docs.rs]
21+
all-features = true

0 commit comments

Comments
 (0)