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

Fix/windows build #312

Merged
merged 12 commits into from
Oct 26, 2024
24 changes: 13 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
pull_request:
workflow_dispatch:

env:
rust_version: "1.82.0"

jobs:
pre_job:
# continue-on-error: true # Uncomment once integration is finished
Expand Down Expand Up @@ -33,17 +36,17 @@ jobs:
- uses: actions/checkout@v4
name: Checkout onto ${{ runner.os }}
- if: runner.os == 'Linux'
name: apt install gstreamer
name: apt install linux deps
run: |
sudo apt update
sudo apt install -y aptitude
sudo aptitude install -y libgstrtspserver-1.0-dev libgstreamer1.0-dev libgtk2.0-dev protobuf-compiler libssl-dev
- if: runner.os == 'Windows'
name: Install Gstreamer
name: Install Windows deps
run: |
# Gstreamer
choco install -y --no-progress gstreamer --version=1.20.0
choco install -y --no-progress gstreamer-devel --version=1.20.0
choco install -y --no-progress gstreamer --version=1.24.2
choco install -y --no-progress gstreamer-devel --version=1.24.2
$env:GSTREAMER_1_0_ROOT_MSVC_X86_64=$env:SYSTEMDRIVE + '\gstreamer\1.0\msvc_x86_64\'
# Github runners work on both C or D drive and figuring out which was used is difficult
if (-not (Test-Path -Path "$env:GSTREAMER_1_0_ROOT_MSVC_X86_64" -PathType Container)) {
Expand Down Expand Up @@ -71,21 +74,17 @@ jobs:
$env:OPENSSL_DIR='D:\\Program Files\OpenSSL\'
}

# Set up pkgconfig for gstreamer
$env:PKG_CONFIG_PATH += ';' + $env:GSTREAMER_1_0_ROOT_MSVC_X86_64 + '\lib\pkgconfig'

# Set github vars
Add-Content -Path $env:GITHUB_ENV -Value "GSTREAMER_1_0_ROOT_MSVC_X86_64=$env:GSTREAMER_1_0_ROOT_MSVC_X86_64"
Add-Content -Path $env:GITHUB_PATH -Value "$env:GSTREAMER_1_0_ROOT_MSVC_X86_64\bin"
Add-Content -Path $env:GITHUB_PATH -Value "%GSTREAMER_1_0_ROOT_MSVC_X86_64%\bin"
Add-Content -Path $env:GITHUB_ENV -Value "OPENSSL_DIR=$env:OPENSSL_DIR"
Add-Content -Path $env:GITHUB_ENV -Value "PKG_CONFIG_PATH=$env:PKG_CONFIG_PATH"

# One last check on directories
dir "$env:GSTREAMER_1_0_ROOT_MSVC_X86_64"
dir "$env:OPENSSL_DIR"
- if: runner.os == 'macOS'
name: Install Gstreamer on macOS
name: Install macOS deps
run: |
curl -L 'https://gstreamer.freedesktop.org/data/pkg/osx/1.20.4/gstreamer-1.0-devel-1.20.4-universal.pkg' -o "$(pwd)/gstreamer-devel.pkg"
sudo installer -verbose -pkg "$(pwd)/gstreamer-devel.pkg" -target /
Expand Down Expand Up @@ -182,6 +181,7 @@ jobs:
echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
- name: Install ${{ matrix.arch }} Rust toolchain
run: |
rustup default "${{ env.rust_version }}"
rustup target add ${TARGET}
env:
TARGET: ${{ matrix.target }}
Expand Down Expand Up @@ -286,8 +286,9 @@ jobs:
echo "TAGS=${tagstr}" >> "${GITHUB_OUTPUT}"
env:
REPO_NAME: ${{ steps.docker_repo.outputs.DOCKER_NWO }}
- name: Install latest rust
- name: Install rust
run: |
rustup default "${{ env.rust_version }}"
rustup toolchain install stable
- name: Install toml-cli
run: |
Expand Down Expand Up @@ -345,8 +346,9 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install latest rust
- name: Install rust
run: |
rustup default "${{ env.rust_version }}"
rustup toolchain install stable
- name: Install toml-cli
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/style_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ jobs:
rustup override set nightly
- name: Run clippy manually
run: |
echo "All Features"
cargo +nightly clippy --workspace --all-targets --all-features || exit 1
echo "No Features"
cargo +nightly clippy --workspace --all-targets --no-default-features || exit 1
echo "Gstreamer Only"
cargo +nightly clippy --workspace --all-targets --no-default-features --features=gstreamer || exit 1
echo "Pushnoti Only"
cargo +nightly clippy --workspace --all-targets --no-default-features --features=pushnoti || exit 1

