Skip to content

Commit

Permalink
Merge pull request #9 from Ragarnoy/feat/major-rework
Browse files Browse the repository at this point in the history
Rework library and bump rss version
  • Loading branch information
Ragarnoy authored Nov 8, 2024
2 parents f234826 + d74c28f commit 4c9a7f9
Show file tree
Hide file tree
Showing 15 changed files with 628 additions and 378 deletions.
11 changes: 11 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
publish = true

[package.metadata.release]
sign-commit = true
sign-tag = true
push = true
publish = true
pre-release-commit-message = "Release version {{version}}"
tag-message = "Release version {{version}}"
tag-prefix = "v"
23 changes: 0 additions & 23 deletions .github/DOCS.md

This file was deleted.

98 changes: 33 additions & 65 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
# This workflow runs whenever a PR is opened or updated, or a commit is pushed to main. It runs
# several checks:
# - fmt: checks that the code is formatted according to rustfmt
# - clippy: checks that the code does not contain any clippy warnings
# - doc: checks that the code can be documented without errors
# - hack: check combinations of feature flags
# - msrv: check that the msrv specified in the crate is correct
name: check
permissions:
contents: read
# This configuration allows maintainers of this repo to create a branch and pull request based on
# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets
# built once.
checks: write # Required for clippy-action comments

on:
push:
branches: [main]
pull_request:
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: check

env:
#CPATH: "/usr/lib/arm-none-eabi/include"
CARGO_TERM_COLOR: always
CPATH: "/home/runner/gcc-arm-none-eabi-9.2020.2-linux/gcc-arm-none-eabi-9-2020-q2-update/include"
ACC_RSS_LIBS: "/home/runner/work/a121-rs/a121-rs/staticlibs"

jobs:
fmt:
runs-on: ubuntu-latest
Expand All @@ -38,16 +31,13 @@ jobs:
components: rustfmt
- name: cargo fmt --check
run: cargo fmt --check

clippy:
runs-on: ubuntu-latest
name: ${{ matrix.toolchain }} / clippy
permissions:
contents: read
checks: write
strategy:
fail-fast: false
matrix:
# Get early warning of new lints which are regularly introduced in beta channels.
toolchain: [stable, beta]
steps:
- uses: actions/checkout@v4
Expand All @@ -58,83 +48,65 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
- name: Install ARM toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '9-2020-q2'
- name: Create lib directory
run: mkdir -p "$ACC_RSS_LIBS"
- name: cargo clippy
uses: giraffate/clippy-action@v1
with:
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}

doc:
# run docs generation on nightly rather than stable. This enables features like
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
# API be documented as only available in some specific platforms.
runs-on: ubuntu-latest
name: nightly / doc
strategy:
matrix:
target: [thumbv7em-none-eabihf]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
- name: Install ARM toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '9-2020-q2'
- name: rustup target add ${{ matrix.target }}
run: rustup target add ${{ matrix.target }}
working-directory: ${{ matrix.crate }}
- name: mkdir $ACC_RSS_LIBS
- name: Create lib directory
run: mkdir -p "$ACC_RSS_LIBS"
- name: cargo doc
run: cargo doc --no-deps --all-features
working-directory: ${{ matrix.crate }}
- name: Install cargo-docs-rs
uses: dtolnay/install@cargo-docs-rs
- name: cargo docs-rs
run: cargo docs-rs
env:
RUSTDOCFLAGS: --cfg docsrs
hack:
# cargo-hack checks combinations of feature flags to ensure that features are all additive
# which is required for feature unification
RUSTDOCFLAGS: "--cfg docsrs"

features:
runs-on: ubuntu-latest
name: ubuntu / stable / features
strategy:
matrix:
target: [thumbv7em-none-eabihf]
name: stable / features
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: Install ARM toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '9-2020-q2'
- name: rustup target add ${{ matrix.target }}
run: rustup target add ${{ matrix.target }}
working-directory: ${{ matrix.crate }}
- name: Create lib directory
run: mkdir -p "$ACC_RSS_LIBS"
- name: cargo install cargo-hack
uses: taiki-e/install-action@cargo-hack
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
# --feature-powerset runs for every combination of features
- name: mkdir $ACC_RSS_LIBS
run: mkdir -p "$ACC_RSS_LIBS"
- name: cargo hack
run: cargo hack --feature-powerset check
working-directory: ${{ matrix.crate }}

