Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
29b09fa
generate bindings
maxded Apr 24, 2025
6f93cdc
fix
maxded Apr 24, 2025
b8a971f
move into single workflow
maxded Apr 24, 2025
8478459
fix cross job
maxded Apr 24, 2025
974bfc9
fix..
maxded Apr 24, 2025
b3c8f82
generate bindings ci
maxded Apr 24, 2025
339228c
on push
maxded Apr 24, 2025
e819cbe
fix syntax
maxded Apr 24, 2025
82cace9
moar syntax
maxded Apr 24, 2025
60afef8
add target
maxded Apr 24, 2025
64b5b71
cross compile
maxded Apr 24, 2025
440a22e
fix build.rs
maxded Apr 24, 2025
5423a10
check
maxded Apr 24, 2025
9b5adeb
Windows on windows
maxded Apr 24, 2025
832a6de
add apple targets
maxded Apr 24, 2025
5cb898d
remove pregenerated bindings
maxded Apr 24, 2025
4ce62bc
fix bindings generation
maxded Apr 24, 2025
dea60a5
cleanup
maxded Apr 24, 2025
ba6c7c7
on push only
maxded Apr 24, 2025
8749f3c
Merge branch 'main' into generate-bindings
maxded Apr 24, 2025
803705e
remove armv7 test
maxded Apr 24, 2025
7cfdd7c
update bindgen and force rust target
maxded Apr 24, 2025
7f93635
remove rust target
maxded Apr 24, 2025
5504041
Update src/lib.rs
maxded Apr 24, 2025
c640950
remvoe info.text
maxded Apr 24, 2025
9226dea
Merge branch 'generate-bindings' of github.com:Traverse-Research/cpui…
maxded Apr 24, 2025
524acd1
update docs
maxded Apr 24, 2025
813c9a8
include 32bit targets
maxded Apr 24, 2025
ebabab4
add rust target to bindgen
maxded Apr 24, 2025
c5d8cd8
update proc-macro2 in minimal-versin check
maxded Apr 24, 2025
147179a
Update Cargo.toml
maxded Apr 25, 2025
4d17aae
feedback
maxded Apr 25, 2025
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
86 changes: 83 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CI

on:
push:
pull_request:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the pull_request one as it would trigger our CI jobs twice which isn't needed.


jobs:
rust:
Expand All @@ -14,8 +15,6 @@ jobs:
run: cargo fmt --all -- --check
- name: Cargo clippy
run: cargo clippy --workspace --all-targets -- -D warnings
- name: Cargo test
run: cargo test --workspace
Comment on lines -17 to -18
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this test here as it is already covered by another build step for all targets.


rust-msrv:
name: Build-test MSRV (1.74) with minimal crate dependencies
Expand All @@ -33,3 +32,84 @@ jobs:
- uses: dtolnay/rust-toolchain@1.74.0
- name: Cargo check
run: cargo check --workspace --all-targets

cross:
name: ${{ matrix.name }} (${{ matrix.target }})
runs-on: ${{ matrix.os }}
env:
PROGRAM: ${{ matrix.cross && 'cross' || 'cargo' }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: Linux
cross: false
test: true

- target: x86_64-apple-darwin
os: macos-latest
name: macOS
cross: false
test: true

- os: windows-latest
name: Windows
target: x86_64-pc-windows-msvc
cross: false
test: true

# - os: ubuntu-latest
# name: FreeBSD
# target: x86_64-unknown-freebsd
# cross: true
# test: false
Comment thread
maxded marked this conversation as resolved.

- target: aarch64-linux-android
os: ubuntu-latest
name: Android
cross: true
test: true

# - os: ubuntu-latest
# name: OpenWrt
# target: aarch64-unknown-linux-gnu
# cross: true
# test: true
# cargo_args: --features "openwrt"
Comment thread
maxded marked this conversation as resolved.

- target: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
name: Linux ARMv7
cross: true
test: true

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

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

- name: Install cross
run: cargo install cross
if: ${{ matrix.cross }}

- name: Build
run: ${{ env.PROGRAM }} build --target=${{ matrix.target }} ${{ matrix.cargo_args }}

- name: Test
run: ${{ env.PROGRAM }} test --target=${{ matrix.target }} ${{ matrix.cargo_args }}
if: ${{ matrix.test }}

- name: Run example
run: cargo run --example info
- uses: actions/upload-artifact@v4
with:
name: info-${{ matrix.target }}
path: info.txt
104 changes: 0 additions & 104 deletions .github/workflows/cross.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target
/Cargo.lock
info.txt
info.txt
Comment thread
maxded marked this conversation as resolved.
Outdated
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ include = ["src", "vendor", "examples", "LICENSE", "build.rs"]
categories = ["hardware-support"] # https://crates.io/category_slugs
keywords = []

[features]
generate_bindings = ["dep:bindgen"]

[dependencies]
bytemuck = "1"
serde = { version = "1", features = ["derive", "rc"] }
Expand All @@ -22,5 +19,5 @@ serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"

[build-dependencies]
bindgen = { version = "0.69", optional = true }
bindgen = { version = "0.69" }
cc = "1.1.0"
16 changes: 6 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,21 @@ fn main() {

build.compile("cpuinfo");

#[cfg(feature = "generate_bindings")]
generate_bindings("src/bindings.rs")
generate_bindings();
}

#[cfg(feature = "generate_bindings")]
fn generate_bindings(output_file: &str) {
fn generate_bindings() {
let dest = std::env::var("OUT_DIR").unwrap();
let dest = std::path::Path::new(&dest).join("bindings.rs");

let bindings = bindgen::Builder::default()
.header("vendor/cpuinfo/include/cpuinfo.h")
.raw_line("#![allow(non_upper_case_globals, non_snake_case, non_camel_case_types)]")
.raw_line("#![allow(dead_code)]")
.clang_args(&["-xc++", "-std=c++11"])
.layout_tests(false)
.generate()
.expect("Unable to generate bindings!");

bindings
.write_to_file(std::path::Path::new(output_file))
.write_to_file(dest)
.expect("Unable to write bindings!");
}

#[cfg(not(feature = "generate_bindings"))]
fn generate_bindings(_: &str) {}
Loading
Loading