check_fmt:
Expand Down
25 changes: 3 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions crates/core/src/bc/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ fn bc_modern_msg<'a>(
E::add_context(input, ctx, E::from_error_kind(input, kind))
}

let ext_len = match header.payload_offset {
Some(off) => off,
_ => 0, // If missing payload_offset treat all as payload
};
// If missing payload_offset treat all as payload
let ext_len = header.payload_offset.unwrap_or_default();

let (buf, ext_buf) = take(ext_len)(buf)?;
let payload_len = header.body_len - ext_len;
Expand Down
11 changes: 3 additions & 8 deletions crates/core/src/bc/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ pub struct BcMeta {
pub stream_type: u8,
/// On modern messages this is the response code
/// When sending a command it is set to `0`. The reply from the camera can be
///
/// - `200` for OK
///
/// - `400` for bad request
///
/// A malformed packet will return a `400` code
pub response_code: u16,
/// A message ID is used to match replies with requests. The camera will parrot back
Expand All @@ -213,14 +216,6 @@ pub struct BcMeta {
pub class: u16,
}

/// The components of the Baichuan header that must be filled out after the body is serialized, or
/// is needed for the deserialization of the body (strictly part of the wire format of the message)
#[derive(Debug, PartialEq, Eq)]
pub(super) struct BcSendInfo {
pub body_len: u32,
pub payload_offset: Option<u32>,
}

#[derive(Debug)]
pub(crate) struct BcContext {
pub(crate) credentials: Credentials,
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/bc_protocol/connection/bcsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub struct BcStream<'a> {
rx: &'a mut ReceiverStream<Result<Bc>>,
}

impl<'a> Unpin for BcStream<'a> {}
impl Unpin for BcStream<'_> {}

impl<'a> Stream for BcStream<'a> {
impl Stream for BcStream<'_> {
type Item = Result<Bc>;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bc>>> {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/bc_protocol/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl ToSocketAddrsOrUid for SocketAddrV6 {
}
}

impl<'a> ToSocketAddrsOrUid for &'a [SocketAddr] {
impl ToSocketAddrsOrUid for &'_ [SocketAddr] {
type UidIter = std::vec::IntoIter<SocketAddrOrUid>;

fn to_socket_addrs_or_uid(&self) -> Result<Self::UidIter, Error> {
Expand Down
9 changes: 0 additions & 9 deletions crates/core/src/bcudp/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ impl Decoder for BcUdpCodex {
type Item = BcUdp;
type Error = Error;

/// Since frames can cross EOF boundaries we overload this so it doesn't error if
/// there are bytes left on the stream
// fn decode_eof(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>> {
// match self.decode(buf)? {
// Some(frame) => Ok(Some(frame)),
// None => Ok(None),
// }
// }

fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>> {
log::trace!("Decoding:");
if src.is_empty() {
Expand Down
8 changes: 0 additions & 8 deletions crates/mailnoti/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ async fn main() -> Result<()> {
Ok(())
}

fn get_local_ip() -> Result<std::net::IpAddr> {
get_if_addrs::get_if_addrs()?
.iter()
.find(|i| !i.is_loopback() && matches!(i.addr, get_if_addrs::IfAddr::V4(_)))
.map(|iface| Ok(iface.ip()))
.unwrap_or_else(|| Err(anyhow!("No Local Ip Address Found")))
}

async fn cam_tasks(name: &str, camera: BcCamera, addr: SocketAddr) -> Result<()> {
let support = camera.get_support().await?;
if support.email.is_some_and(|v| v > 0) {
Expand Down
Loading
Loading