msrv:
# check that we can build using the minimal rust version that is specified by this crate
runs-on: ubuntu-latest
# we use a matrix here just because env can't be used in job names
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
matrix:
msrv: ["1.77"]
target: [thumbv7em-none-eabihf]
msrv: ["1.82"]
name: ubuntu / ${{ matrix.msrv }}
steps:
- uses: actions/checkout@v4
Expand All @@ -144,15 +116,11 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.msrv }}
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
- name: Install ARM toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '9-2020-q2'
- name: rustup target add ${{ matrix.target }}
run: rustup target add ${{ matrix.target }}
working-directory: ${{ matrix.crate }}
- name: mkdir $ACC_RSS_LIBS
- name: Create lib directory
run: mkdir -p "$ACC_RSS_LIBS"
- name: cargo +${{ matrix.msrv }} check
run: cargo check
working-directory: ${{ matrix.crate }}
- name: cargo check
run: cargo check --all-features
82 changes: 82 additions & 0 deletions .github/workflows/nostd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: no-std
permissions:
contents: read

on:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
ACC_RSS_LIBS: "/home/runner/work/a121-sys/a121-sys/staticlibs"
BINDGEN_EXTRA_CLANG_ARGS: "--target=arm-none-eabi -mcpu=cortex-m4"
LIBCLANG_PATH: "/usr/lib/llvm-14/lib"

jobs:
nostd:
runs-on: ubuntu-latest
name: ${{ matrix.target }}
strategy:
matrix:
target: [thumbv7em-none-eabihf]
steps:
- uses: actions/checkout@v4
with:
submodules: true

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

- name: Install ARM toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '9-2020-q2'

- name: Install LLVM and Clang
run: |
sudo apt-get update
sudo apt-get install -y llvm-14-dev libclang-14-dev clang-14
- name: Create lib directory
run: mkdir -p "$ACC_RSS_LIBS"

# Setup correct paths
- name: Setup ARM GCC paths
run: |
GCC_ARM_PATH=$(dirname $(dirname $(which arm-none-eabi-gcc)))
echo "ARM_GCC_PATH=${GCC_ARM_PATH}" >> $GITHUB_ENV
echo "CPATH=${GCC_ARM_PATH}/arm-none-eabi/include:${GCC_ARM_PATH}/lib/gcc/arm-none-eabi/9.2.1/include" >> $GITHUB_ENV
# Debug step to verify paths
- name: Debug environment
run: |
echo "ARM_GCC_PATH=$ARM_GCC_PATH"
echo "CPATH=$CPATH"
ls -la "$ARM_GCC_PATH/arm-none-eabi/include" || true
ls -la "$ARM_GCC_PATH/lib/gcc/arm-none-eabi/9.2.1/include" || true
which arm-none-eabi-gcc
arm-none-eabi-gcc -print-sysroot
- name: cargo check
run: cargo check --target ${{ matrix.target }} --features="stub_library,distance,presence"
env:
CC_thumbv7em_none_eabihf: arm-none-eabi-gcc
AR_thumbv7em_none_eabihf: arm-none-eabi-ar
RUSTFLAGS: "-C link-arg=-nostartfiles"

# Upload build logs on failure
- name: Upload build logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: build-logs
path: |
target/thumbv7em-none-eabihf/debug/build/*/output
target/thumbv7em-none-eabihf/debug/build/*/stderr
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Build Release
run: cargo build --release

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./target/release/liba121_sys.a
asset_name: liba121_sys.a
asset_content_type: application/octet-stream
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ readme = "README.md"
license = "MIT"
edition = "2021"
version = "0.4.0"
rust-version = "1.77"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
rust-version = "1.82"
build = "build/mod.rs"

[dependencies]

[build-dependencies]
bindgen = { version = "0.69" }
cc = "1.0"
bindgen = { version = "0.70.1" }
cc = "1.1"

[features]
stub_library = []
distance = []
presence = []
std = []

[profile.release]
codegen-units = 1
Expand Down
Loading

0 comments on commit 4c9a7f9

Please sign in to comment.