Skip to content

Commit

Permalink
Arm build for Linux (#489)
Browse files Browse the repository at this point in the history
* Arm build for Linux, diferentiate Windows/macOS

* Use cross

* Fix cross and deb implementations

* Use Cross.toml as config
  • Loading branch information
jacksongoode authored Jul 6, 2024
1 parent f876f6d commit ea04b68
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 40 deletions.
67 changes: 45 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,44 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macOS-latest
- os: windows-latest

runs-on: ${{ matrix.os }}
env:
MACOSX_DEPLOYMENT_TARGET: 11.0
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Cache
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ hashFiles('Cross.toml') }}

- name: Install Linux Dependencies
- name: Install Cross
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libssl-dev libasound2-dev
run: cargo install cross

- name: Run Tests
run: cargo test
continue-on-error: true

- name: Build Release
if: runner.os != 'macOS'
run: cargo build --release
- name: Build (Linux)
if: runner.os == 'Linux'
run: cross build --release --target ${{ matrix.target }}

- name: Build x86_64 and aarch64 for macOS
- name: Build Release (macOS)
if: runner.os == 'macOS'
run: |
rustup target add x86_64-apple-darwin aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin --target aarch64-apple-darwin
- name: Build Release (Windows)
if: runner.os == 'Windows'
run: cargo build --release

- name: Cache cargo-bundle
if: runner.os == 'macOS'
id: cache-cargo-bundle
Expand Down Expand Up @@ -96,14 +105,14 @@ jobs:

- name: Make Linux Binary Executable
if: runner.os == 'Linux'
run: chmod +x target/release/psst-gui
run: chmod +x target/${{ matrix.target }}/release/psst-gui

- name: Upload Linux Binary
uses: actions/upload-artifact@v4
if: runner.os == 'Linux'
with:
name: psst-gui
path: target/release/psst-gui
name: psst-gui-${{ matrix.target }}
path: target/${{ matrix.target }}/release/psst-gui

- name: Upload Windows Executable
uses: actions/upload-artifact@v4
Expand All @@ -115,18 +124,27 @@ jobs:
deb:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
- arch: amd64
target: x86_64-unknown-linux-gnu
- arch: arm64
target: aarch64-unknown-linux-gnu
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Download Linux Binary
- name: Download Linux Binaries
uses: actions/download-artifact@v4
with:
name: psst-gui
path: ${{runner.workspace}}
name: psst-gui-${{ matrix.target }}
path: ${{runner.workspace}}/binaries

- name: Move Binary
run: mkdir -p ${{runner.workspace}}/pkg/usr/bin/; mv ${{runner.workspace}}/psst-gui $_
run: |
mkdir -p ${{runner.workspace}}/pkg/usr/bin/
mv ${{runner.workspace}}/binaries/psst-gui ${{runner.workspace}}/pkg/usr/bin/
- name: Move Desktop Entry
run: mkdir -p ${{runner.workspace}}/pkg/usr/share/applications/; mv .pkg/psst.desktop $_
Expand All @@ -150,18 +168,23 @@ jobs:
run: mkdir -p ${{runner.workspace}}/pkg/usr/share/doc/psst-gui/; mv .pkg/copyright $_

- name: Move Package Config
run: mkdir -p ${{runner.workspace}}/pkg/; mv .pkg/DEBIAN $_/
run: |
mkdir -p ${{runner.workspace}}/pkg/
cp -r .pkg/DEBIAN $_/
sed -i 's/Architecture: amd64/Architecture: ${{ matrix.arch }}/' ${{runner.workspace}}/pkg/DEBIAN/control
- name: Set Version
run: "echo Version: $(git rev-list --count HEAD) >> ${{runner.workspace}}/pkg/DEBIAN/control"

- name: Build Package
run: cat ${{runner.workspace}}/pkg/DEBIAN/control && dpkg-deb -b ${{runner.workspace}}/pkg/ psst_$(git rev-list --count HEAD)_amd64.deb
run: |
cat ${{runner.workspace}}/pkg/DEBIAN/control
dpkg-deb -b ${{runner.workspace}}/pkg/ psst_$(git rev-list --count HEAD)_${{ matrix.arch }}.deb
- name: Upload Debian Package
uses: actions/upload-artifact@v4
with:
name: psst-deb
name: psst-deb-${{ matrix.arch }}
path: "*.deb"

appimage:
Expand Down
8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
[workspace]
resolver = "2"
members = [
"psst-protocol",
"psst-core",
"psst-cli",
"psst-gui",
]
members = ["psst-protocol", "psst-core", "psst-cli", "psst-gui"]

[profile.release]
opt-level = 3
Expand All @@ -15,5 +10,6 @@ codegen-units = 1

[profile.dev.package.symphonia]
opt-level = 2

[profile.dev.package.libsamplerate]
opt-level = 2
14 changes: 14 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[build]
pre-build = ["""
dpkg --add-architecture $CROSS_DEB_ARCH && \
apt-get update && apt-get --assume-yes install \
libgtk-3-dev:$CROSS_DEB_ARCH \
libssl-dev:$CROSS_DEB_ARCH \
libasound2-dev:$CROSS_DEB_ARCH
"""]

[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:edge"

[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge"
24 changes: 16 additions & 8 deletions psst-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,21 @@ ureq = { version = "2.8.0", features = ["json", "socks-proxy"] }
url = { version = "2.4.1" }

# GUI
druid = { git = "https://github.com/jpochyla/druid", branch = "psst", features = ["im", "image", "jpeg", "png", "serde"] }
druid = { git = "https://github.com/jpochyla/druid", branch = "psst", features = [
"im",
"image",
"jpeg",
"png",
"serde",
] }
druid-enums = { git = "https://github.com/jpochyla/druid-enums" }
druid-shell = { git = "https://github.com/jpochyla/druid", branch = "psst", features = ["raw-win-handle"] }
druid-shell = { git = "https://github.com/jpochyla/druid", branch = "psst", features = [
"raw-win-handle",
] }
open = { version = "5.0.0" }
raw-window-handle = { version = "0.5.2" } # Must stay compatible with Druid
souvlaki = { version = "0.6.1" }
webbrowser = {version = "0.8.11"}
webbrowser = { version = "0.8.11" }

[target.'cfg(windows)'.build-dependencies]
winres = { version = "0.1.12" }
Expand All @@ -52,11 +60,11 @@ image = { version = "0.24.7" }
name = "Psst"
identifier = "com.jpochyla.psst"
icon = [
"assets/logo_32.png",
"assets/logo_64.png",
"assets/logo_128.png",
"assets/logo_256.png",
"assets/logo_512.png",
"assets/logo_32.png",
"assets/logo_64.png",
"assets/logo_128.png",
"assets/logo_256.png",
"assets/logo_512.png",
]
version = "0.1.0"
resources = []
Expand Down
8 changes: 4 additions & 4 deletions psst-gui/src/data/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct PlaylistRemoveTrack {
pub struct Playlist {
pub id: Arc<str>,
pub name: Arc<str>,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub images: Option<Vector<Image>>,
pub description: Arc<str>,
#[serde(rename = "tracks")]
Expand All @@ -46,9 +46,9 @@ impl Playlist {
}

pub fn image(&self, width: f64, height: f64) -> Option<&Image> {
self.images.as_ref().and_then(|images| {
Image::at_least_of_size(images, width, height)
})
self.images
.as_ref()
.and_then(|images| Image::at_least_of_size(images, width, height))
}

pub fn url(&self) -> String {
Expand Down

0 comments on commit ea04b68

Please sign in to comment.