Skip to content

Commit

Permalink
Fix Windows build & GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sorz committed Jan 10, 2024
1 parent 8242a06 commit 7de41c4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: build-package
on:
push:
tags:
- '*'
- 'v*'

jobs:
release:
name: Release - ${{ matrix.platform.release_for }}
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/tags/test-release'
if: startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -37,18 +37,24 @@ jobs:
suffix: linux_armv7_gnueabihf.bin
toolchain: stable

- release_for: Android-aarch64
os: ubuntu-latest
target: aarch64-linux-android
suffix: linux_aarch64_android.bin
toolchain: stable
# Disabled until corss release a new version
# https://github.com/cross-rs/cross/issues/1222
#
#- release_for: Android-aarch64
# os: ubuntu-latest
# target: aarch64-linux-android
# suffix: linux_aarch64_android.bin
# toolchain: stable

runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup cache
uses: Swatinem/rust-cache@v2
- name: Install musl-tools
if: contains(matrix.platform.target, 'linux-musl')
run: sudo apt install musl-tools
- name: Build
uses: houseabsolute/actions-rust-cross@v0
with:
Expand All @@ -60,7 +66,7 @@ jobs:
- name: Packaging for Debian
if: matrix.platform.target == 'x86_64-unknown-linux-gnu'
run: |
cargo install deb
cargo install cargo-deb
cargo deb --target=${{ matrix.platform.target }} --no-build
- name: Packaging binary
run: |
Expand Down
13 changes: 11 additions & 2 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ use std::{
sync::Arc,
time::{Duration, Instant},
};
#[cfg(unix)]
use tokio::net::{UnixListener, UnixStream};
use tokio::{
self,
io::{AsyncRead, AsyncWrite},
net::{TcpListener, TcpStream, UnixListener, UnixStream},
net::{TcpListener, TcpStream},
};
use tracing::{info, instrument, warn};

Expand Down Expand Up @@ -224,6 +226,7 @@ fn response(req: &Request<Incoming>, start_time: Instant, monitor: Monitor) -> B
#[derive(Debug, Clone)]
enum ListenAddr {
TcpSocket(SocketAddr),
#[cfg(unix)]
UnixPath(SharedStr),
}

Expand All @@ -247,6 +250,7 @@ impl Accept<TcpStream> for TcpListener {
}
}

#[cfg(unix)]
impl Accept<UnixStream> for UnixListener {
async fn accept(&self) -> io::Result<UnixStream> {
let (client, _) = self.accept().await?;
Expand All @@ -273,7 +277,12 @@ impl WebServer {
.context("Not valid TCP socket address for web server")?;
ListenAddr::TcpSocket(addr)
} else {
ListenAddr::UnixPath(bind_addr)
#[cfg(unix)]
{
ListenAddr::UnixPath(bind_addr)
}
#[cfg(not(unix))]
anyhow::bail!("No UNIX domain socket support on this system")
};
Ok(Self { monitor, bind_addr })
}
Expand Down

0 comments on commit 7de41c4

Please sign in to comment.