From 52b4280d7ba8f997eeda065eeaf536598c8ecd1b Mon Sep 17 00:00:00 2001 From: umgefahren <55623006+umgefahren@users.noreply.github.com> Date: Sun, 4 Aug 2024 21:47:53 +0200 Subject: [PATCH 1/4] Add all remaining apple platforms --- .github/workflows/ci.yml | 79 +++++++++++++++++++++++++++++++++++++++- Cargo.toml | 20 +++++----- src/lib.rs | 59 +++++++++++++++++++++++++----- 3 files changed, 138 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8d5f74..bb3e45b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: host: ubuntu-latest cross: false - - target: x86_64-apple-darwin + - target: aarch64-apple-darwin host: macos-latest cross: false @@ -107,3 +107,80 @@ jobs: - name: cargo clippy run: cargo clippy --workspace --all-features --examples --tests -- -D warnings + + apple-platforms: + name: Test on ${{ matrix.name }} + needs: gather_published_crates + strategy: + fail-fast: false + matrix: + include: + - name: ios + target: aarch64-apple-ios-sim + platform: auto-ios-aarch64-sim + unstable: false + deviceType: iPhone-15-Pro-Max + deviceName: my-iphone-15-pro-max + - name: tvOS + target: aarch64-apple-tvos-sim + platform: auto-tvos-aarch64-sim + unstable: true + deviceType: Apple-TV-4K-3rd-generation-4K + deviceName: my-4ktv + - name: watchOS + target: aarch64-apple-watchos-sim + platform: auto-watchos-aarch64-sim + unstable: true + deviceType: Apple-Watch-Ultra-2-49mm + deviceName: my-apple-watch + - name: visionOS + target: aarch64-apple-visionos-sim + platform: auto-visionos-aarch64-sim + unstable: true + deviceType: Apple-Vision-Pro + deviceName: my-apple-vision-pro + runs-on: macos-latest + env: + NAME: ${{ matrix.name }} + PLATFORM: ${{ matrix.platform }} + DEVICE_TYPE: ${{ matrix.deviceType }} + DEVICE_NAME: ${{ matrix.deviceName }} + BUILD_STD: ${{ matrix.unstable && '-Z build-std' || '' }} + PACKAGES: -p ${{ join(fromJSON(needs.gather_published_crates.outputs.members), ' -p ') }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: dtolnay/rust-toolchain@stable + if: ${{ !matrix.unstable }} + with: + targets: ${{ matrix.target }} + + - uses: dtolnay/rust-toolchain@master + if: ${{ matrix.unstable }} + with: + toolchain: nightly + components: rust-src + + - name: Check if compiles on ${{ matrix.name }} + run: cargo check $PACKAGES --all-features --target=${{ matrix.target }} $BUILD_STD --tests + + - name: Install cargo dinghy + uses: taiki-e/cache-cargo-install-action@v2 + with: + tool: cargo-dinghy + + - name: Start ${{ matrix.name }} simulator + id: boot-simulator + run: | + RUNTIME_ID=$(xcrun simctl list runtimes | grep $NAME | cut -d ' ' -f 7 | tail -1) + export SIM_ID=$(xcrun simctl create $DEVICE_NAME com.apple.CoreSimulator.SimDeviceType.$DEVICE_TYPE $RUNTIME_ID) + xcrun simctl boot $SIM_ID + echo "sim-id=$SIM_ID" >> $GITHUB_OUTPUT + + - name: Run all tests + env: + SIM_ID: ${{ steps.boot-simulator.outputs.sim-id }} + run: cargo dinghy -d $SIM_ID -p $PLATFORM test $PACKAGES --all-features $BUILD_STD + diff --git a/Cargo.toml b/Cargo.toml index b67837b..f63c37e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,26 +22,26 @@ ipnet = "2.3.1" log = "0.4.14" [target.'cfg(target_os = "linux")'.dependencies] -rtnetlink = { version = "0.10.0", default-features = false } +rtnetlink = { version = "0.14.1", default-features = false } -[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] +[target.'cfg(all(target_vendor = "apple", any(target_os = "macos", target_os = "ios", target_os = "visionos", target_os = "watchos", target_os = "tvos")))'.dependencies] core-foundation = "0.9.2" -if-addrs = "0.10.0" -system-configuration = "0.5.0" +if-addrs = "0.13.1" +system-configuration = "0.6.0" tokio = { version = "1.21.2", features = ["rt"], optional = true } -smol = { version = "1.2.5", optional = true } +smol = { version = "2.0.0", optional = true } [target.'cfg(target_os = "windows")'.dependencies] -if-addrs = "0.10.0" -windows = { version = "0.51.0", features = ["Win32_NetworkManagement_IpHelper", "Win32_Foundation", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"] } +if-addrs = "0.13.1" +windows = { version = "0.58.0", features = ["Win32_NetworkManagement_IpHelper", "Win32_Foundation", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"] } [target.'cfg(not(any(target_os = "ios", target_os = "linux", target_os = "macos", target_os = "windows")))'.dependencies] async-io = "2.0.0" -if-addrs = "0.10.0" +if-addrs = "0.13.1" [dev-dependencies] -env_logger = "0.10.0" -smol = "1.2.5" +env_logger = "0.11.5" +smol = "2.0.0" tokio = { version = "1.21.2", features = ["rt", "macros"] } [[example]] diff --git a/src/lib.rs b/src/lib.rs index 6f9ac7b..e1f9a72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,9 +4,16 @@ pub use ipnet::{IpNet, Ipv4Net, Ipv6Net}; -#[cfg(target_os = "macos")] -mod apple; -#[cfg(target_os = "ios")] +#[cfg(all( + target_vendor = "apple", + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ), +))] mod apple; #[cfg(not(any( target_os = "ios", @@ -20,28 +27,62 @@ mod linux; #[cfg(target_os = "windows")] mod win; -#[cfg(any(target_os = "macos", target_os = "ios"))] +#[cfg(all( + target_vendor = "apple", + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ), +))] #[cfg(feature = "tokio")] pub use apple::tokio; -#[cfg(any(target_os = "macos", target_os = "ios"))] +#[cfg(all( + target_vendor = "apple", + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ), +))] #[cfg(feature = "smol")] pub use apple::smol; #[cfg(feature = "smol")] #[cfg(not(any( - target_os = "ios", + all( + target_vendor = "apple", + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ), + ), target_os = "linux", - target_os = "macos", target_os = "windows", )))] pub use fallback::smol; #[cfg(feature = "tokio")] #[cfg(not(any( - target_os = "ios", + all( + target_vendor = "apple", + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ), + ), target_os = "linux", - target_os = "macos", target_os = "windows", )))] pub use fallback::tokio; From 07be1cd681fa9c5fb5072815f97081ffbe181257 Mon Sep 17 00:00:00 2001 From: umgefahren <55623006+umgefahren@users.noreply.github.com> Date: Sun, 4 Aug 2024 21:49:06 +0200 Subject: [PATCH 2/4] Bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f63c37e..8bf3972 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "if-watch" -version = "3.2.0" +version = "3.3.0" authors = ["David Craven ", "Parity Technologies Limited "] edition = "2021" keywords = ["asynchronous", "routing"] From 2644c83a4d14f4edce769cf46b5dc1cced2af4ef Mon Sep 17 00:00:00 2001 From: umgefahren <55623006+umgefahren@users.noreply.github.com> Date: Sun, 4 Aug 2024 21:52:06 +0200 Subject: [PATCH 3/4] Also run CI on push (testing) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb3e45b..8871a8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -on: [pull_request] +on: [pull_request, push] name: if-watch From 71add93d7b012fc06c8c96402b150880cd166e49 Mon Sep 17 00:00:00 2001 From: umgefahren <55623006+umgefahren@users.noreply.github.com> Date: Sun, 4 Aug 2024 21:53:03 +0200 Subject: [PATCH 4/4] Decouple from rust-libp2p --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8871a8e..9cf370f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,6 @@ jobs: apple-platforms: name: Test on ${{ matrix.name }} - needs: gather_published_crates strategy: fail-fast: false matrix: @@ -146,7 +145,6 @@ jobs: DEVICE_TYPE: ${{ matrix.deviceType }} DEVICE_NAME: ${{ matrix.deviceName }} BUILD_STD: ${{ matrix.unstable && '-Z build-std' || '' }} - PACKAGES: -p ${{ join(fromJSON(needs.gather_published_crates.outputs.members), ' -p ') }} steps: - uses: actions/checkout@v4 with: @@ -164,7 +162,7 @@ jobs: components: rust-src - name: Check if compiles on ${{ matrix.name }} - run: cargo check $PACKAGES --all-features --target=${{ matrix.target }} $BUILD_STD --tests + run: cargo check --all-features --target=${{ matrix.target }} $BUILD_STD --tests - name: Install cargo dinghy uses: taiki-e/cache-cargo-install-action@v2 @@ -182,5 +180,5 @@ jobs: - name: Run all tests env: SIM_ID: ${{ steps.boot-simulator.outputs.sim-id }} - run: cargo dinghy -d $SIM_ID -p $PLATFORM test $PACKAGES --all-features $BUILD_STD + run: cargo dinghy -d $SIM_ID -p $PLATFORM test --all-features $BUILD_STD