Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt cross-compilation in ci #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ jobs:

build-release:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
needs: ['prepare-env']
name: build-release
runs-on: ${{ matrix.os }}
Expand All @@ -48,9 +51,9 @@ jobs:
# install rust
- run: rustup show && rustup target add ${{ matrix.target }}
# install dependencies
- run: just setup
- run: cargo install cross --git https://github.com/cross-rs/cross
# build (generates binaries)
- run: just build --locked --release --target=${{ matrix.target }}
- run: cross build --all --all-features --locked --release --target=${{ matrix.target }}
- run: cargo test --locked manpage
# create archive
- name: Archive
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ env:

jobs:
verify:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
name: Build & Test
runs-on: ubuntu-latest
steps:
Expand All @@ -18,7 +26,7 @@ jobs:
- uses: extractions/setup-just@v1
# setup rust toolchain
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- run: rustup show
- run: rustup show && rustup target add ${{ matrix.target }}
# cache
- uses: actions/cache@v3
with:
Expand All @@ -34,12 +42,15 @@ jobs:
~/.cargo/.crates.toml
~/.cargo/.crates2.json
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}

# install dependencies
- run: cargo install cross --git https://github.com/cross-rs/cross
# verify
- run: just setup
- run: just build
- run: DEBUG=1 just test
- run: cross build --all --all-features --target ${{ matrix.target }}
# TODO: tests don't work for aarch64 in CI right now
- if: ${{ matrix.target }} == 'x86_64-unknown-linux-gnu'
run: DEBUG=1 just test

release-aur-git:
name: Update AUR(i3stat-git)
Expand Down
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,10 @@ strip = true
lto = true
codegen-units = 1
panic = "abort"

# cross configuration
[package.metadata.cross.target.aarch64-unknown-linux-gnu]
image = "acheronfail/i3stat_aarch64-unknown-linux-gnu"

[package.metadata.cross.target.x86_64-unknown-linux-gnu]
image = "acheronfail/i3stat_x86_64-unknown-linux-gnu"
12 changes: 12 additions & 0 deletions cross/aarch64-meson.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[binaries]
c = 'aarch64-linux-gnu-gcc'
cpp = 'aarch64-linux-gnu-g++'
ar = 'aarch64-linux-gnu-ar'
strip = 'aarch64-linux-gnu-strip'
pkgconfig = 'aarch64-linux-gnu-pkg-config'

[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'
75 changes: 75 additions & 0 deletions cross/aarch64-unknown-linux-gnu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main

ENV DEBIAN_FRONTEND=noninteractive TZ=Europe/London
RUN dpkg --add-architecture arm64 && apt-get update

RUN apt-get install -y \
build-essential \
clang \
dbus \
dunst \
i3-wm \
imagemagick \
libfaketime \
libiw-dev \
libx11-dev:arm64 \
scrot \
xserver-xephyr \
xvfb

# NOTE: we build and install libpulse manually ourselves, since the version in
# cross' current image is too low (v13). We need at least v14.
RUN apt-get install -y \
autopoint \
bash-completion \
check:arm64 \
curl \
dbus-x11 \
dpkg-dev \
g++ \
gcc \
gettext \
git-core \
libasound2-dev \
libasyncns-dev \
libavahi-client-dev \
libbluetooth-dev \
libcap-dev:arm64 \
libdbus-1-dev:arm64 \
libfftw3-dev \
libglib2.0-dev \
libgtk-3-dev \
libice-dev \
libjack-dev \
liblircclient-dev \
libltdl-dev:arm64 \
liborc-0.4-dev \
libsbc-dev:arm64 \
libsndfile1-dev:arm64 \
libsoxr-dev \
libspeexdsp-dev \
libssl-dev \
libsystemd-dev \
libtdb-dev:arm64 \
libudev-dev \
libwebrtc-audio-processing-dev \
libwrap0-dev \
libx11-xcb-dev \
libxcb1-dev \
libxml-parser-perl \
libxml2-utils \
libxtst-dev \
m4 \
meson \
ninja-build \
pkg-config:arm64 \
python3-setuptools \
systemd \
wget
RUN rm -rf /opt/pulseaudio && git clone \
--depth 1 \
--branch stable-14.x \
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git \
/opt/pulseaudio
COPY ./cross/aarch64-meson.txt /opt/pulseaudio/aarch64-meson.txt
RUN cd /opt/pulseaudio && meson --cross-file aarch64-meson.txt build && cd build && ninja && ninja install
71 changes: 71 additions & 0 deletions cross/x86_64-unknown-linux-gnu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
FROM ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main

ENV DEBIAN_FRONTEND=noninteractive TZ=Europe/London

RUN apt-get install -y \
build-essential \
clang \
dbus \
dunst \
i3-wm \
imagemagick \
libfaketime \
libiw-dev \
libx11-dev \
scrot \
xserver-xephyr \
xvfb

# NOTE: we build and install libpulse manually ourselves, since the version in
# cross' current image is too low (v13). We need at least v14.
RUN apt-get install -y \
autopoint \
bash-completion \
check \
curl \
dbus-x11 \
g++ \
gcc \
gettext \
git-core \
libasound2-dev \
libasyncns-dev \
libavahi-client-dev \
libbluetooth-dev \
libcap-dev \
libfftw3-dev \
libglib2.0-dev \
libgtk-3-dev \
libice-dev \
libjack-dev \
liblircclient-dev \
libltdl-dev \
liborc-0.4-dev \
libsbc-dev \
libsndfile1-dev \
libsoxr-dev \
libspeexdsp-dev \
libssl-dev \
libsystemd-dev \
libtdb-dev \
libudev-dev \
libwebrtc-audio-processing-dev \
libwrap0-dev \
libx11-xcb-dev \
libxcb1-dev \
libxml-parser-perl \
libxml2-utils \
libxtst-dev \
m4 \
meson \
ninja-build \
pkg-config \
python3-setuptools \
systemd \
wget
RUN rm -rf /opt/pulseaudio && git clone \
--depth 1 \
--branch stable-14.x \
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git \
/opt/pulseaudio
RUN cd /opt/pulseaudio && meson build && cd build && ninja && ninja install
3 changes: 0 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ setup:
@check +CMDS:
echo {{CMDS}} | xargs -n1 sh -c 'if ! command -v $1 >/dev/null 2>&1 /dev/null; then echo "$1 is required!"; exit 1; fi' bash

# build the crate
build *args:
cargo build --all --all-features {{args}}
_lbuild:
cargo lbuild --all

Expand Down
Loading