Skip to content

Commit

Permalink
ci: improve pkg-config configuration and formatting
Browse files Browse the repository at this point in the history
- Add PKG_CONFIG_LIBDIR to both CI and release workflows
- Format YAML files for better readability
- Simplify Cross.arch.toml commands
- Move build.env to Cross.toml for pkg-config passthrough
  • Loading branch information
aljen committed Dec 1, 2024
1 parent 0850106 commit d1b2961
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
branches: [ "master" ]
branches: ["master"]
workflow_call:

env:
Expand All @@ -21,17 +21,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev pkg-config
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache cargo
uses: actions/cache@v3
with:
Expand All @@ -40,13 +40,13 @@ jobs:
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Check formatting
run: cargo fmt --all -- --check

- name: Check clippy
run: cargo clippy -- -D warnings

- name: Run tests
run: cargo test --all-features

Expand All @@ -63,12 +63,12 @@ jobs:

steps:
- uses: actions/checkout@v4

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

- name: Install cross
uses: taiki-e/install-action@cross

Expand All @@ -91,13 +91,13 @@ jobs:
key: ${{ runner.os }}-cross-${{ matrix.target }}-${{ hashFiles('Cross.toml') }}
restore-keys: |
${{ runner.os }}-cross-${{ matrix.target }}-
- name: Install target specific dependencies
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev dpkg-dev
- name: Set library path
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
Expand All @@ -109,6 +109,7 @@ jobs:
PKG_CONFIG_ALLOW_CROSS: "1"
PKG_CONFIG_PATH: "/usr/lib/${{ matrix.target }}/pkgconfig"
PKG_CONFIG_SYSROOT_DIR: "/usr"
PKG_CONFIG_LIBDIR: "/usr/lib/${{ matrix.target }}/pkgconfig"
run: |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
cargo build --release --target ${{ matrix.target }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
PKG_CONFIG_ALLOW_CROSS: "1"
PKG_CONFIG_PATH: "/usr/lib/${{ matrix.target }}/pkgconfig"
PKG_CONFIG_SYSROOT_DIR: "/usr"
PKG_CONFIG_LIBDIR: "/usr/lib/${{ matrix.target }}/pkgconfig"
run: |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
cargo build --release --target ${{ matrix.target }}
Expand Down
10 changes: 2 additions & 8 deletions Cross.arch.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
[target.aarch64-unknown-linux-gnu]
pre-build = [
"pacman -Syu --noconfirm",
"pacman -S --noconfirm systemd-libs"
]
pre-build = ["pacman -Syu --noconfirm", "pacman -S --noconfirm systemd-libs"]

[target.armv7-unknown-linux-gnueabihf]
pre-build = [
"pacman -Syu --noconfirm",
"pacman -S --noconfirm systemd-libs"
]
pre-build = ["pacman -Syu --noconfirm", "pacman -S --noconfirm systemd-libs"]
23 changes: 13 additions & 10 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
[target.aarch64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture arm64 && apt-get update && apt-get install -y libudev-dev:arm64",
]

[target.armv7-unknown-linux-gnueabihf]
pre-build = [
"dpkg --add-architecture armhf && apt-get update && apt-get install -y libudev-dev:armhf",
]

[build.env]
passthrough = [
"PKG_CONFIG_ALLOW_CROSS",
"PKG_CONFIG_PATH",
"PKG_CONFIG_SYSROOT_DIR",
"PKG_CONFIG_LIBDIR",
]

[target.aarch64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture arm64",
"apt-get update",
"apt-get install --assume-yes libudev-dev:arm64 pkg-config",
]
[target.armv7-unknown-linux-gnueabihf]
pre-build = [
"dpkg --add-architecture armhf",
"apt-get update",
"apt-get install --assume-yes libudev-dev:armhf pkg-config",
]

0 comments on commit d1b2961

Please sign in to comment.