Skip to content
Merged
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
35 changes: 28 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: CI
on:
"on":
pull_request:
push:
branches:
Expand All @@ -11,15 +12,34 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-18.04
# Ubuntus
- os: ubuntu-latest
binary_target: x86_64-unknown-linux-musl
needs_musl: true
- os: ubuntu-18.04
toolchain: stable
- os: ubuntu-20.04
binary_target: x86_64-unknown-linux-gnu
- os: macos-10.15
toolchain: stable

# MacOS
- os: macos-11
binary_target: x86_64-apple-darwin
toolchain: stable

# Windows
- os: windows-latest
binary_target: x86_64-pc-windows-msvc
toolchain: stable

# Nightly Rust
- os: ubuntu-latest
binary_target: x86_64-unknown-linux-gnu
toolchain: nightly

# MSRV
- os: ubuntu-latest
binary_target: x86_64-unknown-linux-gnu
toolchain: 1.56.1
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -32,7 +52,8 @@ jobs:
sudo apt-get install musl-tools
sudo ln -s /usr/bin/musl-gcc /usr/bin/musl-g++

- name: Install LLVM and Clang # required for bindgen on Windows
# Required for bindgen on Windows
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
if: matrix.os == 'windows-latest'
with:
Expand All @@ -49,10 +70,10 @@ jobs:
- name: Install rust ${{ matrix.binary_target }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable-${{ matrix.binary_target }}
toolchain: ${{ matrix.toolchain }}-${{ matrix.binary_target }}
profile: minimal

- uses: actions-rs/cargo@v1
with:
command: make
args: --makefile ci-makefile.toml --no-workspace workspace-ci-flow
args: --no-workspace workspace-ci-flow
1 change: 1 addition & 0 deletions ci-makefile.toml → Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_RUN_CLIPPY = true
CARGO_MAKE_CLIPPY_ARGS = "--all-features -- -D warnings"
CARGO_MAKE_RUN_CHECK_FORMAT = true
CARGO_MAKE_CARGO_VERBOSE_FLAGS = "-vv"
RUSTFLAGS="-D warnings"

[tasks.check-format-ci-flow]
Expand Down
1 change: 1 addition & 0 deletions swiftnav-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description = "FFI bindings for libswiftnav"
readme = "../README.md"
repository = "https://github.com/swift-nav/swiftnav-rs"
license = "LGPL-3.0"
rust-version = "1.56.1"

[build-dependencies]
bindgen = "0.59"
Expand Down
2 changes: 2 additions & 0 deletions swiftnav/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ description = "GNSS positioning and related utilities"
readme = "../README.md"
repository = "https://github.com/swift-nav/swiftnav-rs"
license = "LGPL-3.0"
rust-version = "1.56.1"

[dependencies]
rustversion = "1.0"
chrono = { version = "0.4", optional = true }
swiftnav-sys = { version = "^0.8.0", path = "../swiftnav-sys/" }
33 changes: 33 additions & 0 deletions swiftnav/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,19 @@ impl GpsTime {
assert!(self >= GLO_TIME_START);
GloTime(unsafe { swiftnav_sys::gps2glo(self.c_ptr(), std::ptr::null()) })
}

#[rustversion::since(1.62)]
/// Compare between itself and other GpsTime
/// Checks whether week number is same which then mirrors
/// [f64::total_cmp()](https://doc.rust-lang.org/std/primitive.f64.html#method.total_cmp)
pub fn total_cmp(&self, other: &GpsTime) -> std::cmp::Ordering {
if self.wn() != other.wn() {
self.wn().cmp(&other.wn())
} else {
let other = other.tow();
self.tow().total_cmp(&other)
}
}
}

impl fmt::Debug for GpsTime {
Expand Down Expand Up @@ -904,6 +917,26 @@ mod tests {
assert!(t3 >= t3);
}

#[rustversion::since(1.62)]
#[test]
fn total_order() {
use std::cmp::Ordering;

let t1 = GpsTime::new(10, 234.566).unwrap();
let t2 = GpsTime::new(10, 234.567).unwrap();
let t3 = GpsTime::new(10, 234.568).unwrap();

assert!(t1.total_cmp(&t2) == Ordering::Less);
assert!(t2.total_cmp(&t3) == Ordering::Less);
assert!(t1.total_cmp(&t3) == Ordering::Less);

assert!(t2.total_cmp(&t1) == Ordering::Greater);
assert!(t3.total_cmp(&t2) == Ordering::Greater);
assert!(t3.total_cmp(&t1) == Ordering::Greater);

assert!(t1.total_cmp(&t1) == Ordering::Equal);
}

#[test]
fn add_duration() {
let mut t = GpsTime::new(0, 0.0).unwrap();
Expand Down